Expand description
Audio filters and bus routing: the DSP behind the mixer panel.
BusGraph resolves Project.buses (Main first) into an evaluation order and owns one FilterState
per (bus, filter) so IIR/delay state survives across blocks. Clips sum into their bus
(Project::bus_of), each bus runs its filter chain, then gain/pan/mono, then sums into its output bus.
Interleaved stereo f32 @ 48 kHz, processed in place, block-continuous.
Filters (model::FilterKind): Eq (5-band RBJ: low shelf, three peaks, high shelf — EQ_BANDS maps
bands to parameter indices), HighPass/LowPass (RBJ),
Reverb (Freeverb comb+allpass), Echo (delay line + feedback, optional ping-pong), Distortion (soft clip
- tone), Compressor (peak detector, attack/release, makeup), NoiseGate, Noise (white/pink/tone), Gain.
Parameters: every AudioFilter param is an Animated read once per block at the block-start
timeline time t (AudioFilter::at(i, t)). Coefficients / delay lengths / thresholds are recomputed
from those values and held constant for the block, so automation steps at block boundaries
(≤ ~100 ms). The two params where a step is audible as a click — the Gain filter’s gain and the Noise
filter’s level — are ramped linearly from the previous block’s value across the block. All buffers
(delay lines, comb/allpass memories, bus scratch) are sized at construction / first block, so steady
state allocates nothing.
Structs§
- Allpass 🔒
- Biquad 🔒
- Transposed direct-form II biquad, one per channel per band.
- BusGraph
- Bus routing + per-bus filter state, rebuilt when the bus set changes.
- Comb 🔒
- Delay 🔒
- Interleaved-stereo delay line used by Echo.
- Filter
State - Per-filter DSP state (biquad histories, delay lines, envelopes).
- Freeverb 🔒
- Slot 🔒
Enums§
- Band
- RBJ band shapes used by the EQ and the pass filters.
- Dsp 🔒
- The DSP memory a filter kind needs. Sized once in
FilterState::new.
Constants§
- ALLP_
LEN 🔒 - COMB_
LEN 🔒 - EQ_
BANDS - The EQ’s five bands, low to high, as
(shape, gain param, freq param, Q param). The first sevenF_EQslots keep the meaning the 3-band EQ gave them, so projects saved before the extra peaks still load — hence the scattered indices. - MAX_
ECHO_ 🔒S - Longest Echo delay the parameter allows, in seconds (
F_ECHO’s “Delay ms” max). - MAX_
HOPS 🔒 - Deepest routing chain we follow before declaring a cycle.
- REV_
IN_ 🔒GAIN - Freeverb’s
fixedgain: how much of the dry signal is pushed into the comb bank. - SPREAD 🔒
- Right-channel stereo spread, in samples at 44.1 kHz (Freeverb’s
stereospread).
Functions§
- add_
into 🔒 - coef 🔒
- One-pole smoothing coefficient for a time constant in ms.
- coeffs
- Normalised RBJ coefficients
[b0, b1, b2, a1, a2](a0 divided out). Shelves take Q like the peaks (Q = 0.707 is the classic slope-1 shelf). - db_
to_ lin - Linear amplitude of a dB value.
- filter_
bands - The bands an EQ / pass filter is made of at time
t, as(band, freq, q, gain_db). Empty for every other kind — the UI draws a response curve exactly when this is non-empty. - filter_
response_ db - Total response of an EQ / pass filter at
freq, in dB (0 for other kinds). - hops 🔒
- Hops from
idto Main along resolved outputs (Main = 0, a broken cycle = 1). - lin_
to_ db - dB of a linear amplitude (floored at -120 dB).
- pink_
tick 🔒 - Paul Kellet’s economy pink filter (~ -3 dB/oct over the audio band).
- resolve 🔒
- Where
breally sends: its own id when terminal (Main, dangling or cyclic output). - response_
db - |H(e^jw)| in dB at
freqfor one set of normalised coefficients. - white 🔒
- xorshift32 white noise in [-1, 1).