Fourier synthesis explained

Joseph Fourier's discovery that every periodic signal is a sum of sine waves is one of the most useful ideas in science, and nowhere is it easier to hear than in music. This page explains what harmonics are, how the classic waveforms of synthesizers are built from them, why a square wave never quite loses its ripples, what makes a clarinet sound different from a violin, why the ear barely notices the phases of harmonics and can hear a fundamental that is not there, and how organs and synthesizers have used additive synthesis for more than a century.

An oscilloscope showing a sawtooth wave built from 16 harmonics, each harmonic in its own colour, above the bars of their amplitudes, their phase dials and a keyboard
An oscilloscope showing a sawtooth wave built from 16 harmonics, each harmonic in its own colour, above the bars of their amplitudes, their phase dials and a keyboard

Fourier's idea

In 1807 the French mathematician Joseph Fourier, studying how heat spreads through a metal bar, made a claim that his colleagues found hard to believe: any periodic function, even one with corners and jumps, can be written as a sum of sines and cosines. For a signal that repeats every T seconds the sum uses only the frequencies 1/T, 2/T, 3/T and so on, and the amount of each is found by multiplying the signal by that sine and averaging over one period. He published the theory in full in 1822. Today the same idea runs through acoustics, optics, quantum mechanics, image compression and every phone's radio.

Harmonics and the spectrum

A musical note that repeats f times a second is therefore a sum of a fundamental at f and harmonics at 2f, 3f, 4f and up, x(t) = Σ aₙ sin(2π n f t + φₙ). The amplitudes aₙ form the note's spectrum, and the phases φₙ say how the harmonics line up in time. A vibrating string or air column produces exactly these frequencies, because its standing waves fit a whole number of half wavelengths. Instruments whose overtones are not whole multiples, such as bells and drums, are not periodic and have no single harmonic series.

Building the classic waveforms

The waves of early synthesizers have neat Fourier series. A square wave, (4/π)(sin θ + sin 3θ/3 + sin 5θ/5 + …), has only odd harmonics, because its second half is its first half turned upside down. A sawtooth has all of them at 1/n, a triangle only the odd ones at 1/n², with alternating signs. How fast the amplitudes fall says how smooth a wave is: a jump gives 1/n, a corner 1/n², a smooth curve faster still. That is why a sawtooth sounds bright and buzzy and a triangle soft. A pulse wave that is high for a fraction d of each period has amplitudes proportional to sin(nπd)/n, so a 25 % pulse leaves out every fourth harmonic.

The Gibbs phenomenon

Cut a square wave's series off after a number of harmonics and the sum wiggles: next to every jump it overshoots, by about 9 % of the jump. Adding more harmonics squeezes the ripples closer to the jump but never makes the overshoot smaller; in the limit it is 8.95 %. The English mathematician Henry Wilbraham described it in 1848, but it was forgotten until the American physicist J. Willard Gibbs explained it in letters to Nature in 1898 and 1899, prompted by a letter from Albert Michelson, who had built a machine that added up Fourier series. The ringing shows up wherever high frequencies are cut off sharply: around edges in JPEG images, in brick-wall audio filters and in MRI scans.

Timbre: the fingerprint of a sound

Two instruments playing the same note have the same fundamental but different harmonics, and that difference is most of what we call timbre. A clarinet's bore is closed at the mouthpiece, so in its low register the even harmonics are weak and the sound is hollow and square-like; an oboe and a trumpet are strongest around their third and fourth harmonics; a bowed string is rich in all of them. Listeners judge a sound brighter the higher its spectral centroid, the harmonic numbers averaged with their amplitudes. Real instruments also change their spectrum during a note: the attack of a piano or the breath at the start of a flute note matters a great deal, which is why a steady mix of harmonics sounds more like an organ than like the instrument itself.

Phases and Ohm's acoustic law

In 1843 Georg Simon Ohm, of Ohm's law, proposed that the ear analyses a sound into its sine components and hears their strengths, not how they line up. Hermann von Helmholtz tested the idea in the 1860s with tuning forks and resonators and agreed: changing the phases of a steady tone's harmonics changes its waveform completely but its sound very little. Careful experiments find small exceptions, for low notes and for harmonics close together, but the rule holds well. The phases do matter for the peak of the wave: shuffling them changes the crest factor, the ratio of the peak to the RMS, which is why audio engineers choose phases to keep peaks low.

The missing fundamental

Play the harmonics 2f, 3f, 4f and up without f itself and you still hear the pitch f. The wave still repeats f times a second, and the brain picks out the common spacing of the harmonics, a residue pitch, as the Dutch physicist Jan Schouten showed around 1940. It is the reason a small speaker that cannot play 80 Hz still lets you hear a bass guitar's low notes, and why an old telephone line, which cut off everything below about 300 Hz, did not make men's voices sound higher. Organ builders used the trick for centuries: two pipes a fifth apart sound a deep note an octave below the lower one, a resultant bass.

From the Telharmonium to Web Audio

Additive synthesis is older than electronic music itself. Thaddeus Cahill's Telharmonium, patented in 1897 and played over telephone lines in New York from 1906, built tones from spinning dynamos, one per harmonic. Laurens Hammond's organ of 1935 did the same with small tonewheels: its nine drawbars, marked 16', 5⅓', 8', 4', 2⅔', 2', 1⅗', 1⅓' and 1', are the harmonics 1, 3, 2, 4, 6, 8, 10, 12 and 16 of the lowest, each in nine steps of loudness. Digital instruments such as the Synclavier and the Kawai K5 let musicians draw spectra of dozens of harmonics, and today every browser can do it: the Web Audio API's PeriodicWave, which this synthesizer uses, turns a list of harmonics into a sound. Fourier analysis, the reverse, is done billions of times a day by the fast Fourier transform.

Frequently asked questions

What is the difference between Fourier synthesis and Fourier analysis?

Synthesis builds a signal from its harmonics: you choose the amplitudes and phases and add the sine waves up, as an additive synthesizer does. Analysis goes the other way: it takes a signal and finds how much of each harmonic it contains, by multiplying it by each sine and averaging. In the app, setting the bars is synthesis and drawing a wave on the scope is analysis, done by a discrete Fourier transform of the 128 points of your drawing.

Why does a square wave have only odd harmonics?

Because its second half is its first half upside down: x(t + T/2) = −x(t). An even harmonic goes through a whole number of cycles in half a period, so it is the same in both halves and cannot change sign with the wave; only odd harmonics can. Any wave with this half-wave symmetry, such as a triangle wave or the low notes of a clarinet, has only odd harmonics, or nearly so.

How many harmonics does a sound need?

As many as fall within hearing, about 20 000 Hz. A note at 220 Hz has about 90 harmonics below that, a note at 2 000 Hz only ten. Sixteen harmonics already give a recognisable square or sawtooth for middle and high notes; for low notes more harmonics make the sound brighter and the edges sharper. The ear is less sensitive to the highest ones, which is why a series cut off at 16 still sounds close to the full wave.

What is the spectral centroid?

The centre of gravity of a spectrum: the frequencies of the harmonics averaged with their amplitudes as weights. It is a good measure of how bright a sound seems. A pure sine has its centroid at the fundamental, a sawtooth of 16 harmonics at about 4.7 times the fundamental, a triangle at about 1.7 times; the app shows it as a multiple of the fundamental and in hertz.

Ready to try it?

Open PictorX in your browser — no install, no credit card required to start.

Open the Fourier synthesizer