FX suite (wauvio/fx)
Mixer and bridges
See it in action: Mixing: inserts, buses, sends, sidechain, mastering
Mixer
Header fx/mixer/mixer.hpp. Mixer(sample_rate) combines audio Sources (name, audio, start_sec, linear gain).
add_source(Source)→ index;source(i),source_count().insert(i)→ the source's insertChain&.add_bus(name)→ index;bus(i)→ busChain&;bus_index(name)(throwsstd::out_of_range).send(src, bus, amount, post_fader = true)(index or bus name).sidechain(target, trigger, SidechainSettings)ducks the target by the trigger's level (post-insert, pre-fader). Defaults: threshold −30 dB, ratio 6, attack 5 ms, release 150 ms, knee 4 dB, makeup 0.master()→ masterChain&;set_mastering(MasterSettings),clear_mastering(),has_mastering(),last_master_report().render()— signal flow: inserts → sidechain → sends/buses → sum → master chain → mastering. The result is not normalised or clamped.
Because
render() keeps the mastered level, write it with fx::write_wav (clamps but never normalises) rather than a normalising writer.Bridges
| Function | Header | Description |
|---|---|---|
mixer_from_arrangement(arr, opts) | fx/mixer/from_arrangement.hpp (via fx/ext.hpp) | One Source per track with start time and gain preserved. The arrangement’s own master_reverb()/limiter() are not applied; use FX instead. |
write_wav(buf, path, opts) | same | Writes the buffer as-is (clamped, never normalised) using the RenderOptions bit depth, dither and seed. |
mixer_from_midi(music, opts) | fx/mixer/from_midi.hpp (via fx/midi.hpp) | One Source per MIDI part, named from the file; all start at 0 and use the same instruments and genre settings as the normal MIDI render. |
Full API listing
wauvio/fx/mixer/mixer.hpp
wauvio::fx::struct Source
struct Source
std::string name;
StereoBuffer audio;
double start_sec = 0.0; ///< where this source begins on the timeline
float gain = 1.0f; ///< fader (linear)
wauvio::fx::struct SidechainSettings
struct SidechainSettings
double threshold_db = -30.0;
double ratio = 6.0;
double attack_ms = 5.0;
double release_ms = 150.0;
double knee_db = 4.0;
double makeup_db = 0.0;
wauvio::fx::class Mixer
class Mixer
public:
explicit Mixer(int sample_rate = 0) : sr_(sample_rate > 0 ? sample_rate : global_config().sample_rate) {}
int sample_rate() const noexcept { return sr_; }
size_t add_source(Source s) { srcs_.push_back(Entry{std::move(s), Chain()}); return srcs_.size() - 1; }
size_t source_count() const noexcept { return srcs_.size(); }
Source& source(size_t i) { return srcs_.at(i).src; }
/// Insert chain for a source (runs on the source before sidechain, fader and sends).
Chain& insert(size_t i) { return srcs_.at(i).chain; }
size_t add_bus(const std::string& name) { buses_.push_back(Bus{name, Chain()}); return buses_.size() - 1; }
size_t bus_count() const noexcept { return buses_.size(); }
Chain& bus(size_t i) { return buses_.at(i).chain; }
/// Look a bus up by name; throws std::out_of_range if missing.
size_t bus_index(const std::string& name) const
/// Send `amount` (linear) of a source to a bus. post_fader = scaled by the source fader.
void send(size_t src, size_t bus_idx, double amount, bool post_fader = true)
void send(size_t src, const std::string& bus_name, double amount, bool post_fader = true) { send(src, bus_index(bus_name), amount, post_fader); }
/// Duck `target` by the level of `trigger` (post-insert, pre-fader signal of the trigger).
void sidechain(size_t target, size_t trigger, const SidechainSettings& s = SidechainSettings())
Chain& master() { return master_; }
/// Optional final stage: master the summed mix to a loudness target (after the master chain).
void set_mastering(const MasterSettings& s) { mastering_ = s; do_mastering_ = true; }
void clear_mastering() { do_mastering_ = false; }
bool has_mastering() const noexcept { return do_mastering_; }
const MasterReport& last_master_report() const noexcept { return report_; }
/// Renders the mix (inserts -> sidechain -> sends/buses -> sum -> master chain -> mastering).
/// The result is NOT normalised or clamped; write it with a level-preserving writer
/// (see fx::write_wav in wauvio/fx/ext.hpp) when mastering to a loudness target.
StereoBuffer render()
wauvio/fx/mixer/from_arrangement.hpp
wauvio::fx::Free functions, constants and aliases
/// Build a Mixer from an Arrangement: one Source per track (start time and gain preserved).
/// The Arrangement's own master_reverb()/limiter() are NOT applied - use fx effects instead.
inline Mixer mixer_from_arrangement(const wauvio::music::Arrangement& arr, const RenderOptions& opts = RenderOptions())
/// Write a stereo buffer exactly as it is (clamped to [-1, 1]; never normalised), so a
/// loudness-mastered mix keeps its level. Uses the RenderOptions bit depth / dither / seed.
inline void write_wav(const StereoBuffer& in, const std::string& path, const RenderOptions& opts = RenderOptions())
wauvio/fx/mixer/from_midi.hpp
wauvio::fx::Free functions, constants and aliases
/// One Source per MIDI part (names come from the file). Parts all start at 0 and are
/// rendered by the same instruments / genre settings as the normal MIDI render.
inline Mixer mixer_from_midi(const midi::track::MidiMusic& music, const RenderOptions& opts = RenderOptions())