Modeled instruments
Header wauvio/ext/core/model_instruments.hpp. Modeled instruments synthesise sound from a TimbreRecipe rather than from samples. ModeledInstrument derives from SampledInstrument (see Sampling), so any modeled instrument can also load sample zones, which then take priority over the recipe.
TimbreRecipe
| Group | Fields (defaults) |
|---|---|
| Oscillators | osc1_shape BL_Sawtooth, osc2_shape Sine, osc2_ratio 2.0, osc_mix 0.35, detune_cents 4 |
| FM | use_fm false, fm_ratio 2, fm_index 2 |
| Noise | noise_mix, noise_attack_burst, pink_noise true |
| Envelope | envelope (DAHDSR 0 / 0.015 / 0 / 0.12 / 0.72 / 0.18), percussive |
| Filter | filter_cutoff 5000, filter_q 0.8, filter_env, filter_env_amount |
| Pitch | vibrato_rate_hz 5.2, vibrato_depth_cents, vibrato_delay_sec 0.18, pitch_attack_cents, pitch_attack_time 0.035, fixed_pitch_hz (−1 = follow note), pitch_instability |
| Formants | Two resonant peaks: formantN_hz, formantN_gain_db, formantN_q |
| Output | stereo_width 0.18, gain 0.9 |
| Articulation maps | art_decay_scale, art_noise_boost, art_pitch_shift, art_filter_scale (std::map<Articulation,double>) |
| Modulation | modulation: list of ModRoute |
render_timbre(recipe, note, sample_rate) renders one note from a recipe. A concrete instrument is usually just a constructor that tweaks recipe fields, e.g. Trumpet sets filter_cutoff = 6800, formant1_hz = 1400, pitch_attack_cents = 45. You can edit instrument.recipe at runtime to derive variants.
Family base classes
| Class | Used for |
|---|---|
ModeledInstrument | Root; owns recipe |
KeyboardInstrument | Pianos, organs, harpsichord, accordions |
BowedStringInstrument | Violin family, ensembles, bowed folk strings |
PluckedStringInstrument → GuitarInstrument | Guitars, basses, lutes, plucked world strings |
WoodwindInstrument → SaxophoneInstrument | Flutes, reeds, whistles, saxophones |
BrassInstrument | Trumpets, horns, trombones, tubas |
MalletInstrument | Tuned percussion, hammered strings |
PercussionInstrument | Drums and unpitched percussion; adds hit(dyn, duration, art) |
WorldInstrument | Drones, pipes, hurdy-gurdy |
VocalInstrument | Choir/vowel-style vocal timbres (not the Yune singer engines) |
SynthInstrument | Synth leads, pads, basses |
ExperimentalInstrument | Theremin, bowed metal, tape and granular timbres |
DrumKit
Maps MIDI note numbers to instruments: map(note, instr), has, get, mapped_notes; play(note, dyn, duration) renders a hit; render_pattern(hits, total_duration, dyn) takes (time_seconds, midi_note) pairs. Concrete kits: see the catalog.
Full API listing
wauvio/ext/core/model_instruments.hpp
wauvio::music::struct TimbreRecipe
struct TimbreRecipe
wauvio::osc::WaveShape osc1_shape = wauvio::osc::WaveShape::BL_Sawtooth;
wauvio::osc::WaveShape osc2_shape = wauvio::osc::WaveShape::Sine;
double osc2_ratio = 2.0;
double osc_mix = 0.35;
double detune_cents = 4.0;
bool use_fm = false;
double fm_ratio = 2.0;
double fm_index = 2.0;
double noise_mix = 0.0;
double noise_attack_burst = 0.0;
bool pink_noise = true;
wauvio::env::DAHDSR envelope { 0.0, 0.015, 0.0, 0.12, 0.72, 0.18 };
bool percussive = false;
double filter_cutoff = 5000.0;
double filter_q = 0.8;
bool filter_env = true;
double filter_env_amount = 0.0;
double vibrato_rate_hz = 5.2;
double vibrato_depth_cents = 0.0;
double vibrato_delay_sec = 0.18;
double pitch_attack_cents = 0.0;
double pitch_attack_time = 0.035;
double fixed_pitch_hz = -1.0;
double pitch_instability = 0.0;
double formant1_hz = 0.0, formant1_gain_db = 0.0, formant1_q = 3.0;
double formant2_hz = 0.0, formant2_gain_db = 0.0, formant2_q = 3.0;
double stereo_width = 0.18;
double gain = 0.9;
std::map<Articulation, double> art_decay_scale;
std::map<Articulation, double> art_noise_boost;
std::map<Articulation, double> art_pitch_shift;
std::map<Articulation, double> art_filter_scale;
std::vector<ModRoute> modulation;
inline StereoBuffer render_timbre(const TimbreRecipe& r, const Note& note, int sample_rate)
wauvio::music::class ModeledInstrument
class ModeledInstrument : public SampledInstrument
public:
TimbreRecipe recipe;
explicit ModeledInstrument(std::string instrument_name = "")
wauvio::music::class KeyboardInstrument
class KeyboardInstrument : public ModeledInstrument
public:
explicit KeyboardInstrument(std::string n) : ModeledInstrument(std::move(n))
wauvio::music::class BowedStringInstrument
class BowedStringInstrument : public ModeledInstrument
public:
explicit BowedStringInstrument(std::string n) : ModeledInstrument(std::move(n))
wauvio::music::class PluckedStringInstrument
class PluckedStringInstrument : public ModeledInstrument
public:
explicit PluckedStringInstrument(std::string n) : ModeledInstrument(std::move(n))
wauvio::music::class WoodwindInstrument
class WoodwindInstrument : public ModeledInstrument
public:
explicit WoodwindInstrument(std::string n) : ModeledInstrument(std::move(n))
wauvio::music::class BrassInstrument
class BrassInstrument : public ModeledInstrument
public:
explicit BrassInstrument(std::string n) : ModeledInstrument(std::move(n))
wauvio::music::class SaxophoneInstrument
class SaxophoneInstrument : public WoodwindInstrument
public:
explicit SaxophoneInstrument(std::string n) : WoodwindInstrument(std::move(n))
wauvio::music::class MalletInstrument
class MalletInstrument : public ModeledInstrument
public:
explicit MalletInstrument(std::string n) : ModeledInstrument(std::move(n))
wauvio::music::class WorldInstrument
class WorldInstrument : public ModeledInstrument
public:
explicit WorldInstrument(std::string n) : ModeledInstrument(std::move(n))
wauvio::music::class PercussionInstrument
class PercussionInstrument : public ModeledInstrument
public:
explicit PercussionInstrument(std::string n) : ModeledInstrument(std::move(n))
PlayedNote hit(Dynamics dyn = Dynamics::mf, double duration = 0.4,
Articulation art = Articulation::Sustain, int sample_rate = 0) const
wauvio::music::class VocalInstrument
class VocalInstrument : public ModeledInstrument
public:
explicit VocalInstrument(std::string n) : ModeledInstrument(std::move(n))
wauvio::music::class SynthInstrument
class SynthInstrument : public ModeledInstrument
public:
explicit SynthInstrument(std::string n) : ModeledInstrument(std::move(n))
wauvio::music::class GuitarInstrument
class GuitarInstrument : public PluckedStringInstrument
public:
explicit GuitarInstrument(std::string n) : PluckedStringInstrument(std::move(n)) {}
wauvio::music::class ExperimentalInstrument
class ExperimentalInstrument : public ModeledInstrument
public:
explicit ExperimentalInstrument(std::string n) : ModeledInstrument(std::move(n))
wauvio::music::class DrumKit
class DrumKit
public:
std::string name;
explicit DrumKit(std::string kit_name) : name(std::move(kit_name)) {}
virtual ~DrumKit() = default;
void map(int midi_note, std::shared_ptr<Instrument> instr)
bool has(int midi_note) const { return mapping_.find(midi_note) != mapping_.end(); }
std::shared_ptr<Instrument> get(int midi_note) const
std::vector<int> mapped_notes() const
PlayedNote play(int midi_note, Dynamics dyn = Dynamics::mf, double duration = 0.4,
int sample_rate = 0) const
StereoBuffer render_pattern(const std::vector<std::pair<double,int>>& hits,
double total_duration, Dynamics dyn = Dynamics::mf,
int sample_rate = 0) const