♪Music, Built

Act I · Sound

Part 3 of 68

The Spectrum

Foundationsstarts at this level39 min of film13 chaptersprerequisites: none

Can every sound be taken apart into pure tones, what does the taking apart cost, and is the list of pure tones everything there is to a sound?

In 1807 the Paris Academy would not print Fourier's claim that any curve is a sum of sines; Lagrange objected that smooth curves cannot make a corner. A square wave assembled one sine at a time shows what Fourier meant, the coefficients turn out to be averages, and the overshoot at a jump never goes away. A computer does the same for samples, and since Cooley and Tukey does it fast. Helmholtz tested Ohm's law of hearing with resonators, each one a bottle from Part 2, and a bank of them on our string agrees with the transform. Phase turns out to matter only where the ear cannot separate the partials. To watch a recipe change one needs a window, which costs leakage, and behind the window stands Gabor's limit: no sound is both short and narrow in frequency. A constant-Q ruler suits music better than equal bins; noise has a spectrum that must be averaged. Then the test of Helmholtz's second claim: one pluck played backwards has exactly the same spectrum and is a different instrument. Timbre is a recipe that changes in time. The Tune is assembled from pure tones.

What you need. Parts 1 and 2 for partials, modes and resonators. Sines and cosines; an integral as an average. Complex exponentials appear once, in the definition of the DFT, and the film says what they mean.

Ideas, mathematics and history
Fourier series and transform, timbre, the spectrogram, windows and the Gabor limit, phase, noise colors, why the attack matters
What we build, compute and hear
our STFT and constant-Q transform; the Tune built one partial at a time

What you will be able to do

Foundations

  • Read a spectrum and a spectrogram: partials, onsets, glides, noise.
  • Say what a window does to a spectrum and why a short sound cannot have a sharp pitch.
  • Explain why two sounds with the same spectrum can sound different, and name what else matters.

Full course

  • Compute Fourier coefficients as projections and explain the Gibbs overshoot.
  • State the DFT, the idea and cost of the FFT, and the meaning of a bin.
  • State Gabor's uncertainty relation and choose a window length for a given task.

Research

  • Describe reassignment and when it sharpens a time-frequency picture.
  • Explain why human listeners can beat the uncertainty limit without contradiction.

Practice

  • Choose a window and a bin width before trusting a spectrum analyser.
  • Use a constant-Q or mel picture as the input to a music-analysis task.
  • Shape a sound's identity by its attack rather than by its steady spectrum.

Contents

Each chapter has a home level. Choose a track to see what to read and watch: Foundations 25 min · Full course 37 min · Research 39 min · Practice 37 min.

  1. 0The Academy says noFoundations2 min
  2. 1A sum of sinesFoundations5 min
  3. 2From a recipe to a machinePractice3 min
  4. 3What the ear does with itFoundations4 min
  5. 4The other half of the recipeFoundations3 min
  6. 5Time and frequency togetherFoundations2 min
  7. 6What a window costsPractice2 min
  8. 7The limitPractice4 min
  9. 8A ruler for musicPractice2 min
  10. 9Sounds with no pitchFoundations3 min
  11. 10More than the spectrumFoundations2 min
  12. 11Frontier: sharper than the limitResearch2 min
  13. Variation 3, recap and problemsAll tracks4 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.

The Academy says noFoundations2 min

That was one note, getting brighter. But look at how it was made. Each step added more pure tones, each a plain sine wave, at three, five, seven times the frequency of the first. And the smooth curves are closing in on something with corners.

In December 1807 Joseph Fourier stood before the Paris Academy of Sciences with a memoir about how heat flows through a metal bar. Buried in it was a claim about curves. Any curve at all, he said, even one with sudden jumps, can be written as a sum of sine waves. The examiners included Lagrange and Laplace, the two greatest mathematicians alive. Lagrange would not have it. A sine is smooth. A sum of smooth things is smooth. How could it ever make a corner? If that sounds familiar, it should: it is exactly the objection Euler made to Bernoulli about the plucked string, fifty years earlier, in Part 1. The Academy declined to publish. Fourier waited fifteen years and printed the work himself.

Fourier was right, and this part is about what that means for sound. Three questions. Can every sound be taken apart into pure tones? What does the taking apart cost you: what detail does a magnitude picture leave out? And is the list of pure tones the whole story? If two sounds have exactly the same recipe, must they sound the same? We will end by playing one plucked string in a way that keeps its magnitude spectrum exactly and changes the sound completely.

This is Part 3 of Music, Built. Part 1 took a plucked string apart into partials. Part 2 told two pipes apart by theirs. Now we make the idea exact. How to find the recipe of any wave. How a computer does it, fast. What the ear seems to do with it. How to watch a recipe change in time, and the hard limit on doing so. A way of measuring made for music. And last, what the recipe leaves out.

1A sum of sinesFoundations5 min

How much of each sine is in a wave?

Before the recipe, a fair question. Why sines? You could build waves out of triangles, or square pulses. What is special about this one shape? In steady state, send a sine through a linear, time-invariant system, something that rings: a string, a pipe, a room, an electrical circuit. What comes out is a sine wave of the same frequency. It may be bigger or smaller, earlier or later, but its shape is untouched. A square wave generally changes shape because its harmonics are filtered differently. That is the reason. Sines retain their frequency through any such linear system, which is why the modes of the string in Part 1 each sang a pure sine in time. Take a sound apart into sines and each piece goes through the world independently of the others.

For this odd, zero-mean square wave, only sine terms are needed. A general periodic wave also needs cosines, or phases, and possibly a constant term. The harmonic frequencies are one, two, three times the frequency of the wave itself. The only question is how much of each. His recipe is this. To find how much of the third sine is in a square wave, multiply the two together, point by point, and take the average. Where the square and the sine agree in sign the product is positive, and here they agree more than they disagree. Try the second sine instead, and the positive humps exactly cancel the negative ones. There is no second harmonic in a square wave. That is the whole method: each amount is twice an average. Done numerically for the first seven, it gives , nothing, , nothing, : four over pi, divided by one, three, five. Only the odd ones, each weaker than the last.

Now add them back up, and watch Lagrange's objection. With one term, a sine. With two, three, five, the flat tops fill in and the sides stand up. Every one of these curves is perfectly smooth. None of them has a corner. But measure the average gap between the sum and the square, and it keeps shrinking, towards nothing. Lagrange was thinking of a curve as a single formula. Fourier's sum does something subtler: it gets as close as you like, in the average. Making that idea exact took another twenty years, and the proof, by Dirichlet in 1829, is where the modern idea of a function comes from.

There is one place where the sum stays stubborn, and it matters for sound. Look closely just after the jump. The sum overshoots, and rings. Add more terms and the ringing squeezes closer to the jump, but the overshoot does not get smaller. It settles at about percent of the jump, however many terms you use. This is the Gibbs phenomenon. You will meet it again whenever a sound is cut off sharply in frequency: a filter that is too steep rings, for exactly this reason.

All of that was for a wave that repeats. Most sounds do not: a clap, a word, a whole symphony happens once. Here is the trick. Take a pulse that repeats every four of its own widths. Its recipe is a row of lines, at multiples of its repeat rate. Now let it repeat half as often. The lines move closer together, under the same outline. Repeat it more rarely still, and they crowd closer. In the limit, a pulse that happens just once, the lines merge into a smooth curve: a continuous spectrum. This is the Fourier transform. A sound that repeats has a spectrum of separate lines; audible repetition can give it a pitch. A sound that happens once has a continuous one. And the shorter the pulse, the wider its curve: an ideal infinitely short click has equal strength at every frequency. Real clicks have finite bandwidth.

A question for your ears. Two tones on the same note. One contains every harmonic. The other contains only the odd ones. Which is which?

was the square wave, with only the odd harmonics. It is the hollow one. You have heard that hollowness before: it was the stopped pipe of Part 2, and for the same reason. A was a sawtooth, with every harmonic: brighter, and buzzier.

2From a recipe to a machinePractice3 min

How does a computer find the recipe?

A computer does not have a formula for a sound. It has a list of numbers: the pressure, measured forty-eight thousand times a second. Fourier's recipe still works. Take a stretch of N samples. For each frequency that fits a whole number of times into the stretch, multiply the samples by a wave of that frequency and add up. What comes out is the amount of each frequency: here, a lot of the third and half as much of the seventh. This is the discrete Fourier transform. It has one problem. N frequencies, N samples each: N squared multiplications. One second of sound would take two billion.

The way out was published in 1965 by James Cooley and John Tukey, and it changed what could be computed. Split the samples into the even-numbered ones and the odd-numbered ones. Each half is a transform of half the size. Combine the two answers with a handful of multiplications, and you have the whole. Then do the same to each half, and each quarter, all the way down. The cost falls from N squared to N times the logarithm of N. For a million samples that is ten million multiplications where there were a million million. We wrote both. On this machine, for four thousand samples, the fast one is times quicker, and it gives the same numbers. Every spectrum in this series, and in every recording studio, phone and streaming service, comes from this algorithm.

Here is the machine at work on the plucked string of Part 1. A third of a second of sound goes in. Out come eight thousand numbers, one for every three hertz. And there are the partials we computed by hand in Part 1: a row of sharp peaks at whole multiples of a hundred and thirty-one hertz, with almost nothing between them. A picture like this, strength against frequency, is called a spectrum.

One worked example, because it leads straight to this part's deepest point. Two low notes, a semitone apart: a hundred and ten hertz and a hundred and sixteen and a half. A stretch T seconds long gives one number every one over T hertz. How long a stretch do you need for these two notes to be at least one bin apart? This is a bin-spacing estimate, not a general resolution guarantee. Pause and work it out.

For this bin-spacing criterion, the bins must be no wider than the gap, six and a half hertz, so the stretch must be at least seconds long. And a bass player can change notes faster than that. Actual peak resolution also depends on the window, relative levels and noise. A long analysis window blurs when things happened. Hold on to that. We will come back to it in chapter seven.

3What the ear does with itFoundations4 min

Does the ear take sounds apart too?

So a sound can be taken apart into pure tones on paper, and in a computer. Does the ear do the same? In 1843 Georg Ohm, the Ohm of the electrical law, proposed that it does: you hear a tone of a given pitch exactly when the sound contains the pure tone of that frequency. Twenty years later Hermann von Helmholtz found a way to test it. He had glass globes blown, each with a wide mouth and a narrow nipple to fit in the ear. Each globe is the bottle of Part 2: a mass of air on a spring of air, with one note of its own. Hold one to your ear while a note sounds. If the note contains the globe's frequency, the globe sings. If not, it stays silent.

We can run Helmholtz's experiment on our own string. Ten resonators, tuned to one, two, three, up to ten times the string's frequency. Pluck the string and measure how strongly each one rings. They all ring, the low ones most. Those are the string's partials, found without any mathematics at all: only by resonance. The white dots are the same partials from the transform of the last chapter. On the strong partials the two agree within decibels. A row of resonators is a Fourier analyser.

And you can hear what Helmholtz heard. First the string. Then the same pluck through the resonator tuned to its third partial. Then through the fifth.

A G, and an E, inside a C. With these globes Helmholtz catalogued the partials of voices, violins, pipes and pianos, and concluded that Ohm was right: the ear is a row of resonators, and the quality of a sound, what tells a flute from a violin, is its recipe of partials.

A worked example, to connect this with Part 2. A clarinet plays its lowest note, a hundred and forty-seven hertz. Six of Helmholtz's globes stand ready, tuned to one, two, three, four, five and six times that. Which of them sing? Pause, and remember what kind of pipe a clarinet is.

In the ideal stopped-pipe approximation, odd partials dominate the clarinet's low register. A real clarinet can also have even partials. In our ideal example the first, third and fifth globes sing, and the second, fourth and sixth stay nearly silent. That silence is what makes a clarinet's low notes sound hollow, and Helmholtz found it with exactly this apparatus.

It is a beautiful theory, and both halves of it are too simple. Even before Helmholtz, August Seebeck had built a siren that produced a tone with almost none of its lowest partial, and people heard the low pitch anyway. Ohm called that an illusion, and the argument ran for a century. We will settle it in Part 4. The second half, that the recipe is the whole of a sound's quality, we can test ourselves, before this part is over. First, though, there is something the recipe has been leaving out all along.

4The other half of the recipeFoundations3 min

Does it matter where each sine starts?

Every sine in Fourier's sum needs two numbers, and so far we have drawn only one. The first is how much of it there is. The second is where in its swing it starts: its phase. A magnitude spectrum shows the amounts and leaves out the phases. The full complex spectrum keeps both. Does that matter? Here are two waves built from exactly the same partials in exactly the same amounts. In the first, every partial starts at its crest, and they pile up into one sharp spike in each cycle. In the second, each partial starts at a random point, and the wave looks like noise. Their spectra are identical. Ohm's law says your ear will not care: same amounts, same sound.

Test it. First on a high note, the C above middle C, with seven partials. Wave A, then wave B.

You may hear little difference here: resolved steady partials are often relatively insensitive to phase. Two waves that look nothing alike, and the ear reports one sound. This is why a spectrum is such a useful picture: it keeps what you hear and drops what you mostly do not.

Now a question for your ears. The same test, three octaves lower, with sixty partials. Same amounts, different phases. Do A and B sound the same?

No. A has a hard buzz to it; B is smoother and breathier. Same spectrum, different sound. So Ohm's law has a limit, and it is our first piece of evidence that the list of amounts is not everything.

Why the difference? Think of Helmholtz's resonators. On the high note the partials are far apart. Each of the ear's resonators catches one of them, alone, and one sine wave sounds the same wherever it starts. On the low note the partials are sixty-five hertz apart, and the ear's resonators are not that fine. Several partials land in the same one, and it hears how they add up inside each cycle: a spike, or a smear. This is one important route to phase sensitivity: partials sharing an auditory filter produce different envelopes. Onsets and other conditions can also matter. How fine the ear's resonators are is a measurement, and it is the heart of Part 4.

5Time and frequency togetherFoundations2 min

How do you watch a recipe change?

A magnitude spectrum of the whole Tune would tell you which notes are in it, and nothing about their order. Music is change, and we want to see the recipe changing. So take a short stretch of the sound, a few hundredths of a second, and find its spectrum. Stand that spectrum up as a column: frequency upward, brightness for strength. Slide the stretch along a little and do it again, and again. The columns side by side make a picture of sound: time across, frequency up. It is called a spectrogram, and since the nineteen forties, when Bell Laboratories built a machine to draw one, it has been the standard way to look at sound.

Here it is, with the sound. Learn to read it, because we will use it in every part from here on. A level stripe is one partial of one note. Each note is a stack of stripes, evenly spaced: its harmonics. A sharp left edge is a pluck: the instant the note begins. And the stripes fade from the top downward, because, as we found in Part 1, a string's high partials die first. One check before we rely on it: our own transform and the standard library's agree to the last decimal place.

A spectrogram earns its keep when the pitch moves. Here is the horn from Part 2, driving past. Four stripes, its four partials, level while it approaches, sliding down as it passes, level again as it leaves. And notice that the stripes stay evenly spaced the whole way: each partial falls by the same ratio, so the horn keeps its character while its pitch drops. Watch it and listen.

6What a window costsPractice2 min

What happens at the edges of the stretch?

There is a catch in cutting a stretch out of a sound, and every picture of a spectrum is shaped by it. The transform treats the stretch as if it repeated for ever. If a tone fits a whole number of cycles into the stretch, fine: one tone, one bar. But a real tone has no reason to fit. Give it five and a half cycles, and the end does not join up with the beginning. The transform sees a jump there, and a jump, as Fourier and Gibbs taught us, needs every frequency. One pure tone has spilled into all the bins. This is called leakage.

The cure is to fade the stretch in and out, so that there is no jump at its ends. The shape of the fade is called a window. With no fade at all, the spill is only thirteen decibels down next door, and it falls away slowly. With a smooth hump, named after the meteorologist von Hann, the worst spill is thirty-one decibels down and it drops fast. A slightly fancier hump, Blackman's, gets to fifty-eight. But look at what it costs. The better the window hides the spill, the wider the peak itself: two bins, four, six. You are trading sharpness for cleanliness, and these numbers match the standard tables to a tenth of a decibel.

Here is why it matters. A strong tone, and a second tone seven bins away and two hundred times smaller in amplitude. That is an ordinary situation: the fifth partial of a note is often that much weaker than the first. With no fade, the strong tone's spill is louder than the weak tone, and the weak one is simply not in the picture. With a Hann window, there it is. So a finite-window spectrum is shaped by the analysis. We see the spectrum through a particular window, and the choice of window decides what you can see. Every spectrum in this series uses a Hann window unless it says otherwise.

7The limitPractice4 min

Can you know exactly when, and exactly what pitch?

In chapter two we found that telling two close notes apart takes a long stretch of sound. Here is the other side of that. One short test sound: two clicks, three hundredths of a second apart, and then two steady tones, forty hertz apart. Analyse it in short stretches. The two clicks stand apart cleanly, but the two tones have merged into one thick band. Analyse it in long stretches. Now the two tones are two sharp lines, and the clicks have smeared into one. No choice of stretch shows both. That is not a weakness of our method. It is a fact about waves.

The reason is almost embarrassingly simple. Here are two tones, one making ten cycles a second and one making eleven, drawn so that we can count. Look at the first tenth of a second. They are nearly in step. A short-window spectrum cannot show them as two narrow peaks. For a rough Fourier resolution scale, wait until one has pulled a whole cycle ahead of the other, and that takes a full second. To tell apart two tones one hertz apart, a Fourier window needs roughly a second. Model-based estimates can do better under suitable assumptions. Ten hertz apart, a tenth of a second. A frequency is a count of cycles, and counting takes time.

Dennis Gabor wrote the law down in 1946. Measure the standard deviations of a normalized energy envelope in time and of its Fourier energy in frequency. Their product can never be smaller than one over four pi. A sound can be short, or it can be narrow in frequency. It cannot be both. The mathematics is the same as Heisenberg's uncertainty principle in quantum mechanics, and for the same reason: both are statements about waves. We measured the product for four shapes. A smooth bell curve sits exactly on the limit, and nothing can beat it. The Hann window is within three percent. Ideal rectangular and abruptly starting envelopes have infinite rms bandwidth. These finite sampled estimates depend on the sample rate.

You can hear the limit. Take one tone, the A an orchestra tunes to, and make it shorter and shorter. At a fifth of a second it is plainly a note. At a twentieth it is still a note, though its frequency is already smeared over most of a semitone. At twelve thousandths of a second, five cycles, the smear is three semitones wide. At three thousandths it covers an octave. Each one twice.

The note turned into a click. Nothing was done to it except to make it short. A click is what a tone becomes when there is no time for it to have a pitch.

A question for your ears. Two pairs of very short tones. In one pair, the two are the same note. In the other they are a semitone apart. Which pair is the semitone?

It was , and if you could not tell, that is the limit at work: at five thousandths of a second each tone is smeared over far more than a semitone. Here is the same question with tones twenty-four times longer.

Easy. So this limit runs through music. A short noisy drum stroke concentrates energy in time. A held organ note has narrow partials, even though its onset can still be clear. And it is why fast passages low in the bass turn to mud: a short fixed window spreads their nearby partials together. This spread limit does not forbid model-based frequency estimates or adaptive analyses.

8A ruler for musicPractice2 min

Why should every bin be the same width?

The transform has one more awkwardness, and this one is about music in particular. Its bins are equally spaced in hertz. Musical notes are not. Each octave is a doubling, so the octave from the lowest C here to the next is sixty-five hertz wide, and the octave four above it is a thousand hertz wide. Equal bins give the bottom octave almost nothing and waste hundreds on the top. The remedy is a ruler marked the way a keyboard is: equal steps in ratio. Make each bin a fixed fraction of its own frequency. Q is the frequency divided by that bin width, and a transform built this way is a constant-Q transform. It pays for its fine low bins with time, as Gabor says it must: the lowest bin here listens for milliseconds, the highest for .

Here is the Tune's opening both ways. On the left, equal bins: the notes are crushed into the bottom of the picture, and the stack of stripes above each note is spaced differently for every pitch. On the right, constant Q. The notes step up and down by even amounts, like a piano roll. And every note now has the same pattern of stripes above it, only moved up or down.

That shifting is the point. On this ruler a melody moved to another key is the same picture, slid up or down, which is why many music recognition and transcription systems use a logarithmic pitch representation. Others use mel spectra or raw audio. It was worked out by Judith Brown in 1991, and the wavelets you may have heard of share the idea of scale-dependent resolution. There is a much older instrument that uses a ruler like this one, and it is inside your head. That is the next part.

9Sounds with no pitchFoundations3 min

What is the spectrum of a hiss?

Not every sound has partials. A hiss, a wave on a beach, the breath across the bottle in Part 2: these have no pitch, and their spectrum is not a row of peaks but a continuous spread. Such sounds are called noise, and they are named like colours. White noise has equal power in every hertz, so, within a finite band, its top octave holds roughly half the power, and it hisses. Pink noise has equal power in every octave: three decibels less per hertz for each octave you climb. To an ear, which counts in octaves, it sounds even. Brown noise falls twice as fast. It is a random walk, and it rumbles. Here are all three, set to the same loudness.

There is a trap in measuring noise, and it catches people every day. Take the spectrum of one short stretch of pink noise. It is a mess: spikes and holes, five or six decibels up and down from one bin to the next. That is not an error. The spectrum of noise is itself noise. The tidy slope only appears when you average the spectra of many stretches. A tone shows itself in one look. A noise has to be described by its average, and an analyser that claims to show you the spectrum of a hiss at a glance is averaging behind your back.

Noise is not the opposite of music. It is in every instrument: the breath in a flute's tone, the scrape at the start of a bowed note, the whole of a snare drum, and every consonant a singer pronounces. In a studio, pink noise is the standard signal for testing rooms and loudspeakers, because it loads every octave equally. And there is a stranger appearance. In 1975 Richard Voss and John Clarke measured how the loudness and the pitch of recorded music drift up and down over minutes, from Bach to ragtime to talk radio. The drift had a pink spectrum. Music, it seems, is neither as unpredictable as white noise nor as sluggish as brown. We will come back to that in Part 46.

10More than the spectrumFoundations2 min

Same recipe, same sound?

Now the second half of Helmholtz's claim: that the recipe of partials is the quality of a sound. Here is the test promised at the start. Take the plucked string of Part 1: a sudden start, a long fading tail. Now play the very same computed sound backwards. Running a sound backwards cannot change how much of each frequency is in it: a sine wave played backwards is the same sine wave. We checked: the two spectra agree to sixteen decimal places. If the recipe were everything, these two would sound alike. And a third version: the pluck with its first eighth of a second cut off and the rest faded in.

Three different instruments. The first is a plucked string. The second swells like something bowed, or an accordion, and ends with a snap. The third has lost whatever made it a pluck: it could be almost anything. The recipe barely changed. The sound did.

So what else is there? Measure the three sounds. Their overall brightness, the centre of gravity of the spectrum, is nearly the same. What differs is the attack: six thousandths of a second for the pluck, a hundred and seventy for the cut one, most of two seconds backwards. And within one note the recipe is not fixed at all. The pluck starts bright and its brightness slides down as the high partials die. A spectrum of the whole note averages that story away. In 1948 Pierre Schaeffer, working with disc recorders in a Paris radio studio, cut the attack off a recorded bell and found he had made an oboe. And in 1977 John Grey asked listeners to judge how alike instrument tones were. Their answers needed three axes: brightness, attack, and how the spectrum moves during the note. Timbre is a recipe that changes in time, and the first tenth of a second matters most. Synthesizer builders learned this the practical way: the first thing they gave every sound was a shape in time, an attack, a decay, a level to hold and a release. We will build that in Part 51.

11Frontier: sharper than the limitResearch2 min

Is Gabor's limit the last word?

Gabor's limit is a limit on a picture made by smearing a sound through one window. It is not a limit on what can be known, if you are willing to assume something. Each cell of a spectrogram holds the energy of a patch of time and frequency, and credits it to the centre of the patch. But two additional transforms tell you where inside the patch the energy really sits. Move it there, and the blurred sweep becomes a line, the click a sharp stroke. The method is called reassignment. On this test sound it packs the same energy into times fewer cells. It works best when a patch is dominated by one component; overlapping components can make its estimates ambiguous.

And there is an older device that does better than a spectrogram. In 2013 two physicists in New York asked listeners to judge two things at once about a short note: whether it came before or after another, and whether it was higher or lower. The comparison uses the scale set by Fourier uncertainty; perceptual discrimination thresholds are a different quantity from the energy spreads in that theorem. Most of the listeners could. The best, a professional musician, beat the limit by a factor of . No law of mathematics was broken. The Fourier spread product still holds for the waveform. It is not a universal bound on estimation or discrimination; the ear uses nonlinear processing, and it has had a very long time to learn what sounds are like. What it actually does is the subject of the next part.

This is a live field. Sharper pictures of sound are still being invented. The machines that listen to music, which we build at the end of this series, have to choose what picture to start from, and the choice is not settled. Nor is the question of how much of an instrument's character a handful of numbers can hold. The research problem for this part is to combine two of this part's ideas.

Variation 3, recap and problemsAll tracks4 min

Every part ends by doing something to the Tune with what it has built. This part built a way of taking sounds apart, so the Variation puts one together. Each note is a sum of pure tones, with the amounts and the decays of the plucked string. But the first phrase is allowed only one partial: plain sine waves. The second phrase gets two. Then three, five, eight and sixteen. Listen to a string come into being.

Row three of the ledger. seconds, and by the last phrase the sound is times as bright, for its pitch, as it was in the first. Sixty-five rows to go.

What did we find? Fourier was right: periodic waves can be represented by harmonic sines and cosines, with coefficients found by projection. A computer does it for samples, and since 1965 does it fast. A row of resonators does the same job, and the ear behaves like one, often relatively insensitive to phase for resolved steady partials. To watch a recipe change you need a window, and the window shapes what you see. There is a hard limit on simultaneous Fourier energy concentration in time and frequency, not on every possible inference. And the recipe is not the whole sound: timbre lives in how the recipe changes, most of all at the start.

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? The spectrogram is in almost every part from here on. Resonators and phase are the starting point of Part 4, on the ear. Brightness and attack return when we orchestrate, and when we build synthesizers. The fast transform and its windows are the foundation of digital audio and of every audio codec. And constant Q is how our listening machines will see.

And in practice. A mixing engineer reads a spectrum analyser all day, and should know its window and its bin width before believing it. Audio programmers live with the trade between resolution and delay. Sound designers know that the attack decides what an instrument is, and build new ones by swapping attacks and tails. And most machines that listen take one of this part's pictures as input.

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

One last sound, because this part's picture has a hole in it. Here is a tone with eight partials. Then the same tone with its lowest three partials taken out, so that there is no energy at all at the frequency of the note. Then that lowest partial by itself.

The second tone has nothing at the bottom, and yet its pitch did not move. It is the same note as the first and the third. This is what Seebeck's siren did, and Ohm's law cannot explain it. A spectrum says what is in the air. It does not say what you hear. For that we have to open the instrument that does the listening. That is Part 4: The Ear.

Where it goes next. The spectrogram is in almost every later part. Resonators, phase and the tone with no fundamental open Part 4, on the ear. Brightness, attack and flux return in consonance (Part 5), orchestration (Part 41) and synthesis (Parts 51, 52). The fast transform, windows and overlap-add are the basis of digital audio (Part 48), effects (Parts 49, 50) and codecs (Part 58); constant Q is the input of the listening machines of Parts 61 and 62.

Key results

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

Fourier's recipe\(\displaystyle b_n = \frac{2}{T}\int_0^T f(t)\,\sin\frac{2\pi n t}{T}\,dt\)
The discrete Fourier transform\(\displaystyle X[k] = \sum_{n=0}^{N-1} x[n]\,e^{-2\pi i k n / N}\)
The Gibbs overshoot\(\displaystyle \approx 8.95\%\ \text{of }\allowbreak \text{the }\allowbreak \text{jump, }\allowbreak \text{for }\allowbreak \text{any }\allowbreak \text{number }\allowbreak \text{of }\allowbreak \text{terms}\)
Gabor's limit\(\displaystyle \Delta t \cdot \Delta f \ge \frac{1}{4\pi}\)
Constant Q\(\displaystyle Q = \frac{f}{\Delta f} = \frac{1}{2^{1/b} - 1}\quad\allowbreak (b\ \text{bins }\allowbreak \text{per }\allowbreak \text{octave})\)
Noise colours\(\displaystyle S(f) \propto f^{-\beta}:\ \beta = 0\ \text{white},\ 1\ \text{pink},\ 2\ \text{brown}\)

Try it

Lab 3 · Taking sound apart: the fast transform, and Gabor's limit

Check a hand-written FFT against the definition and count its multiplications; measure how long and how wide a pulse is, and see that the product never falls below 1/(4 pi).

Figure produced by Lab 3: Taking sound apart: the fast transform, and Gabor's limit
Produced by the lab below, seed 0, in 0.3 s.
python -m videos.music.labs 3 needs numpy, scipy, matplotlib · download lab03.py · source on GitHub
samples                                              2048
multiplications, definition                          4,194,304
multiplications, fast                                11,264   (N/2 log2 N = 11,264)
largest difference between them                      3.7e-13
shape                                                gauss, width 4.0 ms
duration (std dev)                                   2.83 ms
bandwidth (std dev)                                  28.1 Hz
product                                              0.0796   (1.00 times 1/(4 pi) = 0.0796)
ear problem, the order (listen first)                sawtooth, 4 harmonics; sawtooth, 16 harmonics; square, 16 harmonics (odd only)
  brightness of the sawtooth, 4 harmonics            287 Hz
  brightness of the sawtooth, 16 harmonics           418 Hz
  brightness of the square, 16 harmonics (odd only)  330 Hz

The fast transform gives the definition's numbers with N/2 log2 N multiplications instead of N squared. A pulse cannot be both short and narrow in frequency: a Gaussian sits exactly on Gabor's limit.
The code (95 lines; it asserts its own result)
"""Lab 3: a fast Fourier transform against the definition, the uncertainty product of a shape, and three tones for the ear."""

import math

import numpy as np

from videos.coursekit import labs
from explainer.music.monochord import Clip, concat
from explainer.music.monochord.dsp import fourier as F

TITLE = "Taking sound apart: the fast transform, and Gabor's limit"
GOAL = ("Check a hand-written FFT against the definition and count its multiplications; measure how long and how "
        "wide a pulse is, and see that the product never falls below 1/(4 pi).")
TASKS = [
    "Change SHAPE to 'rect'. What happens to the product, and why does it depend on the sample rate?",
    "Halve WIDTH. What happens to the duration, the bandwidth, and the product?",
    "Analyse a tone at bin 100.5 with window 'rect' and with 'hann' (F.leakage shows the lobes). How far down is the spill 5 bins away?",
]
SHAPE = "gauss"
WIDTH = 0.004      # seconds
SR = 48_000


def run(seed=0):
    rng = np.random.default_rng(seed)
    lab = labs.Lab()

    # 1. the fast transform is the slow one
    n = int(2 ** rng.integers(8, 12))
    x = rng.standard_normal(n)
    count = [0]
    fast, slow = F.fft(x, count), F.dft(x)
    err = float(np.abs(fast - slow).max() / np.abs(slow).max())
    lab.row("samples", f"{n}")
    lab.row("multiplications, definition", f"{n * n:,}")
    lab.row("multiplications, fast", f"{count[0]:,}   (N/2 log2 N = {n // 2 * int(math.log2(n)):,})")
    lab.row("largest difference between them", f"{err:.1e}")
    assert err < 1e-9 and count[0] == n // 2 * int(math.log2(n))

    # 2. how long, how wide
    t = (np.arange(8192) - 4096) / SR
    if SHAPE == "gauss":
        pulse = np.exp(-0.5 * (t / WIDTH) ** 2)
    elif SHAPE == "rect":
        pulse = (np.abs(t) < WIDTH).astype(float)
    else:
        m = int(2 * WIDTH * SR)
        pulse = np.zeros(8192)
        pulse[4096 - m: 4096 + m] = F.window(SHAPE, 2 * m)
    dt, df = F.spreads(pulse, SR)
    floor = 1 / (4 * math.pi)
    lab.row("shape", f"{SHAPE}, width {1000 * WIDTH:.1f} ms")
    lab.row("duration (std dev)", f"{1000 * dt:.2f} ms")
    lab.row("bandwidth (std dev)", f"{df:.1f} Hz")
    lab.row("product", f"{dt * df:.4f}   ({dt * df / floor:.2f} times 1/(4 pi) = {floor:.4f})")
    assert dt * df >= floor * 0.999, "nothing beats the limit"

    # 3. three tones on one note (Problem 3): a dull sawtooth, a bright one, a square
    f0 = 196.0
    recipes = {"sawtooth, 4 harmonics": [1 / k for k in range(1, 5)],
               "sawtooth, 16 harmonics": [1 / k for k in range(1, 17)],
               "square, 16 harmonics (odd only)": [1 / k if k % 2 else 0.0 for k in range(1, 17)]}
    names = list(recipes)
    order = rng.permutation(3)
    tones = {k: F.additive(f0, a, 1.3, SR) for k, a in recipes.items()}
    lab.audio = concat([Clip(tones[names[j]]).fade(0.01, 0.08).at_level(-18.0) for j in order], gap=0.4)
    lab.row("ear problem, the order (listen first)", "; ".join(names[j] for j in order))
    for k in names:
        lab.row(f"  brightness of the {k}", f"{F.centroid(tones[k][4800:], SR):.0f} Hz")

    fig, (a, b) = labs.figure(2)
    spec = np.abs(fast[: n // 2])
    a.plot(np.arange(n // 2), 20 * np.log10(np.maximum(spec / spec.max(), 1e-6)), color=labs.BLUE, lw=1.0)
    a.set_title("A stretch of noise, by the fast transform")
    a.set_xlabel("frequency bin")
    a.set_ylabel("level (dB)")
    widths = np.array([0.5, 1, 2, 4, 8]) * 1e-3
    prods = []
    for w in widths:
        g = np.exp(-0.5 * (t / w) ** 2)
        d1, d2 = F.spreads(g, SR)
        prods.append((1000 * d1, d2))
    prods = np.array(prods)
    b.loglog(prods[:, 0], prods[:, 1], "o-", color=labs.GOLD, label="Gaussian pulses")
    b.loglog([1000 * dt], [df], "s", color=labs.RED, label=f"this lab's {SHAPE}")
    xs = np.array([0.2, 10.0])
    b.loglog(xs, floor / (xs / 1000), "--", color=labs.BLUE, label="the limit: dt df = 1/(4 pi)")
    b.set_title("Duration against bandwidth")
    b.set_xlabel("duration (ms)")
    b.set_ylabel("bandwidth (Hz)")
    b.legend()
    lab.fig = fig
    lab.note = ("The fast transform gives the definition's numbers with N/2 log2 N multiplications instead of N squared. "
                "A pulse cannot be both short and narrow in frequency: a Gaussian sits exactly on Gabor's limit.")
    return lab

Now change it

  1. Change SHAPE to 'rect'. What happens to the product, and why does it depend on the sample rate?
  2. Halve WIDTH. What happens to the duration, the bandwidth, and the product?
  3. Analyse a tone at bin 100.5 with window 'rect' and with 'hann' (F.leakage shows the lobes). How far down is the spill 5 bins away?

Problems, with solutions

Try each problem before opening its solution.

  1. A sawtooth. Find the Fourier coefficients of a sawtooth wave by Fourier's recipe. Which is the first harmonic more than 40 dB below the fundamental? Compare with a square wave.

    Solution

    Take the sawtooth f(x) = (π − x)/2 on (0, 2π). Then bₙ = (1/π) ∫₀^{2π} f(x) sin nx dx = 1/n, by one integration by parts: every harmonic is present and falls as 1/n. Forty decibels is a factor of 100 in amplitude, so the first harmonic more than 40 dB down is the 101st. A square wave also falls as 1/n but has only odd harmonics; its 101st is likewise the first beyond 40 dB. (Both are slow: a corner in the wave's slope, as in the triangle wave or the plucked string of Part 1, gives 1/n², and reaches 40 dB at n = 11.)

  2. Backwards. Show that playing a signal backwards replaces its transform X[k] by its complex conjugate (times a phase ramp), so that no magnitude changes. What happens to the phases?

    Solution

    Let y[n] = x[N − 1 − n] for real x. Then Y[k] = Σ x[N−1−n] e^{−2πikn/N} = Σ x[m] e^{−2πik(N−1−m)/N} = e^{2πik/N} Σ x[m] e^{+2πikm/N} = e^{2πik/N} X[k]*. The factor in front has modulus one, so |Y[k]| = |X[k]|. Every phase changes sign (and gains the same linear ramp, which is only a shift in time). A spectrum that shows magnitudes cannot tell a sound from its reversal; the ear can, because the order of events in time is carried by the phases.

  3. Ear. The lab (python -m videos.music.labs 3) plays three tones on one note. Put them in order of brightness, and say which one has only odd harmonics.

    Solution

    The three are a sawtooth with 4 harmonics, a sawtooth with 16, and a square wave with 16 (odd only), in an order the lab prints after you have listened. Brightness follows the spectral centroid, which the lab also prints: the 4-harmonic tone is the dullest; the square is the hollow one, like the stopped pipe of Part 2.

  4. Build. Write the inverse of fourier.stft by overlap and add, and show that a Hann window with a hop of a quarter gives back the sound exactly.

    Solution

    Solution sketch. Inverse-transform each column, multiply it by the window again, and add it into the output at its place; divide by the sum of the squared windows at each sample. With the periodic Hann window and a hop of N/4, Σ w²(n − mH) = 3/2 for every n (the squared Hann window is 3/8 − ½cos + ⅛cos 2·, and the cosines cancel over four hops), so the division is by a constant and the reconstruction is exact to rounding (about 10⁻¹⁶) away from the first and last window. This is the engine of every phase vocoder, spectral effect and audio codec in Parts 50 and 58.

  5. ★ Research. Build a reassigned constant-Q transform, and measure how accurately it finds the onsets and pitches of Monochord's notes against an ordinary one.

    Pointers. Reassignment needs, for each constant-Q kernel, the same kernel multiplied by time and its derivative; see Auger and Flandrin (1995) for the general operators and Holighaus et al. (2013) for an invertible constant-Q framework. Score onsets by the F-measure within 50 ms and pitches by raw pitch accuracy, as in the MIREX evaluations; Monochord's notes give exact ground truth. Open questions: how reassignment behaves where partials of different notes share a bin, and whether a learned front end (Parts 61 to 64) ends up computing something similar.

Notes and sources

Sources

Books: W. M. Hartmann, Signals, Sound, and Sensation (1997); M. Müller, Fundamentals of Music Processing (2nd ed., 2021), ch. 2; J. O. Smith, Mathematics of the Discrete Fourier Transform (2nd ed., 2007); H. von Helmholtz, On the Sensations of Tone (1863; tr. Ellis), ch. 2–4; I. Grattan-Guinness, Joseph Fourier, 1768–1830 (1972), for the memoir of 1807 and its examiners (Lagrange, Laplace, Monge, Lacroix).

Papers: J. Fourier, Théorie analytique de la chaleur (1822); G. S. Ohm, "Über die Definition des Tones", Annalen der Physik 59 (1843); A. Seebeck, Annalen der Physik 53 (1841) and 60 (1843); H. Wilbraham (1848) and J. W. Gibbs, Nature 59 (1899), for the overshoot; J. W. Cooley and J. W. Tukey, "An algorithm for the machine calculation of complex Fourier series", Mathematics of Computation 19 (1965) 297–301; M. T. Heideman, D. H. Johnson and C. S. Burrus, "Gauss and the history of the fast Fourier transform", IEEE ASSP Magazine 1 (1984); D. Gabor, "Theory of communication", Journal of the IEE 93 (1946) 429–457; W. Koenig, H. K. Dunn and L. Y. Lacy, "The sound spectrograph", JASA 18 (1946); F. J. Harris, "On the use of windows for harmonic analysis with the discrete Fourier transform", Proceedings of the IEEE 66 (1978) 51–83; J. C. Brown, "Calculation of a constant Q spectral transform", JASA 89 (1991) 425–434; R. F. Voss and J. Clarke, "1/f noise in music and speech", Nature 258 (1975) 317–318; J. M. Grey, "Multidimensional perceptual scaling of musical timbres", JASA 61 (1977) 1270–1277; P. Schaeffer, À la recherche d'une musique concrète (1952), for the cut bell of 1948; K. Kodera, C. de Villedary and R. Gendrin, Physics of the Earth and Planetary Interiors 12 (1976) 142–150, and IEEE Trans. ASSP 26 (1978); F. Auger and P. Flandrin, "Improving the readability of time-frequency and time-scale representations by the reassignment method", IEEE Trans. Signal Processing 43 (1995); J. N. Oppenheim and M. O. Magnasco, "Human time-frequency acuity beats the Fourier uncertainty principle", Physical Review Letters 110 (2013) 044301.

About this partfrom its README

Part 3 of a sixty-eight-part course in music (see the series plan and the syllabus). Parts 1 and 2 explained sounds by taking them apart into partials. This part makes that idea exact: how to find the recipe of any wave, how a computer does it, what the ear seems to do with it, how to watch a recipe change in time, the hard limit on doing so, and what the recipe leaves out. Every transform in it is Monochord's own (explainer/music/monochord/dsp/fourier.py), checked against numpy and scipy; every sound is computed in compute.py. Dates and attributions are the published ones, listed under Sources.

  • The Academy says no. A square wave assembled from 1, 2, 3, 5, 10 and 30 pure tones; Fourier's memoir of 1807 and Lagrange's objection (the quarrel of Part 1 again); three questions; the plan.
  • 1. A sum of sines. Why sines: the only shapes a resonant system leaves unchanged (a sine comes out a sine to 10⁻¹⁴; a square does not). The coefficients as averages of the wave times each sine, computed for a square (4/πn, odd n only); partial sums and their shrinking average error (Dirichlet, 1829); Gibbs's overshoot (8.95% of the jump, for ever); the transform of a sound that happens once (lines merging into a continuous spectrum); an ear question (square or sawtooth?).
  • 2. From a recipe to a machine. The discrete Fourier transform and its N² cost; Cooley and Tukey's fast algorithm (1965; Gauss, 1805), written out and timed (four thousand samples: 609 ms against 0.5 ms here), equal to numpy's to 15 places; the spectrum of Part 1's pluck; a worked example (what duration puts two notes a semitone apart at 110 Hz at least one DFT bin apart? 0.15 s; actual peak resolution also depends on the window, levels and noise).
  • 3. What the ear does with it. Ohm's law of hearing (1843); Helmholtz's resonators (1863), each a bottle from Part 2; ten resonators on our string against the transform (within 0.8 dB on the strong partials); the string heard through one resonator; a worked example (a clarinet and six globes); Seebeck's objection.
  • 4. The other half of the recipe. Phase; two waves with one spectrum; at C5 they sound alike, at C2 they do not (an ear question); why: the ear hears phase where it cannot separate the partials.
  • 5. Time and frequency together. The short-time transform, built up column by column on the Tune's opening; how to read a spectrogram; ours against scipy's (to 15 places); a horn passing (Part 2), its partials sliding down together.
  • 6. What a window costs. Leakage; rectangular, Hann and Blackman windows: side lobes of −13, −31 and −58 dB, main lobes of 2, 4 and 6 bins (Harris's table); a tone 46 dB down that only a window reveals.
  • 7. The limit. One sound through a short and a long window; why (count the cycles); Δt·Δf ≥ 1/4π for rms Fourier energy spreads (Gabor, 1946), measured for four shapes; a tone of 200, 50, 12 and 3 ms; an ear question (which pair is a semitone apart, at 5 ms and at 120 ms?).
  • 8. A ruler for music. Equal bins in hertz against equal steps in ratio; the constant-Q transform (Brown, 1991), Q = 34 at a quarter-tone per bin; the Tune's opening on both rulers.
  • 9. Sounds with no pitch. White, pink and brown noise (measured slopes 0.0, −3.0, −6.0 dB per octave); why a noise spectrum must be averaged; noise in instruments, studios, and (Voss and Clarke, 1975) in music's own fluctuations.
  • 10. More than the spectrum. One pluck forwards, backwards (the same magnitude spectrum to 16 places) and with its attack removed: three different instruments; attack, brightness and their change in time; Schaeffer's cut bell (1948), Grey's timbre space (1977).
  • 11. Frontier: sharper than the limit. Reassignment (Kodera et al., 1976; Auger and Flandrin, 1995): the same energy in 2.6 times fewer cells; listeners who beat the uncertainty limit (Oppenheim and Magnasco, 2013); what a listening machine should start from. ★ research problem.
  • Variation 3, recap and problems. The Tune assembled from pure tones, 1, 2, 3, 5, 8 and 16 partials phrase by phrase; the ledger; what we found; five problems; where it comes back; in practice; references; a tone with no fundamental, and Part 4.
What is computed and built

python -m videos.music.music3.compute (about a minute) fills .cache/music3/.

Item What it computes Checked against
square partial sums of a square wave; its coefficients by projection; the overshoot at 10, 100, 1,000 terms; a sine and a square through a resonator; pulse trains 4/πn; Gibbs's 8.95%
dft our FFT against numpy's; multiplication counts; timings; the pluck's spectrum (N/2) log₂N; partials at multiples of 130.8 Hz
ohm ten resonators on the plucked string each partial cut out of the full spectrum (0.8 dB)
phase harmonic complexes with crest and with random phases at C2 and C5 identical magnitudes (0.4 dB, 0.05 dB)
stft the spectrogram of the Tune's opening; a passing horn scipy.signal.stft (10⁻¹⁶)
windows main and side lobes of four windows; a weak tone beside a strong one Harris (1978), table 1
gabor Δt·Δf for a Gaussian, a Hann window, a decaying ring, a rectangle; tone bursts; one signal, two windows 1/4π (the Gaussian exactly)
cq a constant-Q transform of the Tune's opening each note in the bin of its pitch (7 of 7)
noise white, pink, brown: octave-band slopes; one frame against the mean of 351 0, −3.01, −6.02 dB per octave
timbre a pluck forwards, backwards, without its attack: spectra, attack time, centroid, flux reversal leaves every magnitude unchanged
reassign an ordinary and a reassigned spectrogram of a sweep, a click and a tone the ridge on the sweep's true frequency
tune Variation 3, additive; brightness and partial count of each phrase 1, 2, 3, 5, 8 partials counted from the sound
missing a tone of partials 4 to 8 no energy at the fundamental (−159 dB)

The transforms are held against numpy and scipy in tests/music/test_fourier.py; this part's claims and clips in tests/music/test_music3.py.

Sounds. Thirteen clips, labelled on screen. synthesized: sums of sines (the square wave, the phase pairs, the tone bursts, the noises, the Variation, the tone with no fundamental) and Part 2's passing horn. physical model: Part 1's plucked string, whole, through a resonator, backwards and with its attack removed. There are no recordings.

Two things the film simplifies. "The ear's resonators" in chapter 3 are a picture, made exact in Part 4 (critical bands). The claim that phase is often less audible for resolved steady partials in the high note is the standard result for well-separated partials (see Hartmann, ch. 6); it is not checked here by a listening test.

Companion material in this repository

The syllabus's plan for this partfrom SYLLABUS.md, the plan of record
  1. Hook: a square wave assembled from pure tones; Fourier, Lagrange and the Academy; three questions.
  2. A sum of sines: why sines; coefficients as averages; partial sums; Gibbs; the transform of a sound that happens once; an ear question.
  3. From a recipe to a machine: the DFT, the fast algorithm written out and timed, a pluck's spectrum; a worked example.
  4. What the ear does with it: Ohm's law, Helmholtz's resonators, a resonator bank on our string; Seebeck.
  5. The other half of the recipe: phase, heard at a low note and not at a high one.
  6. Time and frequency together: the spectrogram built column by column; how to read one; a gliding pitch.
  7. What a window costs: leakage, three windows against Harris's table, a weak tone revealed.
  8. The limit: one sound through two windows; counting cycles; Gabor's relation measured; tone bursts; an ear question.
  9. A ruler for music: constant Q; the Tune on both rulers.
  10. Sounds with no pitch: white, pink and brown noise; why noise spectra are averaged.
  11. More than the spectrum: one pluck forwards, backwards and without its attack; attack, brightness, flux.
  12. Frontier: reassignment; listeners who beat the uncertainty limit.
  13. Variation 3: the Tune assembled additively. Outro: problems, payoffs, and a tone with no fundamental.

Covers: Fourier series and transform; the DFT and the FFT; Ohm's acoustic law and Helmholtz's resonators; the short-time transform; windows and leakage; the Gabor limit; constant-Q and wavelets; phase and when it is audible; noise colors; attack, decay and spectral flux. Built and computed: an FFT, STFT and constant-Q transform checked against numpy and scipy.signal; the uncertainty product measured; a reassigned spectrogram. Variation 3: the Tune assembled additively, more partials in every phrase. Frontier: reassignment and superresolution; listeners who beat the Gabor limit (Oppenheim & Magnasco 2013). Reading: Hartmann; Müller ch. 2; Smith, Mathematics of the DFT.

Build the film

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

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

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