Skip to content

Carving away harmonics: subtractive synthesis

The first page in this series built sounds up from sine waves, and ran into a wall: a realistic sound needs dozens of sine waves, each changing in its own way, and that’s a great many numbers to set. Subtractive synthesis turns the problem round. Start with a wave that’s already full of harmonics, and carve away the ones you don’t want with a filter. Then change the filter while the note plays, and the sound comes alive with a single knob.

That’s how the classic analogue synthesisers of the 1960s and 70s worked, from Robert Moog’s and Don Buchla’s modular systems (wardrobe-sized cabinets of modules joined by patch cords) to the portable keyboards that followed. Their sound has never gone out of fashion, and most synthesisers today recreate it in software. That turns out to be harder than it looks, and the second half of this page is about why.

It leans on:

  • Adding sine waves, for harmonics, cents and the keyboard. Every figure here is playable in the same way: click the keys, use the computer’s keys (A is C, Z and X change octave), or press Use a MIDI keyboard. With a controller’s knobs, Link knobs links them to any of a figure’s sliders.
  • Designing IIR filters, for filters with feedback, and the bilinear transform.
  • Sampling, for aliasing.

A few terms first:

  • Voltage control. In an analogue synth, every setting is a voltage, so anything can control anything: a key, a knob, or another module. Moog’s standard was 1 volt per octave: add a volt, and the pitch doubles.
  • A patch is one way of connecting the modules and setting them, and, by extension, one of a synth’s sounds.
  • The classic chain is three modules: an oscillator makes the wave (a VCO, voltage-controlled oscillator), a filter shapes it (a VCF), and an amplifier sets its loudness (a VCA).

Simple circuits make a few waves easily, and all of them are rich in harmonics: a sawtooth ramps up and drops; a square wave flips between high and low; a pulse wave is a square with uneven halves; and a triangle ramps up and down.

Top: the wave. Bottom: its harmonics, the 1st (the fundamental) set to 1. Play the keyboard to hear each wave unfiltered.

The sawtooth has every harmonic, each at 1/n of the first, so its 5th is 14.0 dB below the 1st. The square has only the odd ones, at the same 1/n. The triangle’s odd harmonics fall as 1/n², so its 5th is 28.0 dB down: it’s much softer. A pulse loses every harmonic that fits a whole number of times into its high part: at a width of 25%, the 4th, 8th, 12th and so on are missing. Moving the width while a note plays (pulse-width modulation) makes a rich, shifting sound.

The sawtooth is the favourite starting point, since it has everything: bright, buzzy and ready to be carved.

A low-pass filter lets low frequencies through and turns high ones down. Its cutoff is where it starts to bite, and its slope is how steeply it turns down the frequencies above: in decibels per octave. Each simple filter stage (one pole, in the language of IIR filters) adds 6 dB per octave. Moog’s filter has four stages, for 24 dB per octave.

A sawtooth on A2 (110 Hz): its harmonics before the filter (grey) and after it (orange), and the filter’s response (blue). Move the cutoff, change the slope, and play.

At the cutoff, each stage is 3 dB down, so the four-stage filter is 12.0 dB down there, and 28.1 dB down an octave above it. Far above the cutoff, each stage takes away 6 dB per octave. With the cutoff low, only the first few harmonics survive, and the sawtooth’s buzz turns to a dark, round tone; with it high, the sound is bright.

This is already more useful than additive synthesis for one reason: one number, the cutoff, changes the whole recipe of harmonics at once, in a way that sounds natural. Real instruments get duller as they get quieter, and lower notes have fewer audible harmonics. A filter does that for free.

Moog’s filter is called the ladder because of how its circuit looks: four identical stages, one above the other, like the rungs of a ladder. Its trick is feedback: part of the output is sent back, upside down, to the input.

Moog’s ladder is an analogue circuit, built from transistors and capacitors, and it works continuously, not in samples. The figures on this page use a digital copy of it. Copying it faithfully turns out to be surprisingly subtle, and section 7 shows how; until then, take the copy as exact.

in+stage 1stage 2stage 3stage 4out× k, subtracted at the input (the resonance)−

Each stage delays the wave a little, more at higher frequencies. At the cutoff, each stage delays it by an eighth of a cycle (45°), so the four together delay it by half a cycle (180°). Half a cycle late and turned upside down is the same as on time and the right way up. So at the cutoff, the feedback adds to the input instead of cancelling it, and the filter’s response rises into a resonant peak there. Everywhere else the feedback mostly cancels, which is why the bass gets quieter as the resonance goes up.

Top: the filter’s response with feedback k (blue), and with none (grey); the dashed line is the cutoff. Bottom: what comes out after a single tap (an impulse): the filter rings at its peak. Play a note, and sweep the cutoff while it sounds: that’s the classic synthesiser “wow”.

With the cutoff at 894 Hz: at k = 3, the peak stands 15.5 dB above the bass, and a tap rings for 17.9 ms before falling 60 dB. At k = 3.9, the peak is 36.9 dB above the bass, and the ringing lasts 196 ms. At k = 4, the feedback exactly makes up for the four stages’ loss at the cutoff, so the ringing never dies: the filter self-oscillates, singing a sine wave of its own. In the analogue circuit, saturation (section 7) stops it growing for ever; it does here too.

Sweep a strongly resonant filter up and down over a sawtooth and it sounds almost like a voice saying “wow”. That’s because a resonant peak is exactly what a formant is: the resonances of your throat and mouth boost certain frequencies of your vocal cords’ buzz, and moving your tongue and lips slides them around. The voice coding page models speech the same way, as a buzz through resonant filters. It’s also where the wah-wah pedal got its name.

A self-oscillating filter is an oscillator in its own right, and players use it as one. The last figure on this page has a preset where the oscillators are silent and the filter alone plays the tune.

So far the sound switches on and off with the key, like the organ. Real sounds have a shape in time: a pluck starts hard and dies away; a bowed note swells. An envelope generator makes that shape each time a key is pressed, and the classic one has four settings, ADSR:

  • Attack: how long the sound takes to rise to full, from the moment the key goes down.
  • Decay: how long it then takes to fall to the sustain level.
  • Sustain: the level it holds at for as long as the key stays down. (A level, not a time.)
  • Release: how long it takes to fade away after the key comes up.

The envelope’s best trick is to drive the filter’s cutoff as well as the loudness, since real sounds are brightest when they’re loudest.

Top: the envelope, for a key held for 1.2 s (shaded) and then released. Bottom: the same envelope moving the filter’s cutoff, from 250 Hz up by as many octaves as the last slider says. Play the keyboard to hear each one. (In this figure, one envelope drives both the loudness and the filter; the full synth at the end has one for each.)

In this model the attack rises in a straight line; the decay and release fall exponentially, 98% of the way in the time shown, as an analogue envelope’s capacitor does. “Pluck” opens the filter 4 octaves to 4 kHz at the top of its attack, then lets it close as the note dies: the note darkens as it fades, as a plucked string does. “Brass” swells into brightness.

A low-frequency oscillator (LFO) is an oscillator too slow to hear as a note, from a fraction of a hertz to about 20 Hz. Connected to something else, it makes that thing wobble.

What the LFO does to the sound, over 4 seconds. Choose what it moves, its shape, its rate and its depth, and play.

On the pitch, it’s vibrato, as a singer or a violinist uses: a sine at 5 or 6 Hz and 10 to 20 cents sounds natural. On the cutoff, it sweeps the brightness up and down, a “wah”. On the loudness, it’s tremolo. A square wave on the pitch makes a trill between two notes.

Turn an LFO up into the range of hearing, past about 20 Hz, and the wobble stops sounding like a wobble. New tones appear either side of the note instead: sidebands, just as in radio. That effect is the next page’s whole subject: FM synthesis.

A computer copies all this one sample at a time. The obvious way to make a sawtooth is to keep a phase that climbs from 0 to 1 once each cycle and output its shape, 2 × phase − 1: the “naive” sawtooth. It sounds fine on low notes. On high notes it sounds awful, because of aliasing.

A real sawtooth has harmonics going up for ever. A digital system can only hold frequencies below half its sample rate; anything above that folds back below it, as if reflected in a mirror at half the sample rate. A harmonic that should be at 23 kHz arrives at 21.1 kHz, sampling at 44.1 kHz. Folded harmonics aren’t at whole-number multiples of the note any more, so they sound out of tune: a cloud of whistles that, as the note rises, slide down.

There are three ways to make the sawtooth:

  • Naive: the wave’s shape, sample by sample. Every harmonic above half the sample rate folds back.
  • Every harmonic added up: additive synthesis, stopping at half the sample rate, so nothing folds. It’s perfect, but a low note needs hundreds of sine waves.
  • PolyBLEP: the naive wave, with its jump smoothed over the two samples either side by a small polynomial (a band-limited step). The jump is what makes the endless harmonics, so rounding it off at the scale of a sample takes most of them away, for a few multiplications per sample.

The spectrum of each oscillator, sampled at 44.1 kHz. Blue dots mark the real harmonics; orange dots, the first harmonics above 22.05 kHz, where they fold back to. The shaded band, below 5 kHz, is where the ear is most sensitive. This note plays the chosen note; Sweep up plays a sawtooth gliding up from C3 to C8. Listen to the naive one: the whistles sliding down are the aliases.

On C7 (2.09 kHz), only 10 harmonics fit below half the sample rate. The naive sawtooth’s loudest alias is 20.7 dB below the note, and below 5 kHz the loudest is 26.2 dB down: clearly audible. PolyBLEP brings that low alias down to 64.9 dB below the note. Adding up the harmonics leaves nothing but the analysis’s own floor. The triangle’s harmonics fall so fast that even the naive one’s aliases are 51.8 dB down below 5 kHz.

So digital synths use band-limited oscillators of one kind or another: PolyBLEP, its cousins, tables of pre-filtered waves (the subject of a later page in this series), or running at a much higher sample rate inside and filtering down.

Moog’s ladder works in continuous time: each stage is, in effect, a capacitor charging through a transistor, and the voltages change smoothly. A computer has to copy it one sample at a time. This section works through how, a step at a time, because the obvious way goes wrong in an instructive way. It uses the one-pole filter and the bilinear transform from the IIR page.

Each stage is a one-pole low-pass: its output yy chases its input xx, at a speed set by the cutoff fcf_c:

dydt=2πfc (x−y)\frac{dy}{dt} = 2\pi f_c\,(x - y)

For a sine wave at frequency ff, that gives the stage’s response, a complex number whose size is the gain and whose angle is the phase shift:

H(f)=11+j f/fcH(f) = \frac{1}{1 + j\,f/f_c}

At the cutoff, f=fcf = f_c, the bottom is 1+j1 + j: its size is 2\sqrt 2, so the stage passes 1/21/\sqrt 2 of the wave (−3 dB), and its angle is 45°, so the output lags by an eighth of a cycle. Four stages make −12 dB and 180°, which is section 3’s resonance. And at the cutoff the loop loses (1/2)4=1/4(1/\sqrt 2)^4 = 1/4, which is why feedback of exactly k=4k = 4 makes it self-oscillate. Those two facts, −45° and −3 dB per stage at the cutoff, are what a digital copy has to keep.

The obvious copy steps the equation forward a sample at a time (Euler’s method): each sample, move yy a fraction gg of the way towards xx.

y[n]=y[n−1]+g (x[n]−y[n−1]),g=2πfcfsy[n] = y[n-1] + g\,\big(x[n] - y[n-1]\big), \qquad g = \frac{2\pi f_c}{f_s}

That’s the IIR page’s one-pole filter, with a=1−ga = 1 - g. Then there’s the feedback. Stage 1’s input is x−k y4x - k\,y_4, but y4y_4, the fourth stage’s output, isn’t known until all four stages have run, and they need stage 1’s input first. The obvious way out is to use the previous sample’s y4y_4, which puts a one-sample delay in the loop.

Both steps are slightly wrong, and the errors grow with the cutoff:

  • The Euler stage isn’t quite the analogue one. At its cutoff it lags less than 45° and loses less than 3 dB.
  • The one-sample delay adds a lag of its own, 360°×f/fs360° \times f / f_s.

A better stage uses the trapezoidal rule: instead of stepping with the slope at the start of each sample, it averages the slopes at both ends. That’s the bilinear transform, and prewarping (setting gg with a tangent) makes its cutoff land exactly where it should. Each stage keeps one number of memory, ss:

g = tan(pi * fc / fs) # prewarped, so the cutoff lands exactly
G = g / (1 + g)
def stage(x): # s is this stage's memory, kept between samples
v = (x - s) * G
y = v + s
s = y + v # remember, for the next sample
return y

Its response is exactly the analogue one, with the frequency axis squeezed to fit below half the sample rate, and prewarping puts the cutoff at the one point the squeeze leaves alone. So at its cutoff it’s exactly −3 dB and −45°, whatever the cutoff.

One stage of the ladder, three ways, sampled at 48 kHz: the analogue original (dashed), the naive Euler copy (orange) and the bilinear copy (blue). Top: its level; bottom: its phase. Move the cutoff up and watch the naive one drift away.

At a cutoff of 1.00 kHz, the analogue and bilinear stages are both −3.01 dB and −45.0° there; the naive stage is only −2.71 dB and −39.3°. With the one-sample delay, the naive loop lags 164.9° at the cutoff instead of 180°, so the feedback only adds up at a higher frequency: that’s why the naive filter’s peak goes sharp. At 4 kHz, the naive stage lags only 22.1°, and the whole loop 118.3°.

The bilinear stages fix the first error. The loop still has the second: stage 1 needs y4y_4 now. The way round it is to notice, from the code, that each stage’s output is a known multiple of its input, plus a number that comes only from its memory:

y=(x−s) G+s=G x+s1+gy = (x - s)\,G + s = G\,x + \frac{s}{1+g}

(since 1−G=1/(1+g)1 - G = 1/(1+g)). Chain four of them, with uu the first stage’s input, and the same is true of the whole ladder:

y4=G4 u+S,S=G3s1+G2s2+G s3+s41+gy_4 = G^4\,u + S, \qquad S = \frac{G^3 s_1 + G^2 s_2 + G\,s_3 + s_4}{1 + g}

SS depends only on the four memories, so it’s known before the sample starts. The feedback says u=x−k y4u = x - k\,y_4. Put that in, and there’s one equation with one unknown:

y4=G4 (x−k y4)+S⟹y4=G4 x+S1+k G4y_4 = G^4\,(x - k\,y_4) + S \qquad\Longrightarrow\qquad y_4 = \frac{G^4\,x + S}{1 + k\,G^4}

So each sample: work out SS; solve for y4y_4; set u=x−k y4u = x - k\,y_4; run the four stages on uu, which updates their memories. The feedback has used this sample’s output, with no delay: zero-delay feedback (ZDF). Since every part of the loop is now the analogue one seen through the bilinear transform, the loop’s −180° and its loss of 1/4 land exactly at the cutoff, so it self-oscillates exactly there, at exactly k=4k = 4, at every cutoff. This is how good virtual-analogue filters are built, and it’s what this page’s figures have used all along. Vadim Zavalishin’s book (in the further reading) develops the method in full.

Top: the response, with zero-delay feedback (blue) and done naively (orange), for the cutoff and resonance chosen. Bottom: for every cutoff from 50 Hz to 16 kHz, where each one self-oscillates; the dashed diagonal is where it should. The buttons play a sawtooth with the cutoff sweeping from 200 Hz to 12 kHz, at k = 3.6, both ways. Sampled at 48 kHz.

With zero-delay feedback, the filter self-oscillates exactly at its cutoff, at exactly k = 4, at every cutoff. With k = 3.5, its peak is 22.3 dB above the bass, whatever the cutoff. The naive filter’s peak drifts sharp, and shrinks as the cutoff rises: at a cutoff of 1.26 kHz it peaks at 1.38 kHz (156 cents sharp) and only 15.1 dB high. To self-oscillate with a 1 kHz cutoff, it needs k = 4.63, and sings at 1.15 kHz; with a 4 kHz cutoff, it needs k = 9.60, and sings at 8.89 kHz. With the cutoff above about 5.1 kHz, it can’t self-oscillate at all. In the sweep, the naive filter’s resonance fades out as it climbs.

There’s one more ingredient in the analogue sound. The ladder’s transistors don’t respond in a straight line: a loud signal is squashed (saturation, close to the tanh curve). That rounds off the filter’s peaks, keeps self-oscillation from growing for ever, and makes the resonance get relatively quieter as you play harder, which players hear as warmth. Saturation inside the loop breaks the neat one-equation solution above (the equation stops being linear), so careful designs solve it iteratively, or with clever approximations. This page’s filter takes a simple shortcut: it solves the loop as if it were linear, then saturates the input to the first stage. That’s the drive control in the next figure. Saturation makes new harmonics, which can alias in turn (see Exploring harmonics); careful designs run the filter at a higher sample rate to keep them in check.

Here’s everything on this page in one instrument: two oscillators, the ladder filter with its own envelope, a loudness envelope, an LFO, glide between notes, and switches for the digital methods. It plays up to eight notes at once.

Oscillators
Filter
Filter envelope
Loudness envelope
LFO
Digital

The scope (top) and spectrum (bottom) show the synth’s own output as you play. Start from a preset and change anything. When you find a sound you like, name it and save it in this browser (it joins the preset list), or keep it elsewhere: copy as code gives a line of text to paste back in later, copy a link opens this page with the sound loaded (handy for sharing), and download file saves it as a small file. The last controls switch the oscillators to naive (try a high note) and the filter to the naive one (try sweeping the cutoff with the resonance up).

A few things to try:

  • Fat bass: two sawtooths 7 cents apart. Their beating, as on the first page, makes the sound thick.
  • The filter alone, singing: the oscillators are off, and the resonance is above 4, so the filter self-oscillates; with Key follow at 100%, its cutoff follows the keys, so it plays in tune.
  • Lead: with Glide, notes slide into each other; play legato (the next key before letting go of the last).
  • With a MIDI keyboard, Velocity sets how much harder playing makes it louder.

What subtractive synthesis can’t do easily is the sound of things that ring: bells, metal, glass. Their partials aren’t harmonics at all, and no filter can carve inharmonic partials out of a sawtooth. The next page gets them a different way, by modulating one oscillator with another at audio rates: FM synthesis.

  • Subtractive synthesis starts with a wave rich in harmonics and removes some with a filter. A sawtooth has every harmonic at 1/n; a square only the odd ones; a pulse loses those that fit its width; a triangle’s fall as 1/n².
  • A low-pass filter of four stages falls 24 dB per octave above its cutoff; it’s 12 dB down at the cutoff itself.
  • Resonance is feedback around the filter: at the cutoff the four stages’ 180° turns it from cancelling into adding. At k = 4 the filter self-oscillates.
  • Envelopes (ADSR) shape each note’s loudness and, more importantly, its brightness; LFOs add vibrato, sweeps and tremolo.
  • A naive digital sawtooth aliases: on C7, its loudest alias below 5 kHz is 26.2 dB below the note. PolyBLEP smooths each jump and brings it to 64.9 dB down.
  • A naive digital ladder filter, with a one-sample delay in its feedback, goes sharp and loses its resonance as the cutoff rises. Zero-delay feedback solves the loop each sample, and self-oscillates exactly at the cutoff, at k = 4.
  • Robert A. Moog, “A voltage-controlled low-pass high-pass filter for audio signal processing”, Audio Engineering Society 17th Convention, 1965; and US patent 3,475,623 (1969): the ladder filter.
  • Tim Stilson and Julius O. Smith, “Analyzing the Moog VCF with considerations for digital implementation”, and “Alias-free digital synthesis of classic analog waveforms”, both Proceedings of the International Computer Music Conference, 1996.
  • Antti Huovilainen, “Non-linear digital implementation of the Moog ladder filter”, Proceedings of the 7th International Conference on Digital Audio Effects (DAFx-04), 2004.
  • Vesa Välimäki and Antti Huovilainen, “Antialiasing oscillators in subtractive synthesis”, IEEE Signal Processing Magazine 24(2), 2007: PolyBLEP and its relatives.
  • Vadim Zavalishin, The Art of VA Filter Design (Native Instruments, revised 2018, free online): zero-delay-feedback filters, from first principles.
  • Curtis Roads, The Computer Music Tutorial (MIT Press, 2nd edition 2023), on subtractive synthesis.