Skip to content

Chapter 21

Implementing filters

Four lessons in Part VII, Filter design. Read them in order, or start anywhere: a prerequisite is a link, never a gate.

Start with 21.1
0 of 4 read2 on the essential pathabout 78 minutes

Lessons in this chapter

Block diagram of direct form II. x[n] enters the poles' adders; one column of two delay boxes holds w[n−1] and w[n−2] and feeds the gains −a₁ and −a₂ back to them and the gains b₀, b₁ and b₂ forward to the zeros' adders, which give y[n]. 2 delays and 5 multipliers.Block diagram of direct form II. x[n] enters the poles' adders; one column of two delay boxes holds w[n−1] and w[n−2] and feeds the gains −a₁ and −a₂ back to them and the gains b₀, b₁ and b₂ forward to the zeros' adders, which give y[n]. 2 delays and 5 multipliers.

Lesson 1 Essential20 minYou are hereRead

Filter structures

Wire one biquad five ways, from direct form I to a lattice, and find the same output with different delays and different stored values.

Pole-zero plane and gain plot (dB against frequency, 0 to 4000 Hz) of the order-5 elliptic filter, paired by nearness. Section 3: poles at radius 0.953, angle ±45.6°, with the zeros at ±57.4°; its gain peaks at 14.00 dB. Section 2: poles at radius 0.806, angle ±35.0°, with the zeros at ±76.4°; its gain peaks at 15.72 dB. Section 1: the real pole at 0.666, the zero at −1 and the gain 0.022; its gain stays below −17 dB. The whole filter, the sections' dB added, never exceeds 0 dB.Pole-zero plane and gain plot (dB against frequency, 0 to 4000 Hz) of the order-5 elliptic filter, paired by nearness. Section 3: poles at radius 0.953, angle ±45.6°, with the zeros at ±57.4°; its gain peaks at 14.00 dB. Section 2: poles at radius 0.806, angle ±35.0°, with the zeros at ±76.4°; its gain peaks at 15.72 dB. Section 1: the real pole at 0.666, the zero at −1 and the gain 0.022; its gain stays below −17 dB. The whole filter, the sections' dB added, never exceeds 0 dB.

Lesson 2 Essential18 minYou are hereRead

Second-order sections

Split a high-order IIR filter into biquads, pair its poles with nearby zeros, order the sections, and see why one long direct form breaks.

Two panels: the plane close to z = 1, real part 0.85 to 1.02, with an arc of the unit circle, and the gain in dB from 0 to 400 Hz. Small dots mark every pole that B = 6 fractional bits allow; they are sparse near z = 1. The wanted pole 0.9800∠5.00° is a faint cross, and its gain a dashed curve peaking at 108.1 Hz. The rounded poles are real, 1 and 0.953, one of them on the unit circle; the rounded gain, a solid curve, has no resonance and rises towards 0 Hz.Two panels: the plane close to z = 1, real part 0.85 to 1.02, with an arc of the unit circle, and the gain in dB from 0 to 400 Hz. Small dots mark every pole that B = 6 fractional bits allow; they are sparse near z = 1. The wanted pole 0.9800∠5.00° is a faint cross, and its gain a dashed curve peaking at 108.1 Hz. The rounded poles are real, 1 and 0.953, one of them on the unit circle; the rounded gain, a solid curve, has no resonance and rises towards 0 Hz.

Lesson 320 minYou are hereRead

Finite word-length effects

Fixed-point numbers round a filter's coefficients and signals. Poles snap to a grid, sums overflow, and rounding inside a loop can stop it decaying.

A ring of 8 slots, numbered 0 to 7 clockwise from the top: slot 0 x[8] = 8, slot 1 x[9] = 9, slot 2 x[10] = 10, slot 3 x[11] = 11, slot 4 x[4] = 4, slot 5 x[5] = 5, slot 6 x[6] = 6 and slot 7 x[7] = 7. The write head points at slot 3, which holds the newest value, x[11] = 11, in bold. Beside it, y[n] against sample n from 0 to 11 as stems with square heads, drawn up to n = 11: 0, 0.125, 0.375, 0.75, 1.25, 1.875, 2.625, 3.5, 4.5, 5.5, 6.5, 7.5. A bracket over the stems n = 8 to 11 reads: slots 0 to 3 again.A ring of 8 slots, numbered 0 to 7 clockwise from the top: slot 0 x[8] = 8, slot 1 x[9] = 9, slot 2 x[10] = 10, slot 3 x[11] = 11, slot 4 x[4] = 4, slot 5 x[5] = 5, slot 6 x[6] = 6 and slot 7 x[7] = 7. The write head points at slot 3, which holds the newest value, x[11] = 11, in bold. Beside it, y[n] against sample n from 0 to 11 as stems with square heads, drawn up to n = 11: 0, 0.125, 0.375, 0.75, 1.25, 1.875, 2.625, 3.5, 4.5, 5.5, 6.5, 7.5. A bracket over the stems n = 8 to 11 reads: slots 0 to 3 again.

Lesson 420 minYou are hereRead

Real-time processing

Keep a filter's past inputs in a circular buffer, size audio blocks for latency and load, and check what fits on a processor.

After this chapter

Where to go next.

The chapters either side, and the rest of Part VII in the library.

Phasorium
LibraryEvery lesson, in order

Parts

About Phasorium
Look