Biquad
Tier: Primitives | ComponentType: 6 | Params: 4
Second-order IIR filter implementing the Audio EQ Cookbook with 7 filter types and Direct Form II Transposed topology.
Overview
The Biquad is the workhorse EQ filter of audio DSP. It implements Robert Bristow-Johnson's Audio EQ Cookbook formulas for lowpass, highpass, bandpass, notch, peaking EQ, low shelf, and high shelf responses. The Direct Form II Transposed structure provides excellent numerical stability and low sensitivity to coefficient quantization.
Coefficients are lazily recalculated only when parameters change (via an atomic dirty flag), avoiding unnecessary computation on the audio thread.
File Locations
| Path | |
|---|---|
| Header | Sources/FolioDSP/include/FolioDSP/Primitives/Biquad.h |
| Implementation | Sources/FolioDSP/src/Primitives/Biquad.cpp |
| Tests | Tests/FolioDSPTests/BiquadTests.swift |
| Bridge | Sources/FolioDSPBridge/src/FolioDSPBridge.mm (BiquadBridge) |
Parameters
| Index | Name | Description | Min | Max | Default Min | Default Max | Default | Unit |
|---|---|---|---|---|---|---|---|---|
| 0 | Frequency | Center/cutoff frequency | 20.0 | 20000.0 | 200.0 | 8000.0 | 1000.0 | Hz |
| 1 | Q | Quality factor (0.707=Butterworth, higher=sharper) | 0.1 | 30.0 | 0.5 | 10.0 | 0.707 | |
| 2 | Gain | Boost/cut for peak and shelf types | -24.0 | 24.0 | -12.0 | 12.0 | 0.0 | dB |
| 3 | Type | Filter type: 0=LP, 1=HP, 2=BP, 3=Notch, 4=Peak, 5=LowShelf, 6=HighShelf | 0.0 | 6.0 | 0.0 | 6.0 | 0.0 |
Processing Algorithm
1. Coefficient Calculation (RBJ Cookbook)
Common intermediate values:
Coefficients are computed per filter type (LP, HP, BP, Notch, Peak, LowShelf, HighShelf) and normalized by \(a_0\).
2. Direct Form II Transposed
Core Equations
Lowpass: \(b_0 = \frac{1 - \cos\omega_0}{2}, \quad b_1 = 1 - \cos\omega_0, \quad a_0 = 1 + \alpha\)
Peak: \(b_0 = 1 + \alpha A, \quad a_0 = 1 + \alpha/A\)
Snapshot Fields
| Field | Type | Range | Unit | Description |
|---|---|---|---|---|
| Frequency | Float | 20–20000 | Hz | Current frequency |
| Q | Float | 0.1–30 | Current Q | |
| Gain | Float | -24–24 | dB | Current gain |
| Type | Float | 0–6 | Active filter type | |
| Output | Float | -1–1 | Current output |
Implementation Notes
- Lazy coefficient recalculation via atomic dirty flag — computed only when params change
- Gain parameter only affects Peak and Shelf filter types; other types ignore it
- Q = 0.707 gives maximally flat (Butterworth) response
- No DC blocker needed — biquad is inherently stable
Equation Summary
y = b0x + z1; z1 = b1x - a1y + z2