The Fast Fourier Transform: hearing the notes inside a sound
Inside music streaming, phone calls, Wi-Fi, music visualisers and every audio app that shows a spectrum
What problem does it solve?
How do you split a sound into its frequencies fast enough to do it thousands of times a second?
The big idea
The Fourier transform says any signal is a sum of spinning circles (sine waves) of different speeds. Measuring the amount of each of N frequencies the obvious way costs N × N multiplications. The FFT's aha is that the spinning circles are made of the same 'roots of unity', points equally spaced around Euler's circle. So you can split the samples into even and odd positions, transform each half, and combine them with a twist, then split those halves again, and again. The work drops from N² to N log₂ N.
How it works, step by step
- 1. Take N samples of the sound, with N a power of 2 (e.g. 1024).
- 2. Split them into even-numbered and odd-numbered samples.
- 3. Compute the FFT of each half (by splitting again, all the way down to single samples).
- 4. Combine: X_k = E_k + e^{−2πik/N}·O_k and X_{k+N/2} = E_k − e^{−2πik/N}·O_k, two answers per multiplication.
- 5. The sizes |X_k| tell you how loud each frequency is.
The key formula
- the n-th sample of the sound
- a point spinning around Euler's circle at speed k
- how much of frequency k is in the sound (a complex number: size and phase)
How fast is it?
For a million samples, N² ≈ 10¹² operations versus N log₂ N ≈ 2 × 10⁷, about 50,000 times faster. Honest note on music streaming: audio codecs like MP3, AAC and Vorbis (which Spotify has long used) store sound with the MDCT, a cosine-only Fourier cousin computed with FFT-style speedups, and use a 'psychoacoustic model' to throw away sounds your ear can't hear because louder nearby frequencies mask them.
Try it yourself
- Count the multiplications for N = 8: the obvious way is 64. The FFT needs 3 stages of 4 twists, so 12 (some are trivially ×1).
- Whistle a rising note into a spectrum app and watch one peak slide upward. Then sing 'ahh': why are there many peaks?
Fun fact
James Cooley and John Tukey published the FFT in 1965, partly motivated by detecting Soviet nuclear tests from seismic signals. Later, historians found that Carl Friedrich Gauss had used the same trick around 1805 to calculate asteroid orbits, but it was only published after his death.
Related
- Spinning circles (Fourier series) (interactive)
- The Core: Euler’s circle (interactive)
- Mix & Hear (waves and sound) (interactive)
- Shazam: turning songs into star maps
- JPEG: your photos are secretly made of waves