Signals and the FFT
How can you tell which frequencies are hiding inside a signal?
The intuition
Any signal, however messy, is a sum of simple sine waves. Think of a chord on a piano. Your ear hears one sound, but it is really several notes played together. The FFT is the tool that listens to a signal and lists the notes: which frequencies are in it, and how strong each one is.
To do that, the computer first needs numbers. It measures the signal at a steady pace, called the sample rate, fs. Here it takes 8000 samples every second. Then it grabs a block of N samples and runs the FFT on the block. This demo uses N = 1024.
The answer comes as a row of slots called bins. Each bin is one frequency, and the gap between neighbouring bins is the bin spacing, Δf. It is the sample rate divided by N. More samples in the block means finer bins, so you can tell two close frequencies apart. But more samples also take longer to collect. The capture time, T, is N divided by the sample rate. Δf and T trade off: a finer view costs more time.
There is also a ceiling. A signal sampled 8000 times a second can only show frequencies up to half that, 4,000 Hz. This is the Nyquist limit. A tone above it does not vanish. It folds back down and pretends to be a lower pitch. That is called aliasing, like a wagon wheel that seems to spin backwards on film.
One last catch. The FFT assumes your block repeats forever. If a tone does not fit a whole number of cycles into the block, the peak smears into its neighbours. That is leakage. A window, a gentle fade-in and fade-out applied to the block, tames it.
Try it
Two tones are on: 1000 Hz and 2000 Hz. Find them as two peaks in the spectrum. Then change N and watch the numbers. Type 1003 with the Rectangular window to see leakage, then switch windows. Type 5000 to see aliasing.
Build your signal
Analysis settings
What we found
Tones in the signal
Sample rate is fixed at 8000 Hz. Try typing 1003 with the Rectangular window: the tone falls between two bins, so the peak grows a messy skirt. Hann and Blackman clean up the skirt but make the peak a little fatter. Try 5000 to see a tone that is too fast show up at the wrong pitch.
Compare the signal over time with the frequencies the FFT finds.
Signal over time
Hidden frequencies
The maths
Bin spacing
The gap between two neighbouring frequencies in the result.
Where:
Capture time
How long it takes to collect the block. It is also 1 / Δf.
Where:
Nyquist limit
The highest frequency the samples can show. Anything above it aliases.
Where:
What this assumes
- The sample rate is fixed at 8000 Hz in the demo, and the tones are pure, steady sine waves.
- The strength is in dB, scaled so a tone of volume 1 sitting exactly on a bin reads 0 dB.
- The demo adds no noise. A real signal has some, which fills the floor of the plot.
Predict
If you double N, what happens to the bin spacing?
The takeaway
The FFT turns a block of samples into a list of the frequencies inside, and the block length sets how finely it can tell them apart.
Go deeper
Windows
Multiply the block by one of these shapes before the FFT. The rectangular window leaves the block alone. The others fade the ends to zero, which calms the leakage but makes each peak a little wider. Try them on the same tone above.
- Rectangular: the sharpest peak, but the messiest skirt
- Hann: a good all-rounder
- Blackman: the cleanest skirt, but the widest peak
Why it is called fast
Working out all N bins the long way takes about N × N steps. For N = 1,024 that is 1,048,576. The FFT reuses its work and needs only about N × log₂(N) steps, which is 10,240. That is about 102 times fewer, and the gap grows as N grows.
Where you meet it
Wi-Fi and 4G send their data on many close frequencies at once, a scheme called OFDM. The receiver pulls them apart with an FFT. See modulation for how bits get onto a carrier.