16. filters Reference
import filters.*; — biquad filters after Robert Bristow-Johnson's
Audio EQ Cookbook, plus a ringing filter. Parameter conventions:
| Parameter | Meaning |
fc | Cutoff or center frequency in Hz |
bw | Bandwidth in octaves |
rq | Reciprocal of Q (1/Q) — smaller = more resonant; √0.5 ≈ 0.707 is the flat (Butterworth) response |
db | Gain in dB (shelving and parametric EQ) |
All parameters are modulatable signals; the coefficient math runs at the rate of its
inputs, so filters driven by event-rate controls recompute coefficients only on control
changes.
Filter unit generators (12 dB/8ve)
| Function | Description |
lpf(in, fc) / hpf(in, fc) | Butterworth lowpass / highpass (rq = √0.5). |
rlpf(in, fc, rq) / rhpf(in, fc, rq) | Resonant lowpass / highpass. |
bpf(in, fc, bw) | Bandpass (constant 0 dB peak gain). |
brf(in, fc, bw) | Band reject (notch). |
apf(in, fc, rq) | Allpass (flat magnitude, frequency-dependent phase). |
lowShelf(in, fc, db, rq) / highShelf(in, fc, db, rq) | Shelving EQ. |
peakEQ(in, fc, db, bw) | Parametric (peaking) EQ. |
Steeper and split variants
| Function | Description |
lpf2, hpf2, rlpf2, rhpf2, apf2 | 24 dB/8ve versions: two identical cascaded biquads. |
crossover(in, freq) | Returns the tuple (lows, highs) = (in lpf2(freq), in hpf2(freq)) — multiband processing. |
ring(x, freq, ringTime) | Ringing (two-pole resonant) filter: impulses ring at freq for ringTime seconds — feed it clicks or noise bursts for modal/percussive tones. |
pling(x, freq, atkTime, dcyTime) | Difference of two rings: a ringing tone with a shaped attack. |
Coefficient layer
The ugens above are thin wrappers over coefficient functions returning
BiquadCoeffs (a tuple (b0, b1, b2, a1, a2), normalized by a0),
applied by the transposed-direct-form-II kernel. Use this layer to share one coefficient
computation across several filters, or to build your own responses:
| Function | Description |
biquad(in, coeffs) | One TDF-II biquad stage. |
biquad2(in, coeffs) | Two cascaded stages with the same coefficients. |
lpfCoeffs(fc), hpfCoeffs(fc), rlpfCoeffs(fc, rq), rhpfCoeffs(fc, rq), bpfCoeffs(fc, bw), brfCoeffs(fc, bw), apfCoeffs(fc, rq), lowShelfCoeffs(fc, db, rq), highShelfCoeffs(fc, db, rq), peakEQCoeffs(fc, db, bw) | RBJ cookbook coefficient computations for each response. |
-- one coefficient computation, two channels of filtering for free
-- (a stereo `in` broadcasts through a single biquad's state pair), or
-- share coeffs across distinct signals explicitly:
let coeffs = rlpfCoeffs(cutoff, 0.3);
let a = dry biquad(coeffs);
let b = wet biquad(coeffs);
↑ Back to top