Skip to content
Tutorials Center
My learning

Topics

Lesson 32 of 38 ยท Applications

An Audio Equalizer from Biquads

Design peaking, shelving and notch biquads from the audio EQ cookbook formulas, cascade them into a multiband equalizer and verify the gains in Python.

Every music player, phone and mixing console contains an equalizer: bass and treble knobs, a graphic EQ with sliders, a parametric EQ with frequency, gain and bandwidth controls. They are all built from the same piece, the biquad (second-order IIR section) that you met in second-order sections. In this lesson you build a peaking filter, two shelving filters and a notch from closed-form formulas, then cascade them.

Why biquads?

A biquad has five numbers b0, b1, b2, a1, a2 (with a0 normalized to 1). Their values depend on three user parameters: the center or corner frequency f0, the gain in dB, and a quality factor Q that sets the bandwidth. Because the formulas are cheap, an equalizer can recompute them while you move a slider, and a cascade of biquads runs fast and stays numerically stable.

Common EQ building blocks

Peaking Boost or cut around f0
Low shelf Lifts or lowers all bass
High shelf Lifts or lowers all treble
Notch Removes a narrow band

Each one is a single biquad.

1 / 2

The cookbook formulas

Define A = 10^(gain_dB / 40), w0 = 2 pi f0 / fs, alpha = sin(w0) / (2 Q). The peaking EQ coefficients (before dividing by a0) are:

  • b0 = 1 + alpha A, b1 = -2 cos w0, b2 = 1 - alpha A
  • a0 = 1 + alpha / A, a1 = -2 cos w0, a2 = 1 - alpha / A

At w0 the gain equals exactly gain_dB, and far from f0 it is 0 dB.

Python A peaking filter

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The gain is +6.00 dB at 1 kHz and near 0 dB away from it. A higher Q makes the bump narrower, so the cut with Q = 4 is concentrated around 1 kHz.

Shelving filters and the notch

A shelf changes everything below (low shelf) or above (high shelf) the corner frequency by a fixed gain. The notch has a zero pair on the unit circle, so the gain at f0 is zero. Instead of repeating the formulas, you can use scipy.signal.iirnotch for the notch and write the shelves from the same cookbook family.

Python Shelves and a notch

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The shelf gives the full +8 dB for low frequencies, about +4 dB at the corner (half the gain in dB) and 0 dB at high frequencies. The notch drops to nearly nothing exactly at 50 Hz.

A graphic equalizer

A ten-band graphic EQ places peaking filters at octave centers (31, 62, 125, ..., 16000 Hz) with fixed Q (about 1.4 to 2) and lets the user set each gain. The cascade's response is the product of the individual responses, so the gains in dB add.

Python Cascading ten bands

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The achieved gain at each center is within about 1 dB of the setting; neighboring bands add a little because their skirts overlap. The tones come out at roughly the expected levels (the 126 Hz tone is boosted, the 2 kHz tone is cut). Real graphic EQs optimize the band gains jointly to hit the sliders exactly.

Design tips

  • Keep gains moderate: boosting a band by 12 dB can clip the output. Reduce the overall gain or use a limiter.
  • Smooth parameter changes (interpolate gain or frequency over a few milliseconds) to avoid clicks.
  • Process in floating point or use the transposed direct form II; at low frequencies relative to fs (such as 31 Hz at 48 kHz) fixed-point biquads are noisy.
  • Linear-phase alternative: a long FIR equalizer, convenient for mastering, with a latency of half its length.
  • Match the analog behavior: the formulas come from the bilinear transform of analog prototypes (see the bilinear transform), so the response near fs/2 is warped slightly.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What do the three user parameters of a peaking EQ biquad control?

    f0 places the bump, the gain sets its height and Q its narrowness. The coefficients are computed from these three.
  2. 2. A graphic equalizer's total response in dB is

    Cascaded filters multiply their frequency responses, so decibel responses add.
  3. 3. What does the gain of a low shelf look like?

    A low shelf applies a fixed gain to the low band and leaves high frequencies unchanged, with a smooth transition around the corner.
  4. 4. What is the gain of a notch filter at its center frequency?

    The notch has zeros on the unit circle at the center frequency, which removes that component entirely.

Summary

  • A biquad with five coefficients implements peaking, shelving and notch filters from f0, gain and Q.
  • Cascades of biquads form graphic and parametric equalizers; responses multiply, dB values add.
  • Keep gains moderate, smooth parameter changes, and use stable second-order sections.
  • A linear-phase FIR is the alternative when phase matters.

Next: ECG and Power-Line Denoising