♪Music, Built

Act IX · Electric Sound

Part 51 of 68

Synthesis I: Oscillators and Filters

Foundationsstarts at this level47 min of film13 chaptersprerequisites: Part 3, Part 8, Part 48, Part 49, Part 50

How does a synthesizer make a sound from nothing, and how is its analogue circuit run inside a computer?

The first synthesizer weighed nearly two hundred tons: Cahill's Telharmonium (1906) summed dynamos' near-sines and sent them down telephone lines; Moog's modules (1964) and Switched-On Bach (1968) did the job by subtraction. An ear question hears forty hand-set sines against a two-oscillator patch a search fitted to them (3.0 dB away, missing a bump a low-pass cannot make). A sawtooth is built from sines; the Hammond's nine drawbars borrow tempered wheels (fifths 2.0 cents flat, the third 13.7 sharp); four sources and a filter sweep follow. A naive digital sawtooth aliases (25.6 dB at 110 Hz to 10.3 at 3.5 kHz, 3 dB worse an octave); PolyBLEP cuts it by 14 to 16 dB (an ear question), BLIT sits near 64. The ladder is four poles and a loop, 1/((1+s)^4+k), ringing at k = 4 and losing bass as 1/(1+k); run against its circuit equations, forward steps converge at 6 dB per doubling and the trapezoid with Newton at 12 (37.2 dB at 48 kHz); an ear question hears the saturating circuit against its linear equations, and past k = 4 the filter sings the Tune. Envelopes, LFOs, pulse width, hard sync and unison move one note; wavetables scan eight cycles (aliasing 18 dB naive, 56 band-limited); struck resonators make an 808-style kit (decay 0.454 s against 0.453 predicted); a grid search fits patches, recovers a hidden one, and fails on an organ (27 dB).

What you need. Part 3 for Fourier series; Part 6 for equal temperament; Part 8 for source and filter; Part 40 for the 808; Part 48 for aliasing; Part 49 for poles and filters. Laplace transforms, ordinary differential equations, Newton's method, Runge-Kutta.

Ideas, mathematics and history
the Telharmonium, additive and subtractive synthesis, alias-free oscillators, the Moog ladder, envelopes and modulation, wavetables
What we build, compute and hear
an analog-modelled voice; the Tune switched on

What you will be able to do

Foundations

  • Hear a fitted patch against its target, three Hammond registrations, and a filter sweep with and without resonance.
  • Hear a naive sawtooth alias against PolyBLEP, the ladder at three resonances, and its circuit against its equations.
  • Hear three envelopes on one patch, vibrato, tremolo and a wobble, pulse-width modulation, hard sync and unison.

Full course

  • Build naive, PolyBLEP, BLIT and additive sawtooths, and measure each one's aliasing against pitch.
  • Derive the ladder's response and its k = 4 edge; step its circuit forward and by the trapezoid with Newton.
  • Build envelopes, wavetables, struck-resonator drums, and a grid search that fits a patch to harmonic levels.

Research

  • Decide whether gradient descent through a differentiable ladder fits real notes as reliably as a search.

Practice

  • Choose an oscillator algorithm, a filter solver and a sample rate for a plug-in, and a patch for a sound.

Contents

Each chapter has a home level. Choose a track to see what to read and watch: Foundations 28 min · Full course 44 min · Research 47 min · Practice 44 min.

  1. 0Two hundred tonsFoundations3 min
  2. 1Additive synthesis: dynamos and drawbarsFoundations4 min
  3. 2Subtractive synthesisFoundations3 min
  4. 3Why digital sawtooths aliasFoundations5 min
  5. 4The ladder filterFoundations4 min
  6. 5Running the circuitPractice4 min
  7. 6Envelopes and modulationFoundations3 min
  8. 7Pulse width, sync and unisonFoundations4 min
  9. 8WavetablesPractice3 min
  10. 9Drum circuitsPractice4 min
  11. 10Fitting a patchPractice5 min
  12. 11Frontier: sound matching and differentiable synthesizersResearch3 min
  13. Variation 51, recap and problemsAll tracks3 min

Also on this page: Lecture · Key results · Try it · Lab · Problems · Notes and sources · Build the film.

Lecture

The text of each chapter is the film's narration, as it is spoken, so you can read along or revise without the film. The pictures are in the film. A dashed box stands for a number the film computes when it is rendered (hover over it to see what is computed); the README's figures for each chapter, where it lists them, follow the chapter's text.

Two hundred tonsFoundations3 min

In 1906 an instrument weighing nearly two hundred tons began to play in New York. First, something lighter. The Tune's first phrase, twice. One tone was built by hand from forty sine waves, each set to its own level. The other is a two-oscillator synthesizer patch that a computer search set to imitate it. Which is the original?

The second was the original. Here are the two, harmonic by harmonic, in decibels below the loudest. The original's forty sines, set by hand: falling as one over the harmonic number, with a broad bump near eleven hundred hertz. The patch: one sawtooth through a filter with cutoff near hertz and a little resonance, found by trying settings. It lands within decibels on average. Where it misses is the bump: a low-pass filter cannot lift the third, fourth and fifth harmonics without lifting what lies below them too. Two knobs and a waveform came within a few decibels of forty hand-set sines. That economy is the idea of this part.

One early large-scale electrical instrument weighed nearly two hundred tons; it was not the first device to generate tones electrically. In 1897 Thaddeus Cahill patented a way to make music from electricity and send it down wires. In 1906 his Telharmonium began to play in New York: dynamos, one for each pitch, nearly two hundred tons of them, filling a floor. Each dynamo made something close to a sine wave, and a note's colour was a sum of them: additive synthesis, at industrial scale. Subscribers heard it through the telephone, and it bled into other people's calls. By 1914 the company had failed, and no recording of it survives.

Sixty years later a module did the job. In 1964 Robert Moog showed voltage-controlled modules: an oscillator, a filter and an amplifier, with patch cords between them. The trick was subtraction: start from a wave full of harmonics, and filter most of them away. In 1968 Wendy Carlos released Switched-On Bach, every line of Bach played separately on a monophonic Moog and layered on tape. It became one of the best-selling classical records ever made, with over a million copies. What the Telharmonium did with tons, a filter did with a handful of transistors.

Here is the plan. Additive synthesis, from dynamos to the Hammond organ's drawbars. Subtractive synthesis, and why a digital sawtooth aliases. The ladder filter, and how to run its circuit on a computer. Envelopes, modulation, pulse width, sync and unison. Wavetables and drum circuits. And fitting a patch to a sound, by search and by learning.

1Additive synthesis: dynamos and drawbarsFoundations4 min

Can any tone be built from sine waves?

Start with the oldest idea. A sine wave at the note's frequency, then one at twice it, at half the strength, then three times it at a third, five harmonics, ten, forty. The sum leans and sharpens into a sawtooth: a ramp up and a sudden drop. The ripples at the drop never quite go away; that is Gibbs's overshoot, nine per cent of the jump however many sines you add.

Fourier's theorem says this always works. Any periodic wave is a sum of sines at whole multiples of its frequency, as Part 3 showed. So a steady tone is a list of numbers: the level, and the phase, of each harmonic. For resolved harmonics in suitable steady tones, phase often has less influence than harmonic levels; phase can matter for unresolved components and waveform envelopes, as the same part found: the levels are the colour. Additive synthesis turns the list back into sound, one sine for each number. And the same list is what the hook's search was matching.

In 1935 Laurens Hammond put the Telharmonium in a cabinet. A classic ninety-one-tone generator uses multiple geared shafts carrying steel tonewheels, each beside a magnetic pickup, and a wheel's bumps make a near-sine at its pitch. Nine drawbars mix them, each a harmonic, each in nine steps from silent to full. The names are organ-pipe lengths in feet: sixteen feet sounds an octave below the key, eight feet the key itself, four feet an octave up, and the odd ones, five and a third, two and two thirds, one and three fifths, one and a third, are the fifths and the third between.

Three registrations on a computed Hammond, each playing the Tune's first phrase. The eight-foot drawbar alone, a pure flute. Then eight, eight, eight and the rest in: the first three drawbars full, the setting the jazz organist Jimmy Smith made famous. Then every drawbar out.

The flute is hollow and soft; the three full drawbars add the octave below and the fifth, and the sound turns round and heavy; all nine out is bright and loud, the organ's full chorus. Nine numbers, nine colours each: nearly three hundred and ninety million registrations, all additive.

One economy hides in the Hammond's harmonics. Ninety-one wheels must serve every key, so there is no wheel at the true third harmonic of each note. Each drawbar borrows the wheel of the nearest note of the equal-tempered scale. The fifths come out cents flat, a small offset whose audibility depends on the listening context; but the major third, the fifth harmonic, is cents sharp, Part 6's tempered third. It beats slowly against the true harmonics of anything else in the room, and that slow shimmer is part of the Hammond's sound.

Additive synthesis has a price. Real tones change: each harmonic of a piano or a trumpet rises and dies on its own schedule, as Parts 7 and 8 measured. In the 1960s Jean-Claude Risset at Bell Labs resynthesized trumpet notes from measured envelopes of their harmonics, and they sounded like trumpets. So additive synthesis needs a sine and an envelope for every harmonic: dozens of curves for one note. Instruments that tried it, the Synclavier and Kawai's K5, asked players to draw them all. The cheaper road starts with every harmonic at once, and takes away.

2Subtractive synthesisFoundations3 min

Why start with too much?

Subtractive synthesis runs the other way. Start with an oscillator whose wave already has every harmonic in it. Shape the spectrum with a filter, where one knob, the cutoff, moves the brightness of all of them at once. Then shape the loudness with an amplifier whose gain follows an envelope. Oscillator, filter, amplifier: the same chain as the human voice, a buzzing source and then a filter, as Part 8 built. A handful of controls, instead of a curve for every harmonic.

Analogue synthesizers offer a few sources, each a different list of harmonics. The sawtooth has every harmonic, falling as one over k: the richest, brassy and string-like. The square has only the odd ones, at the same rate: hollow, like the clarinet of Part 8. The triangle has odd harmonics too, but falling as one over k squared, twelve decibels an octave: nearly a flute. And a pulse a quarter of a cycle wide loses every fourth harmonic; its width is a knob, and chapter seven turns it.

Moog's word for the modules was voltage-controlled. A voltage-controlled oscillator, filter and amplifier: pitch, colour and loudness. Every knob could also be turned by a voltage from another module. The keyboard sends one volt for each octave, so a circuit that turns volts into frequency exponentially makes the keys equal-tempered. An envelope generator, triggered by each key, turns the filter and the amplifier. And a slow oscillator, an LFO, can turn anything at all. That one idea, that knobs are inputs, is the whole grammar of the synthesizer.

Here is the gesture subtractive synthesis is known for. A sawtooth at a hundred and ten hertz, held, while the filter's cutoff opens from a hundred and fifty hertz to six kilohertz and closes again. First without resonance; then with the filter's feedback turned up, which puts a peak at the cutoff that sings each harmonic as it passes.

Without resonance the sound simply brightens and darkens, like a mouth opening. With it, the peak picks out one harmonic after another, a whistle running up the series and back: you can see it in the spectrogram as the bright ridge along the cutoff, crossing each harmonic in turn.

The chain became an instrument in stages. First as modular systems, Moog's and, on the West Coast, Don Buchla's: separate modules with cords between them. Buchla preferred to shape a wave from a simple one by folding it back on itself; subtraction was never the only way. In 1970 the Minimoog fixed the chain inside a portable case: three oscillators, the ladder filter, two envelopes. In 1978 the Prophet-5, with five voices, remembered the setting of every knob: one of the first synthesizers with patch memory. And the knobs became a standard so durable that software still draws them.

3Why digital sawtooths aliasFoundations5 min

What goes wrong when a computer draws a ramp?

Now take the synthesizer into a computer. The obvious digital sawtooth adds the frequency over the sample rate to a phase every sample, wraps it at one, and outputs twice the phase minus one. But its drop happens between two samples, at a moment the samples cannot place. An instant drop has harmonics without end, and every one above half the sample rate folds back, as Part 48 showed. They land between the true harmonics, unrelated to the note: inharmonic, and when the note rises, some of them fall. An analogue oscillator never had this problem; its circuit is band-limited by nature.

Here is one high note, D seven at hertz, sampled at forty-eight kilohertz. Only ten of its harmonics fit below the twenty-four kilohertz limit; they are the white marks. The naive sawtooth's spectrum is a forest: much of the off-grid energy comes from folded harmonics, with finite-window leakage also relevant to this metric, some as loud as the real ones high up, scattered down to the bass. The same note from a band-limited oscillator, PolyBLEP, which we are about to build: the same ten harmonics, and the forest cut far back.

Measure it across six octaves: the share of each note's energy that lies off its harmonics. The naive sawtooth: decibels down at a hundred and ten hertz, and only at thirty-five hundred, three decibels worse for every octave, as a trend for these tested waveforms and frequencies, rather than an exact law for every note. PolyBLEP is to decibels better everywhere, at A four. Run it at twice the rate and filter, and you gain another to . BLIT, an older method, sits flat near decibels. And adding sines below the limit, one by one, is exact to the arithmetic, at the cost of a sine for every harmonic.

How does PolyBLEP do it? Here is a sawtooth at a twelfth of the sample rate, twelve samples a cycle, as the naive method draws it. The trouble is concentrated at the jumps. A band-limited step, a BLEP, is what an ideal step looks like after the anti-aliasing filter: a smooth rise with small ripples. Eli Brandt's method of 2001 stores that shape and pastes it in at every jump. Vesa Välimäki and Antti Huovilainen's polynomial version approximates it with two pieces of parabola, one sample either side, computed from where between the samples the jump really fell. Only the two samples beside each jump change; the rest of the ramp is untouched. It costs a few multiplications a jump.

Your turn. The Tune's first phrase, two octaves above middle C, on a raw sawtooth with no filter, twice. One oscillator is naive, one is PolyBLEP. Which one aliases? Listen for faint tones that do not belong to the note.

The first was naive. Its high notes carry a faint, gritty halo, tones that slide against the melody; on the second they are cut back by about decibels, below where most ears catch them in a phrase like this. On a single held note, with headphones, you may still hear the second's.

The cures came in order. In 1996 Tim Stilson and Julius Smith integrated a band-limited impulse train, a BLIT, into a ramp. In 2001 Eli Brandt pasted a stored band-limited step at every jump, which also makes hard sync clean, as chapter seven needs. In 2006 and 2007 Välimäki and Huovilainen reduced the step to two parabolas: cheap, and good enough. Wavetables built separately for each octave store only the harmonics that fit, as chapter eight shows. And a modern software synthesizer mixes these with a little oversampling.

4The ladder filterFoundations4 min

What made the Moog sound like a Moog?

The filter that made the Moog sound like a Moog is a ladder. Robert Moog's patent, filed in 1966, stacks pairs of transistors like the rungs of a ladder, and each rung, with a capacitor, is a one-pole low-pass: it falls six decibels an octave above its cutoff. Four in a row fall twenty-four. And the output is fed back to the input, inverted and multiplied by k: the resonance knob.

At low levels the circuit is linear, and the algebra takes three lines. One rung is one over one plus s over omega c. Four in a row, with k times the output subtracted at the input: Y equals G to the fourth times X minus k Y. Solve for Y over X: one over one plus s over omega c, to the fourth, plus k. Everything about the filter's shape is in that denominator.

Draw it for a cutoff of one kilohertz. With no feedback, the response is flat below the cutoff, twelve decibels down at it, and falling twenty-four decibels an octave above. Turn k up to one, two, three: a hump grows at the cutoff. At three point eight it is a peak decibels high, a narrow band that rings. And look at the left end of the curves: as the peak rises, the bass falls.

Why does it ring? At the cutoff frequency, each rung's factor is one plus j: a gain of one over root two and a phase lag of forty-five degrees. Four rungs lag a hundred and eighty degrees, and one plus j to the fourth is exactly minus four. So the denominator at the cutoff is k minus four. At k equals four the ideal linear model is marginally stable at its cutoff; perturbations can sustain ringing. In the nonlinear circuit, sufficient feedback and a perturbation can start oscillation, with saturation limiting its amplitude. Moog's players found this edge and used it, as we will in the next chapter.

The bass loss is in the denominator too. At zero frequency every rung passes everything, and H of zero is one over one plus k. At k equals three the bass is a quarter of its amplitude, decibels down. Players heard it as the resonance thinning the sound, and later designs add a little of the input back to keep the bass.

Hear it on a bass line: the Tune's first phrase two octaves below middle C, through the ladder at five hundred hertz, opened by a pluck envelope on every note. Feedback zero, two, and three point seven.

At zero it is round and plain. At two each note gains a vowel, a wah as the envelope sweeps the hump through the harmonics. At three point seven every note chirps, the filter ringing at the cutoff as it falls, and the bass underneath has thinned: the classic acid squelch, and the price of it.

5Running the circuitPractice4 min

How do you put a transistor ladder inside a computer?

The linear algebra is only the quiet half of the story. A transistor pair passes current as the hyperbolic tangent of the voltage across it: linear when quiet, saturating when loud. So the ladder is four capacitors, each charged through a tanh. These are the equations of Antti Huovilainen's 2004 model, derived from the circuit. Turn the input up, and the filter itself distorts, softly, in its own way.

A computer must step these equations from sample to sample, and there are better and worse ways. First a reference: the fourth-order Runge-Kutta method with sixteen small steps per sample, slow and very nearly exact. Then forward steps: each capacitor moves by its current slope, with the feedback taken from the last sample's output. Huovilainen's correction averages the last two outputs in the loop, cancelling half a sample of delay. And the trapezoidal rule with Newton's method solves for the new voltages and the feedback together, at every sample. Vadim Zavalishin called this zero-delay feedback: the loop has no sample of delay in it.

Here they are against the reference, driven hard with plenty of resonance, at one, two, four and eight times forty-eight kilohertz. Forward steps are only decibels from the oversampled numerical reference at the normal rate, and gain six decibels for each doubling: a first-order method. The half-sample correction starts decibels lower and keeps the same slope. The trapezoid with Newton starts at and gains twelve decibels a doubling, second order: at the normal rate it is already better than forward steps at eight times the rate. Each of its samples costs about times as much on this computer: far less than eight times the samples.

Your turn. The Tune's first phrase on a sawtooth driven hard into the ladder, twice, at the same loudness. One run uses the circuit's equations with every tanh removed, a filter linear in its audio input for a fixed cutoff trajectory; the other, the full circuit. Which is the circuit?

The second. A linear filter does not care how hard it is driven: it simply rings, a sharp, whistling resonance on every note. The circuit cannot do that. Its transistors saturate, so the resonance is tamed and the tone thickens and rounds off: the Moog's warmth is partly this.

The harmonics show it. In the linear filter, the fourth harmonic, at eight hundred and eighty hertz, right on the resonant peak, comes out decibels above the fundamental: the whistle. In the circuit the saturating rungs refuse to build that peak, and the fourth harmonic sits decibels below it. The resonance is felt, not shouted.

Now push k past four. With no input but one tiny click, the filter starts to oscillate and does not stop: the tanh in each rung holds the swing at a steady level, as a real circuit's saturation does. It oscillates close to the cutoff, within about twenty cents at each of three settings: a filter that has become a nearly pure sine oscillator.

So play a tune on it. No oscillator at all: the ladder alone, oscillating, its cutoff stepped through the Tune's first phrase.

A pure, slightly hollow whistle, gliding a little as each change of cutoff settles: the sound players called the filter singing. Chapter nine strikes the same filter instead of letting it run, and gets a drum.

6Envelopes and modulationFoundations3 min

How does a held voltage become a note?

A keyboard only says when a key goes down and when it comes up. The envelope generator turns that into a shape. When the key goes down, the voltage rises, the attack, then falls, the decay, to a level that is held as long as the key is, the sustain, and when the key comes up it falls away, the release. Three times and one level: the composer Vladimir Ussachevsky asked Moog for these four in the 1960s, and nearly every synthesizer since has them.

Three settings make three instruments. A pluck: a two-millisecond attack, no sustain, a decay of a third of a second. Brass: a quick swell, then a held level. A pad: more than half a second to rise and a second to fade. Each envelope moves the amplifier, and a copy opens the filter, here by three octaves at its peak, so that every note brightens as it begins, as a real instrument's does.

Hear one patch with only the envelopes changed: the Tune's first phrase as a pluck, as brass, and as a pad.

The pluck is a bass or a harpsichord-like stab, every note bright for an instant and dying. The brass swells into each note and holds it. The pad blurs the notes into one another, each still rising while the next begins. Same oscillator, same filter: time alone made three instruments.

The other source of movement is a low-frequency oscillator, an LFO: a wave too slow to hear as pitch, wired to a knob. Wired to the oscillator's pitch, five and a half times a second, thirty cents each way, it is vibrato, Part 43's singer's wobble. Wired to the amplifier, it is tremolo. Wired to the filter's cutoff with some resonance, three times a second across four octaves, it is the wobble of a dubstep bass.

One held note, modulated three ways: vibrato, tremolo, and the wobble, an octave lower.

Vibrato warms the tone without changing its colour. Tremolo pulses it, like a rotating speaker's nearer horn. The wobble talks: the resonant cutoff sweeping up and down the harmonics sounds like a mouth saying wow, wow, wow.

In a modular system any source can turn any knob. Sources: envelopes, LFOs, the number of the key, how hard it was struck, a wheel under the player's hand, even another oscillator. Destinations: pitch, cutoff, resonance, level, pulse width, another module's rate. Two routings are nearly always made. Keyboard tracking lets the cutoff follow the note, so high notes are not dull; and velocity to cutoff makes a key struck harder sound brighter, as a piano does. And an oscillator at audio rate turning another's pitch is frequency modulation, which is Part 52.

7Pulse width, sync and unisonFoundations4 min

How do you make one oscillator move?

A pulse wave is high for a fraction w of each cycle, low for the rest. At half, it is the square: odd harmonics only. At a quarter, every fourth harmonic vanishes; at a tenth, every tenth, and the sound turns thin and nasal. The rule is one line: the k-th harmonic's size goes as the sine of pi k w, over k, which is zero wherever k times w is a whole number. Move w slowly with an LFO and the zeros sweep through the harmonics: pulse-width modulation.

Hard sync ties two oscillators together. The master runs at the note. The slave runs at its own frequency, but every time the master starts a cycle, the slave is forced to start one too. At one and a half times the master, the slave gets through one ramp and half of another before it is cut short; at two and a half, two and a half; at three point seven, nearly four. The result always repeats at the master's rate, so the pitch stays put, while the shape, and so the harmonics, change as the slave's frequency moves: a tearing, vocal sweep. Each restart is a jump, so a clean digital sync needs Brandt's band-limited steps; here we run four times the rate and filter.

Hear both on one held C. First the pulse width swinging from a half to eight per cent and back; then hard sync, the slave sweeping from one to five times the master and back.

Pulse-width modulation gives a slow, chorus-like movement, the zeros sweeping through the spectrum, with a reedy nasal tone at the narrow end. Sync is harsher: a resonant, tearing sweep, like a filter but brighter, the sound of a thousand synth leads.

The last trick is to use many oscillators on one note, slightly detuned: unison. One sawtooth has one line at each harmonic; here is its eighth, near a kilohertz. Seven sawtooths spread over thirty-six cents put seven lines there, over hertz, and they beat against each other, with a changing beating pattern; fixed-frequency components do not guarantee mathematical nonrepetition. The spread in hertz grows with the harmonic, so the top of the spectrum shimmers most: the same thickening that sixteen violins give in Part 41, made by arithmetic.

A C major chord on one sawtooth a note, then on seven. The single sawtooths are clear and a little buzzy, every note exact. The seven-voice chord is wide and moving, a wash. Roland's JP-8000 of 1996 offered exactly this, seven sawtooths a note, as its supersaw, and trance music built itself on it.

Unison began as a flaw. An analogue oscillator drifts; its pitch wanders by cents as it warms. Two of them never quite agree, so detuned multiple-oscillator patches can have beating. Some designers deliberately added detuning and drift to digital patches to imitate this texture, so designers added the drift back on purpose. Virtual analogue was the 1990s' name for imitating the circuits, flaws and all. What to imitate, and what to improve, is still a matter of taste.

8WavetablesPractice3 min

What if the oscillator could hold any shape?

A digital oscillator need not imitate a circuit at all. An analogue oscillator offers a few shapes; a memory can hold any shape. Store one cycle as two thousand and forty-eight numbers, and read it round and round at the note's rate. Store many cycles in a row, and let a knob choose where to read: that is a wavetable. Wolfgang Palm's PPG Wave of 1981 scanned through sixty-four cycles under an envelope's control. A moving position is a moving spectrum, without any filter.

Here is our table: eight stored cycles. At the front, position zero, a sine. Moving back, odd harmonics grow in, then the even ones, until the last cycle has forty-eight harmonics, nearly a sawtooth. Between two stored cycles the oscillator cross-fades, so the position can move smoothly.

Hear one held C3 while the position moves from the sine to the brightest cycle and back.

The tone opens like a filter sweep, but differently: no resonant whistle, and the order in which harmonics arrive is whatever the tables say. Odd harmonics came first here, so the middle of the scan sounded hollow, like a clarinet, before the even ones filled it in.

The spectra at three positions. At zero, one harmonic. Halfway, the odd harmonics are strong, the third at decibels, and the even ones faint, near : the hollow middle you heard. At one, every harmonic, falling smoothly.

Wavetables meet chapter three's problem again. The brightest cycle has forty-eight harmonics. Play it at C six, hertz, and the forty-eighth would be at kilohertz, far past the limit. Read naively, the folded harmonics are only decibels below the note. Keep only the harmonics below twenty kilohertz for that octave, and the aliasing falls to . So a wavetable synthesizer stores each table several times, with fewer harmonics for each octave up, the same trick as the mipmaps of computer graphics. It costs memory, not arithmetic.

Wavetables never went away. PPG and then Waldorf built them in the 1980s; in software they are drawn, imported from recordings, or computed. One cycle cut from a voice or an instrument becomes a table, sampling's cousin, which is Part 52. The table position is one more knob for envelopes and LFOs to turn, with the same filter, envelopes and unison behind it. And the frontier asks the inverse question: which settings make a given sound?

9Drum circuitsPractice4 min

How does a circuit make a drum?

Part 40 played the 808's drums as finished sounds. Here is how a circuit makes one. Take a resonator: two poles just inside the unit circle, as Part 49 drew them. Struck once, it rings at its frequency and dies away. Its Q sets how long: the time to fall by a factor of e is two Q over two pi f. A drum machine's voices are resonators like this, struck by a trigger pulse a millisecond long; the 808's kick is a bridged-T network, a resonant filter set just short of oscillating.

The kick: a resonator at hertz with a Q of . The formula predicts a decay time of seconds, and the computed kick's envelope measures . One detail makes it a kick and not a bass note. While the trigger pulse lasts, it pulls the circuit's resonance up, here by sixty per cent, relaxing with an approximately twenty-millisecond time constant. Measured cycle by cycle the first periods run at , , and hertz: a falling chirp that the ear hears as the beater's thump.

The rest of the kit is built the same way. The snare: two resonators, at a hundred and eighty and three hundred and thirty hertz with low Q, for the shell, plus high-passed noise with its own short envelope for the wires; the 808 calls that level snappy. The clap: three bursts of noise ten milliseconds apart, then a tail, so that it sounds like several hands not quite together. And the hats: Part 40's six square waves at unrelated pitches, band-passed high, short for closed and long for open.

Four bars of the circuit kit at a hundred beats a minute, on a sixteen-step grid.

Nothing in that groove was recorded. Every sound is a resonator struck, noise shaped by an envelope, or square waves filtered: a few dozen components each, which is why a drum machine of 1980 could carry a whole kit in one box.

And any resonant filter is a drum. Chapter five's ladder, its feedback at three point nine, just short of oscillating, struck by a two-millisecond pulse, at three cutoffs, then a fill on all three. Use headphones or bass-capable speakers for these low toms.

Three toms. The decay shortens as the cutoff rises, , and seconds, because at a fixed feedback the filter's Q is fixed, and the same number of cycles takes less time at a higher pitch. And the hard strike saturates the rungs, which slows them: the low tom starts at hertz and settles to as it quietens. A real drumhead does the opposite, falling in pitch as it quietens, as the kick's chirp does.

The circuits had a short first life. In 1980 the TR-808 was all analogue, a commercial flop that became hip-hop's kick, as Part 40 told. In 1983 the TR-909 kept analogue drums but stored its cymbals as six-bit samples. Samples won, and by the late 1980s most drum machines played recordings. Then the circuits came back, modelled in software and rebuilt in hardware. A resonator, a noise source and an envelope remain the cheapest drum there is.

10Fitting a patchPractice5 min

Given a sound, which knobs make it?

Synthesis runs from knobs to sound. Sound design often wants the reverse. A player hears a tone and asks: which oscillator, which cutoff, how much resonance? For a computer the recipe is to choose a distance between sounds, then search for the knobs that make it smallest. Part 41's orchestration solver did the same with instruments for knobs. The hook's patch was found this way: three knobs, three hundred and fifty settings tried.

First the knobs. Our patch is a sawtooth and a square, mixed by m, through the ladder at cutoff f c with feedback k. Then the distance. Measure each sound at every multiple of half its note: the harmonics, and the slots between them. The slots between catch what a patch like ours cannot make, such as a tone an octave below. Levels in decibels below the loudest, floored at minus sixty. The distance is the root-mean-square difference, in decibels, over the slots where either sound has anything.

Before trusting the search, check it on an answer we know. Make a sound with the patch itself, at fourteen hundred hertz, feedback two, an even mix, and hide the settings. The search finds hertz, feedback , mix , at a distance of decibels. The cutoff is off by per cent only because the search tries a grid of fourteen cutoffs and then nine finer steps, and lands on the nearest.

Here is what the search saw for the hook's target, at the best mix: the distance for every cutoff and feedback it tried. Bright squares are close, dark ones far. The valley runs along the cutoff: too low and the patch is dull, too high and it is buzzy, with a broad good region between. The best lies near hertz with feedback . With three knobs a grid is cheap; with thirty it would not be.

Back to the hook, slot by slot. The target's harmonics, and the patch's beside them, with the empty slots between. Below the bump and above it the two agree within a few decibels. At the third, fourth and fifth harmonics the target is up to decibels louder: a ladder low-pass can make a peak at its cutoff, but not a broad hump with the highs still bright above it. The search settled for the best compromise, a cutoff above the bump. A peaking filter, Part 49's, would close the gap: a richer patch, one more knob.

Some targets are out of reach. Jimmy Smith's registration on middle C has tones at half the note, the sixteen-foot drawbar, and at one and a half times it, the fifth below the octave: slots that no filtered sawtooth or square on that note can fill. The best of three hundred and fifty settings is decibels away. Hear the organ and the best patch.

The organ sits an octave lower than its key, round and deep; the patch is a bright, mostly square tone at the key's own pitch. A large error in this sampled search suggests a mismatch between the target and this patch family; it does not prove that no setting could fit, but not which module would bring it closer. Here the answer is a second oscillator an octave down: a change to the patch, not to its knobs.

Fitting real synthesizers is harder in four ways. Our distance hears only the steady spectrum: not the attack, not the envelope, not the movement. A grid grows exponentially: ten values each for thirty knobs is ten to the thirtieth patches. So genetic algorithms and other searches took over in the 1990s and 2000s. And spectral distances have valleys that mislead: a patch an octave off can look nearer than one a semitone off. The frontier learns the inverse directly, or makes the synthesizer itself differentiable.

11Frontier: sound matching and differentiable synthesizersResearch3 min

Can a network learn to turn the knobs?

The frontier replaces search with learning. Make a million patches at random, render them, and train a network to map each sound back to the knobs that made it. Matthew Yee-King, Leon Fedden and Mark d'Inverno did this in 2018 for a software synthesizer and beat a genetic search. InverSynth, by Oren Barkan and colleagues in 2019, read the knobs from a spectrogram. Philippe Esling's Flow Synthesizer of 2020 learned a map of all the presets, to be explored by ear. But each network learns one synthesizer: change the instrument and you train again.

The other road makes the synthesizer itself differentiable. Every knob gets a gradient, and gradient descent turns them all at once. DDSP, by Jesse Engel and colleagues in 2020, put an additive synthesizer and filtered noise inside a network. Recursive filters are the hard part: gradients must flow back through every sample of feedback. Boris Kuznetsov, Julian Parker and Fabián Esqueda trained IIR filters this way in 2020, and ladders followed. Our trapezoid-and-Newton ladder is smooth in its knobs, so it too could be differentiated, in principle.

There is a catch. Gradient descent needs a distance whose slope points the right way. Joseph Turian and Max Henry showed in 2020 that spectral distances are bad at pitch: away from the answer their slope is flat, or wrong, as our fitting chapter warned. So differentiable synthesizers are usually told the pitch, and learn only the colour. Ben Hayes and colleagues' review of 2024 collects the methods and the open problems. The same knobs, the same distance, and a search that is no longer blind.

A research problem to end on. Take a two-oscillator patch with the ladder and two envelopes, and render a thousand notes with hidden settings. Fit each by grid search, by a learned inverse, and by descent through a differentiable ladder from many starting points. Map how often descent finds the hidden settings, against pitch, resonance and the distance used. The question: can gradient descent fit an analogue patch to a recorded note as reliably as a search? Then fit notes from real analogue synthesizers, and judge the fits by blind listening.

Variation 51, recap and problemsAll tracks3 min

Every part ends by doing something to the Tune with what it built. Here it is switched on, as Wendy Carlos made Bach: four lines, each played on its own patch, one at a time, and layered. A brass lead with a filter envelope and vibrato; a plucked square bass; a narrow pulse arpeggio; and a soft unison pad. First the lead alone, then all four.

Row fifty-one of the ledger. notes on four tracks, counting each pad chord once: in the lead, in the bass, in the arpeggio. The lead's oscillator keeps its aliasing decibels below its harmonics on average; a naive one would manage only .

What did we find? Additive synthesis sums sines, and the Hammond borrows tempered ones. Subtractive synthesis filters a rich wave: a few knobs move every harmonic. A naive digital sawtooth aliases, and band-limited steps cut it by fourteen to sixteen decibels. The ladder is four poles and a loop: its ideal linear stability boundary is k equals four, and its transistors saturate. The trapezoid with Newton's method steps its circuit to second order. And envelopes, LFOs, pulse width, sync and unison move a sound, while fitting finds its knobs.

Five problems. One to compute, one to prove, one for your ears, one to build, and a research problem, marked with a star. Solutions are in this part's notes. Pause here.

Where does this come back? Next time, in FM, grains and physical models, the other ways out of the oscillator. In MIDI and sequencers, where a keyboard learns to talk to a synthesizer. In recording and mixing. In transcription, which is the hook's inverse problem for whole recordings. And in generative audio, with differentiable synthesizers inside networks.

And in practice. Sound designers start from a sawtooth and a filter envelope, and subtract. Players turn the resonance up gently, because it costs the bass. Plug-in developers band-limit every jump and step the ladder implicitly. And producers detune a little, for the drift that analogue had for free.

The books and papers this part follows. The full list, with notes, is in the README.

Where it goes next. FM, granular and physical-model synthesis in Part 52; MIDI and the sequencer in Part 53; synthesizers in a mix in Part 56; transcription, the inverse problem for recordings, in Part 61; differentiable synthesizers in Part 66.

Key results

The part's results in one place, for revision.

Sawtooth\(\displaystyle \tfrac{2}{\pi}\sum_k (-1)^{k+1} \sin(2\pi k f t)/k\)
Ladder\(\displaystyle H(s) = 1/\big((1 + s/\omega_c)^4 + k\big)\)
Edge\(\displaystyle (1 + j)^4 = -4 \Rightarrow k = 4\)
Pulse\(\displaystyle |a_k| \propto |\sin(\pi k w)|/k\)
Resonator\(\displaystyle \tau = 2Q/(2\pi f)\)

Try it

Lab 51 · Synthesis, computed

Measure how four sawtooths alias, step the ladder's circuit three ways against a reference, and fit a patch to a sound you design.

Figure produced by Lab 51: Synthesis, computed
Produced by the lab below, seed 0, in 0.9 s.
python -m videos.music.labs 51 needs numpy, scipy, matplotlib · download lab51.py · source on GitHub
aliasing at 1760 Hz (dB re the note): naive, PolyBLEP, BLIT, additive  -13.5, -28.9, -64.6, -119.3
ladder, forward: error at 1x, 2x, 4x (dB)                              -12.0, -16.3, -21.3
ladder, corrected: error at 1x, 2x, 4x (dB)                            -14.5, -19.5, -24.9
ladder, trapezoid: error at 1x, 2x, 4x (dB)                            -37.4, -49.4, -61.4
hidden patch (cutoff, k, mix)                                          900 Hz, 3, 0.25
found                                                                  882 Hz, 3, 0.25; distance 1.28 dB
ear problem: the last three are naive or PolyBLEP (listen first)       naive, naive, PolyBLEP

A naive sawtooth's drop between samples folds harmonics back; a band-limited step at each jump cuts them. The ladder's circuit converges at 6 dB per doubling by forward steps and 12 by the trapezoid. A patch is found by a distance and a search, and a distance can only say a sound is out of reach, not why.
The code (81 lines; it asserts its own result)
"""Lab 51: synthesis, computed: sawtooths and their aliasing, the ladder against its circuit, and fitting a patch."""

import numpy as np

from videos.coursekit import labs
from explainer.music.monochord import SR, Clip, concat
from explainer.music.monochord import dynamics as D
from explainer.music.monochord import synth as S

TITLE = "Synthesis, computed"
GOAL = ("Measure how four sawtooths alias, step the ladder's circuit three ways against a reference, and fit a patch to a "
        "sound you design.")
TASKS = [
    "Change NOTE. How does each sawtooth's aliasing change from octave to octave, and why does the naive one lose 3 dB an octave?",
    "Change CUTOFF, K and DRIVE. At what K does the forward-step model's error grow fastest? Does the trapezoid keep its lead?",
    "Edit TARGET (a hidden patch: cutoff, k, mix). Does the search find it? Then make the target a drawbar organ and explain the fit.",
]
NOTE = 1760.0
CUTOFF, K, DRIVE = 1500.0, 3.0, 1.0
TARGET = (900.0, 3.0, 0.25)


def run(seed=0):
    rng = np.random.default_rng(seed)
    lab = labs.Lab()
    names = ("naive", "PolyBLEP", "BLIT", "additive")
    fns = (S.saw_naive, S.saw_polyblep, S.saw_blit, S.saw_additive)
    al = [D.alias_energy(fn(NOTE, SR), NOTE, SR) for fn in fns]
    lab.row(f"aliasing at {NOTE:g} Hz (dB re the note): " + ", ".join(names), ", ".join(f"{a:.1f}" for a in al))
    x = DRIVE * S.saw_polyblep(220.0, 2400)
    ref = S.ladder_ode(x, CUTOFF, K)

    def err(y):
        return 10 * np.log10(np.sum((y - ref) ** 2) / np.sum(ref ** 2))
    rows = {"forward": [err(S.ladder(x, CUTOFF, K, oversample=r, half=False)) for r in (1, 2, 4)],
            "corrected": [err(S.ladder(x, CUTOFF, K, oversample=r)) for r in (1, 2, 4)],
            "trapezoid": [err(S.ladder_trap(x, CUTOFF, K, oversample=r)) for r in (1, 2, 4)]}
    for k, v in rows.items():
        lab.row(f"ladder, {k}: error at 1x, 2x, 4x (dB)", ", ".join(f"{e:.1f}" for e in v))
    f = 261.63
    tgt = S.patch(f, 8192, *TARGET)
    fit = S.fit_patch(tgt, f)
    lab.row("hidden patch (cutoff, k, mix)", f"{TARGET[0]:.0f} Hz, {TARGET[1]:g}, {TARGET[2]:g}")
    lab.row("found", f"{fit['cutoff']:.0f} Hz, {fit['res']:g}, {fit['mix']:g}; distance {fit['distance_db']:.2f} dB")
    assert rows["trapezoid"][0] < rows["forward"][0] and fit["distance_db"] < 3.0

    # sound: the hidden patch and the fit; ear problem: naive or PolyBLEP high notes, at random
    n = int(1.2 * SR)
    env = S.adsr(n, SR, gate_s=1.0, a=0.01, d=0.2, s=0.8, r=0.15)
    clips = [Clip(0.4 * S.patch(f, n, *TARGET) * env, SR), Clip(0.4 * S.patch(f, n, fit["cutoff"], fit["res"], fit["mix"]) * env, SR)]
    answers = []
    for i in range(3):
        m = 2093.0 * 2 ** (int(rng.integers(0, 12)) / 12)
        if rng.random() < 0.5:
            clips.append(Clip(0.25 * S.saw_naive(m, n) * env, SR))
            answers.append("naive")
        else:
            clips.append(Clip(0.25 * S.saw_polyblep(m, n) * env, SR))
            answers.append("PolyBLEP")
    lab.audio = concat(clips, gap=0.6)
    lab.row("ear problem: the last three are naive or PolyBLEP (listen first)", ", ".join(answers))

    fig, (ax1, ax2) = labs.figure(2)
    for k, c in zip(rows, ("C3", "C1", labs.GOLD)):
        ax1.plot([1, 2, 4], rows[k], "o-", color=c, label=k)
    ax1.set_xscale("log", base=2)
    ax1.set_xlabel("times 48 kHz")
    ax1.set_ylabel("error, dB")
    ax1.legend(fontsize=7)
    ht = S.harmonic_levels(tgt, f)
    hf = S.harmonic_levels(S.patch(f, 8192, fit["cutoff"], fit["res"], fit["mix"]), f)
    j = np.arange(1, len(ht) + 1) / 2
    ax2.stem(j - 0.08, ht, linefmt="C7-", markerfmt="C7o", basefmt=" ", bottom=-60)
    ax2.stem(j + 0.08, hf, linefmt="C3-", markerfmt="C3o", basefmt=" ", bottom=-60)
    ax2.set_xlabel("multiple of the note")
    ax2.set_ylabel("dB")
    lab.fig = fig
    lab.note = ("A naive sawtooth's drop between samples folds harmonics back; a band-limited step at each jump cuts them. "
                "The ladder's circuit converges at 6 dB per doubling by forward steps and 12 by the trapezoid. A patch is "
                "found by a distance and a search, and a distance can only say a sound is out of reach, not why.")
    return lab

Now change it

  1. Change NOTE. How does each sawtooth's aliasing change from octave to octave, and why does the naive one lose 3 dB an octave?
  2. Change CUTOFF, K and DRIVE. At what K does the forward-step model's error grow fastest? Does the trapezoid keep its lead?
  3. Edit TARGET (a hidden patch: cutoff, k, mix). Does the search find it? Then make the target a drawbar organ and explain the fit.

Problems, with solutions

Try each problem before opening its solution.

  1. Compute. A ladder has its cutoff at 500 Hz and k = 2. What are its gains, in dB, at 0 Hz and at 500 Hz?

    Solution

    At 0 Hz, H = 1/(1 + k) = 1/3: −9.5 dB. At the cutoff, (1 + j)⁴ = −4, so H = 1/(−4 + 2) and |H| = 1/2: −6.0 dB. (With no feedback the cutoff would be at −12.0 dB; the feedback has raised it 6 dB and cut the bass 9.5.)

  2. Prove. Prove that a pulse of width w (high for a fraction w of each cycle) has harmonics of size proportional to |sin(πkw)|/k.

    Solution

    Take the pulse p(t) = 1 for 0 ≤ t < w and 0 for w ≤ t < 1, period 1 (a constant offset changes only the zeroth coefficient). Its k-th complex Fourier coefficient is c_k = ∫₀^w e^{−2πikt} dt = (1 − e^{−2πikw})/(2πik) = e^{−πikw} (e^{πikw} − e^{−πikw})/(2πik) = e^{−πikw} sin(πkw)/(πk). So |c_k| = |sin(πkw)|/(πk), which is zero exactly when kw is a whole number.

  3. Ear. The lab plays high notes on a naive or a PolyBLEP sawtooth, at random; say which is which.

    Solution

    The lab prints them. The naive ones carry a faint, inharmonic halo, tones that do not belong to the note and sound rough or gritty; on a sustained note they can sound like a quiet second pitch.

  4. Build. Add a peaking filter to the patch and refit the hook's target: how far does the distance fall?

    Where to look. Put Part 49's peaking biquad (effects.biquad("peak", ...)) after the ladder, with its frequency and gain as two more knobs, and widen fit_patch's grid (or search them by a few rounds of coordinate descent). The target's bump is near 1.1 kHz and about 9 dB above what the ladder alone gives there.

  5. ★ Can gradient descent fit an analogue patch to a recorded note as reliably as a search?

    Where the frontier is. Render notes from a two-oscillator patch with the ladder and two envelopes at hidden settings; fit them by grid search, by a network trained to invert the synthesizer, and by gradient descent through a differentiable ladder (the trapezoidal solver is smooth in its knobs) from many starts; map the success rate against pitch, resonance and the distance used (spectral, multi-resolution, or learned); then fit notes from real analogue instruments and judge the fits blind.

Notes and sources

Sources

  • C. Roads, The Computer Music Tutorial (2nd ed., 2023); W. Pirkle, Designing Software Synthesizer Plug-Ins in C++ (2nd ed., 2021); T. Pinch and F. Trocco, Analog Days: The Invention and Impact of the Moog Synthesizer (2002); R. Weidenaar, Magic Music from the Telharmonium (1995).
  • T. Stilson and J. O. Smith, "Alias-free digital synthesis of classic analog waveforms", ICMC (1996), and "Analyzing the Moog VCF with considerations for digital implementation", ICMC (1996); E. Brandt, "Hard sync without aliasing", ICMC (2001); V. Välimäki and A. Huovilainen, "Oscillator and filter algorithms for virtual analog synthesis", Computer Music Journal (2006), and "Antialiasing oscillators in subtractive synthesis", IEEE Signal Processing Magazine (2007).
  • R. A. Moog, US patent 3,475,623, "Electronic high-pass and low-pass filters employing the base to emitter diode resistance of bipolar transistors" (filed 1966, granted 1969); A. Huovilainen, "Non-linear digital implementation of the Moog ladder filter", DAFx (2004); V. Zavalishin, The Art of VA Filter Design (2012, rev. 2018).
  • J.-C. Risset, An Introductory Catalogue of Computer Synthesized Sounds (Bell Laboratories, 1969).
  • M. Yee-King, L. Fedden and M. d'Inverno, "Automatic programming of VST sound synthesizers using deep networks and other techniques", IEEE Trans. Emerging Topics in Computational Intelligence (2018); O. Barkan and others, "InverSynth: deep estimation of synthesizer parameter configurations from audio signals", IEEE/ACM TASLP (2019); P. Esling and others, "Flow synthesizer: universal audio synthesizer control with normalizing flows", Applied Sciences (2020).
  • J. Engel, L. Hantrakul, C. Gu and A. Roberts, "DDSP: differentiable digital signal processing", ICLR (2020); B. Kuznetsov, J. D. Parker and F. Esqueda, "Differentiable IIR filters for machine learning applications", DAFx (2020); J. Turian and M. Henry, "I'm sorry for your loss: spectrally-based audio distances are bad at pitch" (2020); B. Hayes and others, "A review of differentiable digital signal processing for music and speech synthesis", Frontiers in Signal Processing (2024).
  • C. Dodge and T. A. Jerse, Computer Music: Synthesis, Composition, and Performance (2nd ed., 1997); T. Holmes, Electronic and Experimental Music (6th ed., 2020), for the history from the Telharmonium on.
About this partfrom its README

Part 51 of a sixty-eight-part course in music (see the series plan and the syllabus), the fourth part of Act IX, Electric Sound. One early large-scale electrical instrument weighed nearly two hundred tons: Thaddeus Cahill's Telharmonium (1906) summed the near-sines of dynamos and sent them down telephone lines, and it failed. Sixty years later Robert Moog's modules did the job by subtraction, and Switched-On Bach sold over a million copies. This part builds a synthesizer: oscillators that do not alias, the Moog ladder run against its own circuit equations, envelopes, modulation, wavetables, drums made of resonators, and a search that sets the knobs to imitate a sound. The tools are Monochord's (explainer/music/monochord/synth.py); every sound is computed, and none is sampled.

  • Two hundred tons. An ear question (forty sines set by hand, and a two-oscillator patch a search fitted to them: which is the original?); the two harmonic by harmonic (the patch 3.0 dB away on average, missing the bump near 1.1 kHz that a low-pass cannot make); the Telharmonium; Moog and Switched-On Bach; the plan.
  • 1. Additive synthesis: dynamos and drawbars. A sawtooth from 1, 2, 3, 5, 10 and 40 sines (Gibbs's 9 per cent); Fourier's list; the Hammond (1935): 91 tonewheels and nine drawbars; three registrations heard (8' alone, 888000000, all nine); the tempered drawbars (the fifths 2.0 cents flat, the third 13.7 sharp); what additive synthesis costs (Risset's trumpets, the Synclavier, the K5).
  • 2. Subtractive synthesis. Take away; four sources and their harmonics (sawtooth, square, triangle, a 25 % pulse); oscillator, filter, amplifier and voltage control (1 V an octave); a filter sweep heard without and with resonance, with its spectrogram; from cords to keyboards (Buchla, the Minimoog, the Prophet-5).
  • 3. Why digital sawtooths alias. The drop between samples; one high note's spectrum naive and band-limited (D7, ten true harmonics); aliasing against pitch over six octaves (naive 25.6 dB down at 110 Hz to 10.3 at 3.5 kHz, 3 dB worse an octave; PolyBLEP 14 to 16 dB better, 5 to 8 more at twice the rate; BLIT near 64; additive exact); PolyBLEP's two parabolas drawn; an ear question (a high phrase naive and PolyBLEP: which aliases?); BLIT, BLEP, PolyBLEP, wavetables.
  • 4. The ladder filter. Four poles and a loop (Moog's patent, filed 1966); the linear ladder in three lines, 1/((1 + s/ωc)⁴ + k); five responses (a peak of 14.3 dB at k = 3.8); why k = 4 is the edge ((1 + j)⁴ = −4); resonance costs bass (1/(1 + k): −12.0 dB at k = 3); a bass line at three resonances, heard.
  • 5. Running the circuit. Huovilainen's equations (four capacitors charged through tanh); three ways to step them against a Runge–Kutta reference: forward steps (−11.9 dB at 48 kHz, 6 dB better per doubling), the half-sample correction (−14.4), and the trapezoid with Newton, zero-delay feedback (−37.2, 12 dB per doubling, about 2.5 times the cost a sample); an ear question (the circuit against its equations without tanh, driven hard); the harmonics (the 4th at +3.3 dB linear, −19.5 in the circuit); past k = 4 (oscillating within about 20 cents of the cutoff); the filter sings the Tune.
  • 6. Envelopes and modulation. ADSR (Ussachevsky); pluck, brass and pad; one patch with three envelopes, heard; LFOs (vibrato, tremolo, a wobble), heard; any source to any destination (keyboard tracking, velocity, FM ahead).
  • 7. Pulse width, sync and unison. Width as a knob (zeros at |sin πkw|/k); hard sync (the slave restarted by the master); PWM and sync heard; seven sawtooths over 36 cents (seven lines over 22 Hz at the 8th harmonic); a supersaw heard; perfect and imperfect (drift, virtual analogue).
  • 8. Wavetables. A wave from memory (PPG, 1981); eight stored cycles; a scan heard; three positions' spectra (the hollow middle); wavetables alias too (at C6, 18.3 dB down naive, 55.8 with only the 19 harmonics below 20 kHz: mipmaps); wavetables now.
  • 9. Drum circuits. A drum is a struck resonator (τ = 2Q/2πf); the kick from the circuit (52 Hz, Q 74: decay 0.453 s predicted, 0.454 measured; a chirp from 63 Hz to 52); snare, clap and hats; a kit of circuits heard; the ladder struck near self-oscillation as three toms (decays 0.25, 0.16 and 0.10 s; the low tom rising from 77 Hz to 79); circuits and samples (the 808, the 909's 6-bit cymbals).
  • 10. Fitting a patch. The inverse problem; a distance between two tones (levels at every multiple of half the note, floored at −60 dB); the search checked on a hidden patch (1400 Hz, k = 2, mix 0.5 found as 1365 Hz, 2, 0.5, 0.69 dB); the landscape; the hook's target slot by slot (the bump missed by up to 9 dB); an organ no setting can make (27 dB, heard); why fitting is hard.
  • 11. Frontier: sound matching and differentiable synthesizers. Learning the inverse (Yee-King, Fedden and d'Inverno; InverSynth; the Flow Synthesizer); differentiable synthesizers (DDSP; differentiable IIR filters); where the gradients go wrong (Turian and Henry); ★ research problem: can gradient descent fit an analogue patch to a recorded note as reliably as a search?
  • Variation 51, recap and problems. The Tune switched on: a lead alone, then four monophonic tracks (lead, square bass, pulse arpeggio, unison pad) layered; the ledger (354 notes on four tracks; the lead's aliasing 34 dB below its harmonics, 18 if naive); what we found; five problems; where it comes back; in practice; references; Part 52.
What is computed and built

python -m videos.music.music51.compute (about half a minute; the loops are compiled by numba when it is installed) fills .cache/music51/.

Item What it computes Checked against
fit, hook a grid search over cutoff, feedback and mix; a hidden patch recovered; the hook's target; an organ the hidden settings (tests)
partials, organ, waves partial sums; tempered drawbars; four sources' harmonics the tempered cents (tests)
sweep, alias a resonant sweep and its spectrogram; aliasing for five oscillators over six octaves 3 dB an octave; additive exact (tests)
ladder, ladder3, drive, sing the linear response; three solvers against Runge–Kutta; saturation; self-oscillation −12.04 dB at the cutoff; 6 and 12 dB a doubling (tests)
env, mod, pwmsync, unison envelopes, LFOs, PWM, hard sync, unison the pulse's zeros; sync's period (tests)
table eight cycles, a scan, band-limited copies the sine at position 0 (tests)
drums, toms struck resonators, noise and squares; the ladder struck τ = 2Q/2πf (tests)
tune51 four tracks, one patch each the note count (tests)

Monochord's tools are held in tests/music/test_synth.py; this part's claims and clips in tests/music/test_music51.py.

Sounds. Every sound in this part is synthesized here: oscillators, filters, envelopes, resonators and noise. The Hammond is a computed model of its drawbars, and the hats are Part 40's six square waves.

What the models are, and are not. The ladder is Huovilainen's model: ideal tanh stages and capacitors, no thermal noise, no mismatch between transistors, no change of tuning with temperature. The Hammond has no key click, no leakage between tonewheels, no percussion and no rotating speaker. The drums are schematic circuits, not schematics of the 808. The patch fitting matches steady spectra only.

Notes

The Telharmonium was not the first electrically generated tone device. Classic Hammond generators use geared shafts, and tempered-drawbar offsets refer to this simplified model. Phase audibility depends on harmonic resolution and envelopes. PolyBLEP reduces aliasing rather than eliminating it, and off-grid-energy metrics include windowing effects. The ladder’s k=4 boundary belongs to the ideal linear model; nonlinear oscillation needs a perturbation and amplitude limiting. Numerical comparisons use an oversampled reference rather than exact physical truth. Patch fitting is a finite sampled search with a chosen spectral metric, not a proof of perceptual identity or impossibility.

Companion material in this repository

The syllabus's plan for this partfrom SYLLABUS.md, the plan of record
  1. Hook: an ear question (forty sines or a fitted patch: which is the original?); the two compared; the Telharmonium; Moog and Carlos; the plan.
  2. Additive synthesis: a sawtooth from sines; Fourier's list; the Hammond; three registrations heard; tempered drawbars; the cost.
  3. Subtractive synthesis: take away; four sources; the chain and voltage control; a filter sweep heard; from cords to keyboards.
  4. Why digital sawtooths alias: the drop; one note's spectrum; aliasing against pitch; PolyBLEP drawn; an ear question (which aliases?); the cures.
  5. The ladder filter: four poles and a loop; the algebra; five responses; the edge at k = 4; resonance costs bass; three resonances heard.
  6. Running the circuit: the equations; three solvers; convergence; an ear question (circuit or equations without tanh?); harmonics; past the edge; the filter sings.
  7. Envelopes and modulation: ADSR; three envelopes; one patch three ways heard; LFOs; three modulations heard; routing.
  8. Pulse width, sync and unison: width as a knob; hard sync; PWM and sync heard; unison; a supersaw heard; drift.
  9. Wavetables: a wave from memory; the table; a scan heard; three spectra; mipmaps; wavetables now.
  10. Drum circuits: struck resonators; the kick from the circuit; snare, clap, hats; a kit heard; the ladder struck as toms; circuits and samples.
  11. Fitting a patch: the inverse problem; a distance; the search checked; the landscape; the hook's target; an organ out of reach, heard; why fitting is hard.
  12. Frontier: learning the inverse; differentiable synthesizers; where gradients go wrong; the research problem.
  13. Variation 51: the Tune switched on, four tracks layered. Outro: problems, payoffs.

Covers: additive synthesis from organ to Hammond; subtractive synthesis; why digital sawtooths alias and how to stop it; the ladder filter; envelopes; modulation; sync and pulse width; unison; wavetables; drum circuits. Built and computed: monochord/synth.py: naive, PolyBLEP, BLIT and additive sawtooths with aliasing measured (naive 25.6 dB down at 110 Hz to 10.3 at 3.5 kHz; PolyBLEP 14 to 16 dB better); pulses, hard sync, unison, tempered drawbars; the ladder by forward steps, Huovilainen's correction and the trapezoid with Newton, against Runge–Kutta (6 and 12 dB a doubling; −37.2 dB at 48 kHz); self-oscillation within 20 cents; ADSR, wavetables with band-limited copies; struck-resonator drums (decay 0.454 s against 0.453); a patch fitted to harmonic levels (a hidden patch found within 0.7 dB; the hook's target 3.0 dB; an organ 27). Variation 51: the Tune switched on: four monophonic tracks, one patch each (354 notes; aliasing 34 dB down, 18 if naive). Frontier: sound matching by learning; differentiable synthesizers (open: can descent fit a patch as reliably as a search?). Reading: Roads, The Computer Music Tutorial; Pirkle; Välimäki & Huovilainen (2006); Pinch & Trocco, Analog Days.

Build the film

python -m videos.music.music51.compute        # the part's numbers, into .cache/music51
python tools/build.py music51                  # render and assemble the film
EXPLAINER_TTS=silent python tools/qa_scene.py music51 Hook   # one chapter, silent, with a contact sheet

Scenes: videos/music/music51. Setup: see the course page. Source of these notes: the README and the scenes' narration.

Build it
python -m videos.music.music51.compute                          # numbers and sounds (about half a minute)
EXPLAINER_TTS=silent python tools/build.py music51 -q l --fps 15   # a silent-narration preview, with the sounds
python tools/qa_sound.py music51 --sync                         # the sound gates
python tools/dead_air.py renders/music51_480p.mp4 --sound music51  # no empty screen; no sound over a still one
python tools/lecture_length.py music51                          # 30 to 60 minutes, listening included
python tools/build.py music51                                   # 1080p30, narrated
python -m pytest -q tests/music                                 # Monochord against its references; this part's claims and clips
python -m videos.music.labs 51                                  # the lab (writes a figure and a short WAV)