@maruaudio/dsp/filters/biquad is a second-order IIR filter with RBJ Audio EQ Cookbook coefficients, run in transposed direct form II. It filters one mono signal, one sample per biquadNodeTick call. Coefficients, outputs and state are rounded to 32-bit floats (Math.fround).
const state = initBiquadNode(48000)
setBiquadNodeType(state, BIQUAD_LOWPASS)
setBiquadNodeFrequency(state, 1200)
updateBiquadNodeCoefficients(state) // before the next tick
const y = biquadNodeTick(state, x)Parameters
| Setter | Range the setter enforces | Default |
|---|---|---|
setBiquadNodeType | Rounded, then 0 to 6: BIQUAD_LOWPASS, HIGHPASS, BANDPASS, NOTCH, PEAKING, LOWSHELF, HIGHSHELF | Low-pass |
setBiquadNodeFrequency | 10 Hz to 0.45 × the sample rate | 1000 Hz |
setBiquadNodeQ | 0.0001 to 40 | 0.7071 |
setBiquadNodeGainDb | −24 to +24 dB; read by peaking and shelf types only | 0 dB |
Band-pass has a constant 0 dB peak; gain enters as 10^(dB/40) (math/decibels).
Lifecycle
initBiquadNode → setters → updateBiquadNodeCoefficients → biquadNodeTick → resetBiquadNode. Setters only store values; a new state passes its input through until the coefficients are updated. prepareBiquadNodeSampleRate sets a new rate and clamps the stored frequency to its ceiling; update the coefficients again before the next tick. resetBiquadNode clears the two state words and keeps the settings. Ticks allocate nothing and do no I/O. The update calls cos, sin and pow, so run it when a parameter changes, not per sample.
When to use it
One fixed or occasionally retuned second-order filter per channel, with one state per channel: a tone control, an EQ band, a notch, a shelf. The leaf catalog lists filters/parametric-eq (a fused EQ with transitions) and filters/state-variable (a TPT filter).
Limits
- Mono sample tick, not a block Processor.
- Coefficient changes apply at once, with no smoothing.
- The clamp is the kernel node's conditional clamp, not the
math/rangepolicy: a NaN passes through unchanged. - A frequency clamped at a low rate stays clamped at a higher one until set again.