SynthMaker Manual Open SynthMaker (opens in a new tab)
Signal processing · Chapter 1

Write your own filter, and watch what it does

One line of maths is a low-pass filter. The figures on this page run that line in your browser: they show what it does to every frequency and to a single click, and they change as you turn its knob. Press Play it to hear the same filter on a bass line.

1One line

Every sample, the output y moves a share a of the way from where it was, y', towards the input x:

OnePole · its code
module OnePole  in x  out y  setting a: 0.08, from 0.005 to 1  y = y' + a * (x - y')end

A fast wiggle in x is gone before y has moved far, and a slow one is followed almost exactly. Slow passes, fast doesn't: that's a low-pass filter.

Open in SynthMaker ↗ (opens in a new tab) Turn a and watch both views.
Figure 1.1 The one-line low-pass, running. Response is its gain at every frequency: 0 dB at the bottom, falling above a corner that moves up as a grows. Impulse is what one click becomes: a, then a(1 − a), then a(1 − a)², each sample a little less. A bigger a starts higher and dies away sooner, so more of the highs get through.

2Why the click tells you everything

Send in one click, a single 1 and then silence. The first output is a. After that the input is 0, so each sample keeps 1 − a of the one before: a fade that never quite ends. That fade is the filter's impulse response.

Any sound is a row of clicks of different sizes, so the filter's output is its impulse response added up for each one. The Response view is worked out from the impulse response itself (SynthMaker plays the module one click and measures it), so what you see is what you hear.

3Four in a row, and feedback

Put four of the same line in a row and you get a steeper low-pass. Now take the last output, one sample ago, and subtract a share of it from the input, feedback * y':

Ladder · its code
module Ladder  in x  out y  setting a: 0.1, from 0.005 to 1  setting feedback: 0, from 0 to 4.4  s1 = s1' + a * (x - feedback * y' - s1')  s2 = s2' + a * (s1 - s2')  s3 = s3' + a * (s2 - s3')  y = y' + a * (s3 - y')end

Each stage lags a little behind its input, and at one frequency the four lags add up to half a cycle: there the part fed back is upside down, so subtracting it adds to it. Turn feedback up and that frequency grows a peak.

Open in SynthMaker ↗ (opens in a new tab) Turn feedback slowly up to the top.
Figure 1.2 Four one-poles in a row, the last fed back into the first. As feedback goes up, two of the four poles slide out towards the unit circle, the Response grows a peak near 800 Hz, and the Impulse rings: one click becomes a short tone. At the top of the knob the poles are just inside the circle, and the filter rings for a long time.

Try it

  1. In figure 1.1, turn a right down: the corner drops below 200 Hz and the click becomes a slow fade.
  2. In figure 1.2, play it and turn feedback up while the bass line plays: the filter starts to sing.
  3. Open either in SynthMaker, open the filter's code, and change a line: play it and hear what your change does.

Remember