Lesson 3
Filters
An oscillator hands you a fixed spectrum, and no instrument has a fixed spectrum. The classic fix is to start with a waveform containing far too much and then remove things, which is why the method is called subtractive. The removing is done by a filter.
What a filter actually is
A filter is a curve, and using it is multiplication. For every frequency, the curve says how much of it survives: 1.0 means untouched, 0.5 means halved, 0.0 means gone. Multiply the incoming spectrum by that curve, frequency by frequency, and the result is the output.
That is the entire idea, and everything else in this lesson is a question about the shape of the curve. It is worth holding onto because the usual mental model, of a filter as a gate that sound passes through, gets almost every prediction wrong.
The figure below draws the curve in gold and the measured output in violet. Set the source to white noise and the two lie on top of each other, because noise contains every frequency at equal power and so leaves the curve nowhere to hide. That is the claim demonstrated rather than asserted.
A curve, multiplied into a spectrum
Gold is what the filter does. Violet is what comes out. Try white noise.
Press play to see the trace
- Cutoff
- 900 Hz
- Level at cutoff
- -
- Measured slope
- -
- Sections
- 1
Keeps everything below the cutoff and rolls off above it. The default of subtractive synthesis, because harmonics are ordered by frequency and this is the control that decides how many survive.
Cutoff is not a wall
The most common misconception about filters is that the cutoff is where the sound stops. It is not. Cutoff is conventionally the point where the signal is down by 3 dB, which is a reduction to about 71% of the amplitude, and is a fairly subtle change rather than a cliff.
Watch the level at cutoff readout. The figure starts at a resonance of 0.707, which is the value at which the response is maximally flat, and the readout sits at −3.0 dB exactly, as the definition promises. Everything dramatic happens above the cutoff, gradually, and how gradually is the next question.
Slope, and why it comes in sixes
Above the cutoff the curve falls at a constant rate per octave, and that rate is what people mean by the filter's slope. It is always a multiple of 6 dB per octave, and the reason is structural rather than conventional: each pole in the filter contributes exactly 6 dB per octave.
The section used here is a two-pole design, so one of them rolls off at 12 dB per octave. Switch to two sections and they cascade. Cascading multiplies the curves, and multiplying magnitudes means adding decibels, so two 12 dB/octave sections give 24. The slope readout confirms it, and it is measured off the live response between one and two octaves above the cutoff rather than copied from the switch.
Two honest notes about that readout. Turn the resonance up and it drifts to around −14 rather than −12, because the resonant peak lifts the level at the nearer probe point and the fall away from it looks steeper than the true asymptote. And take the cutoff a little above 4 kHz (the exact point depends on your sample rate) and it stops reporting altogether: measuring a stopband slope needs a clean octave above the cutoff and below Nyquist, and up there no such octave is left. That is lesson 2 turning up again in a place you would not have looked for it.
This is where the famous filters get their names. The Moog ladder is four one-pole stages in series, four times 6, which is the 24 dB/octave that most people hear as the sound of a synthesizer. The Oberheim SEM is two poles, 12 dB/octave, and is noticeably gentler for exactly that reason: at two octaves above cutoff a 12 dB filter has removed 24 dB and a 24 dB filter has removed 48.
Resonance is feedback
Resonance, labelled Q here and often called emphasis, is a bump in the curve right at the cutoff. Physically it is feedback: some of the filter's output is returned to its input, and frequencies near the cutoff arrive back in phase with themselves and reinforce.
Turn it up and two things happen. The bump grows, so the level at cutoff goes positive rather than sitting at −3 dB, and the filter starts to ring: it holds energy near the cutoff for a while after being excited. Sweeping a resonant low-pass over a sawtooth is probably the single most recognisable gesture in electronic music, and this is all it is.
Push the feedback far enough on a real analogue ladder and it stops needing an input at all. It sustains itself and emits a sine wave at the cutoff frequency, which is self-oscillation, and it is why some synthesizers can be played as a crude sine oscillator with the filter alone.
The filter in this page will not do that, and it would be dishonest to imply otherwise. It is a Web Audio biquad, which is a stable digital section: raising Q makes the peak taller and the ringing longer, but the feedback path is not the kind that can run away. Self-oscillation needs a topology that permits it, and usually some nonlinearity to stop the runaway becoming an infinity.
Why low-pass won
Four types are on offer above, and in practice one of them does almost all the work. That is not habit, and there are two decent reasons for it.
The first is that harmonics are ordered by frequency, and loudness generally falls as you go up. A low-pass filter therefore has a single control that decides how many harmonics survive, which maps almost perfectly onto what people perceive as brightness. No other filter type gives you that as one knob.
The second is that the physical world is mostly low-pass. Air absorbs high frequencies faster than low ones, soft materials damp them, distance removes them. A closing low-pass is therefore heard as something moving away, or being covered, or losing energy, which is why the gesture feels like something rather than merely sounding like something.
Where this model stops being the whole story
Everything above assumes the filter is linear: that multiplying the input by two multiplies the output by two, and that the curve is the same curve regardless of how hard you drive it. The biquad in this page really is linear, and that assumption is what lets a single response curve describe it completely.
Real analogue filters are not linear, and a good deal of what people like about them lives in the difference. Transistors saturate, so a loud input is gently compressed and gains harmonics that were not in the source. Resonance interacts with level, so pushing the input changes the shape of the peak. The result cannot be drawn as one curve, because there is a different curve at every amplitude.
That is most of what is meant when digital filters are called sterile, and it is a fair complaint about a naive implementation rather than about digital as such: the nonlinearity can be modelled, it is simply extra work that a textbook biquad does not do.