Tzopilotl
Docs
GitHub

Writing SynthDefs

16. filters Reference

import filters.*; — biquad filters after Robert Bristow-Johnson's Audio EQ Cookbook, plus a ringing filter. Parameter conventions:

ParameterMeaning
fcCutoff or center frequency in Hz
bwBandwidth in octaves
rqReciprocal of Q (1/Q) — smaller = more resonant; √0.5 ≈ 0.707 is the flat (Butterworth) response
dbGain 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)

FunctionDescription
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

FunctionDescription
lpf2, hpf2, rlpf2, rhpf2, apf224 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:

FunctionDescription
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