Module dsp::biquad
Biquad (2nd-order IIR section) + design tools
struct Biquad is a single Direct-Form-II-Transposed 2nd-order section:
y[n] = b0*x[n] + z1
z1' = b1*x[n] - a1*y[n] + z2
z2' = b2*x[n] - a2*y[n]
(a0 is always normalized to 1 — every coefficient below already has it divided out.) DF2T is the conventional choice for a single biquad: only two state variables, and better numerical behavior under coefficient quantization than Direct Form I. Cascade several for a higher-order filter (e.g. two biquads for a 4th-order response) with FilterChain (sample_filter.h): a chain of SampleFilters is itself one, so chains nest.
Biquad::lowpass/highpass/bandpass/notch/allpass/peaking/lowshelf/ highshelf compute coefficients using Robert Bristow-Johnson's "Audio EQ Cookbook" formulas — the standard, widely-implemented reference for these particular filter shapes. Biquad::bilinear is the more general tool underneath: given any analog (s-domain) 2nd-order prototype, it derives the matching digital biquad via the substitution s = 2fs(z-1)/(z+1) (the bilinear transform) — use it directly for an analog prototype the cookbook doesn't cover (e.g. a Butterworth/ Chebyshev/Bessel design), the same way the cookbook formulas were themselves derived from an analog prototype internally.
Structs
| Biquad | |
| Biquad32 | Single precision (float coefficients and state), same contract as Biquad. The designers above compute in double; Biquad32::from rounds their result once (keeping its state). |
| FBiquad | Q8.24 fixed-point biquad: coefficients are designed in double precision via the designers above, then quantized once with FBiquad::from — the same design-time-float/runtime-fixed split as the rest of std/dsp. |