· SOFTWARE

Why your FFT spectrum lies: spectral leakage and windows

It comes up often, when a “wrong measurement” report lands on one of our spectral-analysis tools: the customer looks at the spectrum of a clean sine and complains that the peak isn’t where it should be, or that the read amplitude is lower than the generator’s known value. Almost always there’s no bug. There’s an FFT read without understanding what an FFT assumes — and the cause has a precise name: spectral leakage.

The FFT believes your signal is periodic

A discrete FFT doesn’t see an infinite sine: it sees the finite block of samples you hand it, and it assumes that block repeats identically forever. If the signal frequency falls exactly on a bin — that is, if an integer number of periods fits in the block — the assumption holds and the spectrum is clean: all the energy lands in a single bin.

In practice this almost never happens. The signal frequency is uncorrelated with the block length, the last period is cut off mid-cycle, and at the seam between one repetition and the next a discontinuity appears. That discontinuity isn’t free: the FFT represents it by smearing energy across all the neighbouring bins. That’s leakage. The peak is no longer a sharp line, but a hill with long skirts decaying slowly to either side.

What it actually breaks

Leakage isn’t a cosmetic detail. It produces two errors that matter in a real measurement:

  • Corrupted amplitude. The tone’s energy spreads across several bins, so the peak bin reads less than the true value. In the worst case — a frequency exactly halfway between two bins — the scallop-loss error reaches about 3.9 dB with the rectangular window. Nearly a factor of two in voltage, read as “instrument error”.
  • Masked weak tones. The leakage skirts of a strong tone swamp the bins where a weak nearby tone would live. This is the classic problem when chasing a harmonic distortion or an intermodulation product 60 dB below the carrier: the signal is there, but it drowns in the main tone’s skirts.

Windows: smoothing the seam

The fix is to not hand the FFT a sharply truncated block, but to first multiply it by a window that tapers gently to zero at the edges. Kill the discontinuity and the long leakage skirts go with it. It’s a trade, not a free lunch: softening the edges widens the main lobe, so you lose frequency resolution in exchange for lower side lobes.

Each window sits at a different point of this trade-off:

  • Hann — the reasonable default: fast-decaying skirts, a moderate main lobe. Good for the vast majority of broadband analysis.
  • Hamming — a lower first side lobe than Hann, but the far skirts decay more slowly. Useful when the disturbance is close in frequency.
  • Blackman — heavily suppressed skirts, a wide main lobe. For when you need to dig out a weak tone far from a strong one.
  • Flat-top — a deliberately wide, flat main lobe, so the amplitude read at the peak is accurate even when the tone falls between two bins. This is the right window when the number you need is the level, not the precise frequency: typically in calibration.

The reference taxonomy on all of this remains Harris’s 1978 work on windows for harmonic analysis: worth keeping at hand when picking a window for a specific case.

ENBW, the number everyone forgets

When you move from tone measurements to noise measurements — power spectral density, background levels — the window introduces a factor that must be stated explicitly: the ENBW (Equivalent Noise Bandwidth). A window doesn’t measure noise in a bin of width Δf, but in an effective band of ENBW · Δf. Forgetting this factor means getting the noise level wrong by an amount that depends on the window: for Hann the ENBW is about 1.5 bins. Comparing noise measurements made with different windows without normalising for ENBW means comparing numbers that aren’t comparable.

Before calling it a bug

An FFT spectrum is not a truth: it’s the result of a periodicity assumption and a window, and it lies to you in a predictable way if you ignore either. Faced with a wrong amplitude, two things are worth checking in order: which window is applied, and whether the tone falls on a bin or between two. To get hands-on with leakage, window choice and ENBW we put an interactive FFT / Window Explorer online; the physical model and the formulas are in the dedicated wiki.

Designing a spectral-analysis pipeline or calibrating a measurement chain and want the numbers to add up? Let’s talk.

← Back to blog

A technical project?

Hardware, firmware, software, acoustics: if you have a related use case, let’s talk.