Skip to content

Audio equalisers and biquads

Build audio equalisers from biquads, with cookbook peaking, shelf and notch filters, their poles and zeros, Q in octaves, and cascades whose dB curves add.

Before this20.2 · 6 more
Chapter 20 · Lesson 5 of 6

First, the picture

An equaliser’s “mid” knob turns up one band of a song and leaves the rest alone. Below, one small filter lifts the band around 1 kHz by 12 dB and then cuts it by 12 dB. Watch the poles and the zeros move apart, and then trade places.

Boost or cut one band

Cookbook peaking biquad at f_s = 48 kHz: f_0 = 1 kHz, Q = 1.41 (one octave wide).

G = 0 dB: the poles sit on the zeros, they cancel, and the gain is flat.

gain at 1 kHz
0.0 dB
pole radius
0.955
zero radius
0.955
0.00 / 12.00 s
Describe this picture

Two panels for the cookbook peaking biquad at fs=48f_s=48 kHz, with f0=1f_0=1 kHz and Q=1.41Q=1.41 (one octave wide). The plane, zoomed in near z=1z=1, has the real part from 0.85 to 1.03 and the imaginary part from −0.03 to 0.15, on one scale both ways. It shows only the upper half, with an arc of the unit circle. The upper pole is a cross and the upper zero a circle, each labelled with its radius, such as “r = 0.977”; a dotted ray from the origin at the angle Ω0\Omega_0 is labelled “1 kHz”. The gain panel plots the gain from −15 to 15 dB against frequency from 20 to 20 000 Hz on a log scale, as a solid curve. A dotted level sits at half the gain in dB, and a bracket between its two crossings is labelled with the width in octaves. The readouts are the gain at 1 kHz, in dB with one decimal on its own row, and the pole and zero radii, with three decimals.

The clip lasts 12 s. At G=0G=0 dB the poles sit on the zeros, at 0.955, they cancel, and the gain is flat. From 2 s to 4.5 s the gain eases up to +12 dB, and the poles and zeros move apart, close to the 1 kHz ray; the readouts follow on a grid of 0.1 dB. At 5.75 s, at +12 dB, the poles have moved toward the circle (0.977) and the zeros away (0.912), and the bell is one octave wide at half its height, 6 dB, from 708 to 1412 Hz. From 7 s to 9.5 s the gain eases down to −12 dB. At the end the same two radii are swapped: the zeros nearer the circle now dig a dip of exactly the same shape, upside down. After the clip the curve’s peak, or its dip, is a handle named “Gain G”, from −15 to +15 dB in steps of 0.5 dB, with a value like “−12.0 dB at 1 kHz”. The arrow keys move it by 0.5 dB, Page Up and Page Down by 3 dB, and Home and End jump to −15 and 15 dB. At 0, +12 and −12 dB the caption is the clip’s own; elsewhere it reads like “+6.0 dB: poles at 0.968, zeros at 0.937.” The gain is kept in the link, as peak.g, and starts at −12.

Boost or cut one band

A stereo with a “mid” knob lets you turn up the voices in a song without touching the bass or the cymbals. Turn it down by the same amount and the voices sink back by the same amount. I want to build that knob, and it takes one small filter.

The filter is the second-order system of Transfer functions, poles & zeros (16.3), with two zeros as well as two poles:

H(z)=b0+b1z−1+b2z−21+a1z−1+a2z−2.H(z)=\frac{b_0+b_1z^{-1}+b_2z^{-2}}{1+a_1z^{-1}+a_2z^{-2}}.

Its top and bottom are both quadratics in z−1z^{-1}, so it is called a biquad. Five numbers set it completely. By 16.3, the gain at a frequency comes from arrows to the point ejΩe^{j\Omega} on the unit circle. It is b0b_0 times the product of the two arrows from the zeros, divided by the product of the two arrows from the poles.

Choosing five numbers by hand is slow. R. Bristow-Johnson’s cookbook is a set of recipes that turns three settings you can hear into those five numbers. The settings are a centre frequency f0f_0 in hertz, a gain GdBG_\text{dB} in dB, and a width QQ.

QQ is the quality factor of First- and second-order systems (6.3). There, a larger QQ meant a sharper resonance; here it means a narrower band. First turn f0f_0 into rad/sample, as in Frequency in discrete time (12.1): Ω0=2πf0/fs\Omega_0=2\pi f_0/f_s.

The cookbook’s peaking recipe boosts or cuts a band around f0f_0. It uses two helpers. One is the gain factor 10GdB/4010^{G_\text{dB}/40}, whose square is the amplitude ratio of GdBG_\text{dB}. The other is the width term, sin⁡Ω0/(2Q)\sin\Omega_0/(2Q), written αQ\alpha_Q in this one display:

αQ=sin⁡Ω02Q,b0=1+αQ 10GdB/40,b1=−2cos⁡Ω0,b2=1−αQ 10GdB/40,a0=1+αQ 10−GdB/40,a1=−2cos⁡Ω0,a2=1−αQ 10−GdB/40.\begin{aligned} \alpha_Q&=\frac{\sin\Omega_0}{2Q},\\ b_0&=1+\alpha_Q\,10^{G_\text{dB}/40},\\ b_1&=-2\cos\Omega_0,\\ b_2&=1-\alpha_Q\,10^{G_\text{dB}/40},\\ a_0&=1+\alpha_Q\,10^{-G_\text{dB}/40},\\ a_1&=-2\cos\Omega_0,\\ a_2&=1-\alpha_Q\,10^{-G_\text{dB}/40}. \end{aligned}

Then divide all six by a0a_0, so that the bottom starts with 1. Two things follow straight from the lines. At GdB=0G_\text{dB}=0 the gain factor is 1, so each bb equals its aa: top and bottom are the same, and the filter passes everything unchanged.

Now flip the sign of GdBG_\text{dB}. The gain factor turns into its reciprocal, so the bb lines become the aa lines and the other way round. Top and bottom trade places, so HH becomes 1/H1/H, and its gain in dB changes sign at every frequency.

Where does the recipe come from? Bristow-Johnson started from an analog bell and applied the bilinear transform of IIR design by the bilinear transform (20.2), pre-warped so that the bell’s centre lands exactly on f0f_0. Analog frequency is ω\omega (rad/s), digital frequency is Ω\Omega (rad/sample); Oppenheim and Schafer use the opposite letters. I will not repeat that algebra here.

The picture at the top of the page runs at fs=48f_s=48 kHz, the usual rate for video and studio audio, with f0=1f_0=1 kHz. That is Ω0=2π⋅1000/48000=0.1309\Omega_0=2\pi\cdot1000/48000=0.1309 rad/sample, only a 48th of a turn. So the poles and zeros of an audio filter crowd close to z=1z=1, and the plane is zoomed in on that corner.

The gain panel’s frequency axis is logarithmic, as in Frequency response and Bode plots (8.4). An octave is a doubling of frequency, and on this axis every octave has the same width. I measure the width of a bell in octaves, between the two frequencies where it reaches half its height in dB.

Notice the start. At 0 dB the poles sit exactly on the zeros, so each pole’s arrow is as long as its zero’s arrow and the gain is 1 everywhere. As the gain rises, the poles move toward the circle. Near 1 kHz their arrows become short, the zeros’ arrows stay longer, and the gain climbs.

At −12 dB the radii swap, just as the recipe’s lines did. The zeros are now the near pair, and the bell turns into a dip of the same shape. A tone control turned up 12 dB and then down 12 dB moves between these two pictures.

Look closely and the pairs are not exactly on the ray. At +12 dB the zeros sit at 0.0930 rad and the poles at 0.1289 rad, while the ray is at 0.1309 rad. Even so, the recipe puts the top of the bell exactly on 1 kHz: the gain there is 12.00 dB.

After the clip, drag the bell up or down, or use the arrow keys, to set the gain yourself. At +6 dB the poles sit at 0.968 and the zeros at 0.937; at −6 dB the two radii swap.

Five shapes from one recipe

The cookbook has more recipes, all built from the same three settings. A shelf lifts or lowers everything on one side of a corner frequency f0f_0. A low shelf changes the lows, below the corner, and a high shelf changes the highs, above it.

Its third setting is a slope instead of a width. I use the cookbook’s slope of 1, the steepest that does not overshoot. Its lines are longer than the peaking ones, but they use the same gain factor and the same cos⁡Ω0\cos\Omega_0 and sin⁡Ω0\sin\Omega_0.

A notch removes one frequency completely. As in Resonators, notches and combs (17.4), it puts its zeros on the unit circle at ±Ω0\pm\Omega_0 and its poles just inside. Its recipe is the shortest:

b0=1,b1=−2cos⁡Ω0,b2=1,a0=1+sin⁡Ω02Q,a1=−2cos⁡Ω0,a2=1−sin⁡Ω02Q,\begin{aligned} b_0&=1,\quad b_1=-2\cos\Omega_0,\quad b_2=1,\\ a_0&=1+\frac{\sin\Omega_0}{2Q},\\ a_1&=-2\cos\Omega_0,\\ a_2&=1-\frac{\sin\Omega_0}{2Q}, \end{aligned}

with the same width term, and all six divided by a0a_0 again. Its bottom line is the peaking recipe’s at 0 dB, so the notch’s poles are the ones from the first instrument’s first frame, 0.955 from the origin.

The figure puts five of these shapes on the same axes as the first instrument’s gain panel.

peaking, +12 dB at 1 kHz120−12low shelf, +6 dB below 100 Hz120−12high shelf, +4 dB above 8 kHz120−12notch at 1 kHz, Q = 1.41120−12peaking cut, −12 dB at 1 kHz120−1220100100010 000frequency (Hz)gain (dB)
Fig. Five shapes from one recipe. A shelf reaches half its gain at its corner (+3.0 dB at 100 Hz for the low shelf); the notch falls below −100 dB at 1 kHz and is −10.9 dB at 900 Hz.

Three bands add up

One biquad shapes one band. To shape a whole song you run several in a row, a cascade: the output of one is the input of the next. At each frequency the first multiplies the sine by its gain, the next multiplies the result by its own gain, and so on. So the gains multiply.

In How big is a signal (1.3), multiplying by 10 always added the same number of dB, because a logarithm turns a product into a sum. So in a cascade the dB curves add. You can predict the whole equaliser by adding its bands’ curves, point by point.

A parametric equaliser is such a cascade where every band has its own f0f_0, GdBG_\text{dB} and QQ, for example a low shelf, a peak and a high shelf. A graphic equaliser fixes the centres and gives you only the gains. The usual one has 31 bands a third of an octave apart, at the frequencies of the standard ISO 266, from 20 Hz to 20 kHz.

Below, three bands run in a row. Watch the thick total form as the sum of the three thin curves.

Three bands add up

A low shelf (100 Hz, +6 dB), a peak (1 kHz, −6 dB, Q = 1.41) and a high shelf (8 kHz, +4 dB) in a row, at f_s = 48 kHz.

Three biquads in a row.

total at 100 Hz
not yet
total at 1 kHz
not yet
0.00 / 13.00 s
Describe this picture

One panel for a low shelf (100 Hz, +6 dB), a peak (1 kHz, −6 dB, Q=1.41Q=1.41) and a high shelf (8 kHz, +4 dB) in a row, at fs=48f_s=48 kHz. It plots the gain from −10 to 10 dB against frequency from 20 to 20 000 Hz on a log scale. Each band is a thin dashed curve, labelled “low shelf”, “peak” and “high shelf”, and their total is a thick solid curve labelled “total”. A round handle sits at each band’s centre frequency and gain. The two readouts, in one row, are the total at 100 Hz and at 1 kHz, in dB with two decimals, or “not yet”. Under the panel is a “Hear it” button.

The clip lasts 13 s. It starts with empty axes and the 0 dB line. From 1.5 s to 6 s the low shelf, the peak and the high shelf draw, one at a time. At 7 s, in the hold, each band is shown alone: a shelf of +6 dB below 100 Hz, a dip of −6 dB at 1 kHz and a shelf of +4 dB above 8 kHz. From 8 s to 10 s the total draws, with a short vertical tick at its moving end showing each point formed as the sum of the three below it. At the end the total is 2.97 dB at 100 Hz (the shelf’s 3.00 plus the peak’s −0.03) and −6.00 dB at 1 kHz. After the clip each handle drags both ways: left and right set the frequency, from 20 Hz to 20 kHz in steps of a twelfth of an octave, and up and down set the gain, from −10 to +10 dB in steps of 0.5 dB. Tab moves between the handles, named “Low shelf”, “Peak” and “High shelf”, and the arrow keys move the one with focus; each value reads like “100 Hz, +6.0 dB”. Each band’s QQ stays fixed. The three bands are kept in the link, as eq.low, eq.peak and eq.high, each as “frequency,gain”, starting at “100,6”, “1000,-6” and “8000,4”. Away from those settings the caption reads in the form “Total: 4.12 dB at 100 Hz, −1.50 dB at 1 kHz.” The “Hear it” button plays 3 s of hiss through the three bands; the hiss is made in the browser on the first press, the same every time, and the biquads are recomputed for the sound card’s sample rate.

Notice the 2.97 dB at 100 Hz. It is the shelf’s 3.00 plus the peak’s −0.03, and the high shelf adds nothing there. The peak’s tail reaches a long way down, but only a little.

After the clip, drag each band’s handle, or use Tab and the arrow keys, to move it. Try raising the peak to 0 dB. The total is then 3.00 dB at 100 Hz and 0.00 dB at 1 kHz: only the peak’s share of the sum has changed.

Press “Hear it” to play 3 s of hiss, a random noise with every frequency in it, through the three bands. Press it again to stop.

How wide is a Q?

Audio people often give a band’s width in octaves instead of QQ. For a bell NN octaves wide, the analog relation is

Q=2N2N−1.Q=\frac{\sqrt{2^{N}}}{2^{N}-1}.

At N=1N=1 this is 2/1=1.41\sqrt2/1=1.41, the first instrument’s QQ. To go the other way, write x=2N/2x=2^{N/2}. The relation becomes Qx2−x−Q=0Qx^2-x-Q=0, whose positive root gives

N=2ln⁡2 ln⁡1+1+4Q22Q.N=\frac{2}{\ln2}\,\ln\frac{1+\sqrt{1+4Q^2}}{2Q}.

The formula is for the analog bell. The digital bell of the first instrument measures 0.997 octave, not 1, because the bilinear transform squeezes frequencies a little. At 1 kHz out of 48 kHz the difference is too small to see.

Worked example

Let’s compute the page’s numbers ourselves.

1. A peak of +12 dB at 1 kHz, Q=2Q=\sqrt2, 48 kHz. First the helpers: Ω0=0.1309\Omega_0=0.1309 rad/sample, cos⁡Ω0=0.991445\cos\Omega_0=0.991445 and sin⁡Ω0=0.130526\sin\Omega_0=0.130526. The width term is 0.130526/(2⋅1.414214)=0.0461480.130526/(2\cdot1.414214)=0.046148, and the gain factor is 1012/40=1.99526210^{12/40}=1.995262.

The recipe gives b0=1+0.046148⋅1.995262=1.092077b_0=1+0.046148\cdot1.995262=1.092077, b1=−1.982890b_1=-1.982890 and b2=0.907923b_2=0.907923. On the bottom, a0=1+0.046148/1.995262=1.023129a_0=1+0.046148/1.995262=1.023129 and a2=0.976871a_2=0.976871. Dividing by a0a_0:

  • top: 1.067390, −1.938065, 0.887398;
  • bottom: 1, −1.938065, 0.954788.

Now read off the roots. A pair re±jθre^{\pm j\theta} multiplies out to 1−2rcos⁡θ z−1+r2z−21-2r\cos\theta\,z^{-1}+r^2z^{-2}. So the pole radius is 0.954788=0.9771\sqrt{0.954788}=0.9771, and cos⁡θ=1.938065/(2⋅0.9771)=0.99171\cos\theta=1.938065/(2\cdot0.9771)=0.99171 gives θ=0.1289\theta=0.1289 rad, or 7.38°.

For the zeros, divide the top by b0b_0 first: r2=0.887398/1.067390=0.831372r^2=0.887398/1.067390=0.831372, so r=0.9118r=0.9118. Then cos⁡θ=1.938065/(2⋅1.067390⋅0.9118)=0.99567\cos\theta=1.938065/(2\cdot1.067390\cdot0.9118)=0.99567, so θ=0.0930\theta=0.0930 rad, or 5.33°.

The gain is 12.00 dB at 1 kHz, 5.99 dB at 707 Hz, one half octave below, and 2.51 dB at 500 Hz, one octave below.

2. Shelves and a notch. Take the low shelf of the second instrument, +6 dB at 100 Hz. It gives 6.00 dB at 0 Hz, 3.00 dB at its corner and 0.38 dB at 200 Hz, one octave above. The high shelf, +4 dB at 8 kHz, gives 2.00 dB at its corner and 3.998 dB at 20 kHz.

The notch at 1 kHz with Q=2Q=\sqrt2 has b0=1/(1+0.046148)=0.955888b_0=1/(1+0.046148)=0.955888 after the division. It is −10.85 dB at 900 Hz and −11.65 dB at 1100 Hz. On a logarithmic axis 1100 Hz is nearer to 1 kHz than 900 Hz is, so it sits deeper in the notch.

3. The equaliser’s total. Adding the three bands’ dB at eleven frequencies gives the table.

Frequency (Hz)Total (dB)Where it comes from
205.99low shelf
505.62low shelf
1002.97low shelf at its corner
2000.24low shelf, peak’s tail
500−1.12peak
1000−6.00peak at its centre
2000−1.11peak
50000.31high shelf, peak’s tail
80001.96high shelf at its corner
16 0003.94high shelf
20 0004.00high shelf

4. Q and octaves. A third-octave band of a graphic equaliser has N=1/3N=1/3, so Q=21/6/(21/3−1)=4.32Q=2^{1/6}/(2^{1/3}-1)=4.32. Going the other way, Q=1Q=1 gives N=(2/ln⁡2)ln⁡((1+5)/2)=1.39N=(2/\ln2)\ln\big((1+\sqrt5)/2\big)=1.39 octaves.

Where you’ll meet this

Every mixing desk, car stereo and phone equaliser is a cascade of biquads like these. The Web Audio API’s BiquadFilterNode, which every web browser provides, computes its peaking, shelf and notch coefficients from the cookbook formulas.

A linear-phase FIR equaliser, which delays every frequency equally, is part of Choosing FIR or IIR (20.6). Running biquads safely with few bits is Second-order sections (21.2) and Finite word-length effects (21.3). More audio processing follows in Audio effects (29.2).

The maths behind it · linear combinations

A cascade is a product of transfer functions, and in dB a product becomes a sum. So the equaliser’s dB curve is a linear combination of its band curves. That is why a graphic equaliser can be fitted to a target curve by least squares on its band gains.

The maths behind it · kernel regression

On a logarithmic frequency axis a peaking bell looks like a smooth bump. A graphic equaliser approximates a target curve by a sum of bumps at fixed centres, like a kernel regression or a radial-basis fit with fixed kernels.

Reference card

ShapePoles and zerosCookbook inputs
Biquadb0+b1z−1+b2z−21+a1z−1+a2z−2\dfrac{b_0+b_1z^{-1}+b_2z^{-2}}{1+a_1z^{-1}+a_2z^{-2}}five numbers
Peakingpoles and zeros near the angle Ω0=2πf0/fs\Omega_0=2\pi f_0/f_sf0f_0, GdBG_\text{dB}, QQ; ±GdBG_\text{dB} swaps the radii
Shelfhalf the gain in dB at the cornerf0f_0, GdBG_\text{dB}, slope
Notchzeros on the circle, poles just insidef0f_0, QQ (17.4)
Q and octavesQ=2N/(2N−1)Q=\sqrt{2^{N}}/(2^{N}-1)Q=2Q=\sqrt2: one octave
Cascadegains multiply, dB addparametric and graphic EQ

End of lesson 20.5

Where to go next.

Phasorium
LibraryEvery lesson, in order

Parts

About Phasorium
Look