Skip to main content

Module effects

Module effects 

Source
Expand description

Prepared bus effect chains. All times and parameter ramps are sample based.

Install with MixerHandle::set_effects, then update a matching slot with MixerHandle::set_effect. Slots are zero based and follow the slice order. Structural edits are immediate and reset the new chain’s state; fade the bus around them when needed. Parameter ramps preserve filter/delay/reverb history. A delay-time ramp moves the read head and intentionally changes pitch. Chorus, flanger and phaser share retained-phase ModulationRate automation. Bitcrusher deliberately quantizes and holds samples; Saturation applies a cubic soft curve. These colour effects do not oversample or suppress aliasing. Parameter smoothing does not remove their intentional waveform discontinuities.

Named buses run in combined audio/sidechain dependency order, effects before the bus fader. Detectors hear the key bus after its effects, gain and pause fade, in the same frame, including routing mute/solo gating when enabled. By default all named buses feed master; super::BusRouting replaces those audio paths explicitly. Master effects, gain and the limiter still run last. Self sidechains, master as a key, and cycles are refused. Application-time failures arrive as MixerEvent::EffectsRejected; the previous chain survives.

A paused bus freezes its effect buffers and parameter clock. Tails continue after its voices end, until the bus is paused or the chain is removed. Sidechain attack/release are exponential time constants (63.2% after one time constant). Stereo detectors use the louder channel and apply one gain to both channels.

Buffers are prepared on the handle. At most MixerConfig::queue chain edits may await reclamation: poll events to release old chains and permit more edits. Even if events are not polled or the handle is dropped, rendering retains these buffers rather than freeing them. Dropping the mixer itself frees its resources.

Structs§

Bitcrusher
Signed PCM quantization plus sample-and-hold rate reduction. At integer bits, exactly 2^bits levels span -1..=1-2^(1-bits), rounded to nearest (ties away from zero). Fractional bits blend adjacent integer quantizers for smooth automation. Captures the first frame, then advances one shared stereo phase per frame. Aliasing and quantization/hold steps are intentional; no dither or anti-aliasing.
Chorus
Two sinusoidally modulated delay taps per channel, with a quarter-cycle offset between taps. The wet signal is their average. Linear interpolation; no added dry-path latency. Delay +/- depth must fit 1 sample..=80 ms at preparation.
Compressor
Hard-knee peak compressor. sidechain: None detects this effect’s input. depth blends gain reduction with unity; 0 disables reduction, 1 is full depth.
Delay
Fractional-sample delay with linear interpolation and optional negative feedback.
Flanger
One sinusoidally modulated short delay tap per channel, creating a moving comb response when mixed with dry audio. Delay +/- depth must fit 1 sample..=20 ms. Default settings need at least 2000 Hz; reduce depth or increase delay below it.
Phaser
Four first-order allpass stages per channel. Full wet with zero feedback has unity magnitude at a fixed frequency; blending dry/wet creates two notches. The default 800 Hz centre needs at least 1778 Hz output; lower it at lower rates.
Reverb
Four parallel feedback combs and two allpass diffusers per channel.
Saturation
Symmetric cubic soft saturation, without oversampling. For driven input v, f(v)=v-v^3/3 when |v|<1, otherwise sign(v)*2/3. The slope joins continuously at +/-1. This is a colour effect, not a physical tape model; harmonics can alias.

Enums§

Effect
A chain slot’s typed settings. New variants can share the same preparation, automation, sidechain and lifetime machinery.
EffectTime
Delay time in seconds or beats with an explicit tempo. To follow a tempo change, send updated settings with the new BPM; the time follows the requested ramp.
ModulationRate
LFO speed in cycles/second or one cycle per stated number of quarter-note beats. Beat mode takes an explicit BPM. Send updated settings to follow tempo changes. Speed updates preserve phase; this is period sync, not transport phase lock.

Constants§

MAX_EFFECTS
Maximum effects per bus, including the master.