# The FFT and analysis windows

> Spectral leakage, windows (Hann, Hamming, Blackman, Blackman-Harris, flat-top) and their metrics — ENBW, scalloping, main lobe and side-lobes — how to pick the right window to analyse a spectrum.

Published: 2026-06-24
Updated: 2026-08-25
Practice: software
Standard: The FFT and analysis windows <https://en.wikipedia.org/wiki/Window_function>

Page: <https://www.stline.it/en/wiki/fft-window-explorer/>

---

The FFT turns a block of samples into a spectrum, but the result depends as much on the signal as on the **window** used to analyse it. Understanding *spectral leakage* and windows is the difference between reading a spectrum and misreading it. This tool shows the effect of windows on a test signal; this page explains what happens and why.

## The FFT and resolution

The FFT computes the Discrete Fourier Transform of N samples and returns N/2+1 frequency bins equally spaced between 0 and Fs/2 (Nyquist). The bin spacing — the **frequency resolution** — depends only on Fs and N:

$$
\Delta f = \dfrac{f_s}{N} \qquad\qquad X[k] = \sum_{n=0}^{N-1} x[n]\,e^{-j 2\pi k n / N}
$$

At a given Fs, more samples (large N) give finer bins and therefore the ability to tell apart closer lines. But N samples at rate Fs are N/Fs seconds of observation: resolution is bought with **measurement time**. There is no shortcut — it is a direct consequence of the transform, not a limitation of the algorithm.

## Spectral leakage

The FFT treats the N samples as one **period** repeating forever. If a sinusoid completes an integer number of cycles in the window, the repetition is seamless and the energy lands in a single bin. But if it does not — the normal case — a discontinuity appears at the edges of the block, and that discontinuity has spectral content at all frequencies: the line's energy spreads onto neighbouring bins. This is **spectral leakage**.

The practical consequence is serious: a strong line produces skirts that can **bury** a weak nearby line, even when their frequency spacing is well beyond the resolution Δf. Leakage is not noise — it is the signal itself, poorly localised.

## Windows and their trade-offs

An **analysis window** multiplies the N samples by a function that tapers smoothly to zero at the edges, cancelling the edge discontinuity. The price is an unavoidable compromise, fully described in the field's reference work — **F. J. Harris, "On the Use of Windows for Harmonic Analysis with the Discrete Fourier Transform" (Proc. IEEE, 1978)** — which tabulates and compares dozens of windows.

A window's spectrum has two parts: a **main lobe** (the line, widened) and the **side-lobes** (the residual skirts). The two trade off:

- a window with a **narrow lobe** resolves close lines but has **high side-lobes** → more leakage;
- a window with **low side-lobes** suppresses leakage but has a **wide lobe** → worse resolution.

The classic windows are sums of cosines; each extra term lowers the side-lobes at the cost of the lobe:

$$
w[n] = \sum_{k=0}^{K} (-1)^k\, a_k \cos\!\left(\dfrac{2\pi k n}{N}\right)
$$

- **Rectangular** (no window) — the narrowest lobe of all, but side-lobes at only −13 dB.
- **Hann / Hamming** — one cosine term: side-lobes at −31 / −43 dB, moderate lobe. The general compromise.
- **Blackman / Blackman-Harris** — two/three terms: side-lobes down to −92 dB, a markedly wider lobe.
- **Flat-top** — **five coefficients** (four cosine terms), optimised for amplitude: a very wide lobe, but almost no scalloping. Note a little-known property: this window **is not non-negative**. With the SRS/Matlab coefficients used here the minimum is −0.0706 and the first sample is −4.2·10⁻⁴, not zero — so the general description “goes smoothly to zero at the edges”, true for all the others, has to be corrected for the flat-top to “crosses zero and goes negative”.

## ENBW and scalloping

Two metrics summarise a window's behaviour beyond the lobe shape.

The **Equivalent Noise Bandwidth (ENBW)** is the width, in bins, of the ideal rectangular filter that passes the same noise power as the window. It measures how much noise each bin collects: high ENBW = worse signal-to-noise ratio for a line. It depends on the coefficients alone:

$$
\text{ENBW} = N \cdot \dfrac{\sum_{n} w_n^2}{\left(\sum_{n} w_n\right)^2}
$$

The rectangular window has ENBW = 1 bin (the minimum possible); softer windows rise (Hann ≈ 1.5, flat-top ≈ 3.8). It is the equivalent-noise-bandwidth price of suppressing leakage.

The **scalloping loss** is instead the worst-case amplitude error: a line falling exactly halfway between two bins is read attenuated (up to −3.9 dB for the rectangular). The **flat-top** is designed precisely to cancel it (scalloping ≈ 0 dB): that is why it is the window for calibrated amplitude measurement, even though its wide lobe makes it unsuited to resolving close lines.

### The windows compared

| Window | ENBW (bins) | Scalloping | 1st side-lobe | −3 dB lobe | −6 dB lobe |
|---|---|---|---|---|---|
| Rectangular | 1.000 | −3.92 dB | −13.3 dB | 0.88 bin | 1.20 bin |
| Hamming | 1.363 | −1.75 dB | −43.6 dB | 1.30 bin | 1.81 bin |
| Hann | 1.500 | −1.42 dB | −31.5 dB | 1.44 bin | 2.00 bin |
| Blackman | 1.727 | −1.10 dB | −58.1 dB | 1.64 bin | 2.30 bin |
| Blackman-Harris | 2.004 | −0.83 dB | −92.0 dB | 1.90 bin | 2.66 bin |
| Flat-top | 3.770 | −0.01 dB | −94.2 dB | 3.72 bin | 4.58 bin |

The lobe columns are the **total** width at the −3 and −6 dB levels, in bins: it is the direct measure of resolution, and it runs from the rectangular's 0.88 bin to the flat-top's 3.72. The rest of the table reads as the announced trade-off — lower side-lobes paid for with growing ENBW and lobe — with **one glaring exception**: Hamming has lower side-lobes *and* lower ENBW *and* a narrower lobe than Hann. It dominates on every metric in the table. So why is Hann half the world's default?

### The Hann/Hamming paradox: roll-off is what counts

Because the **first** side-lobe is not the whole story. What matters, when a weak line has to be seen, is the leakage level **at the distance where that line sits**, and the two windows behave in opposite ways as you move away:

| Window | 1st side-lobe | Beyond 10 bins | Beyond 50 bins | Beyond 200 bins | Slope |
|---|---|---|---|---|---|
| Rectangular | −13.3 dB | −30.4 dB | −44.0 dB | −55.4 dB | 5.9 dB/oct. |
| Hamming | −43.6 dB | −47.4 dB | −60.6 dB | −72.0 dB | 5.9 dB/oct. |
| Hann | −31.5 dB | −71.1 dB | −112.1 dB | −148.2 dB | 17.8 dB/oct. |
| Blackman | −58.1 dB | −78.9 dB | −119.5 dB | −155.5 dB | 17.8 dB/oct. |
| Blackman-Harris | −92.0 dB | −99.2 dB | −121.2 dB | −131.0 dB | 0.9 dB/oct. |
| Flat-top | −94.2 dB | −93.0 dB | −98.6 dB | −109.6 dB | 4.6 dB/oct. |

Hann starts worse (−31.5 dB) but **falls by 17.8 dB per octave**; Hamming starts better (−43.6) and falls by only 5.9. The crossover happens very early: **by 10 bins away Hann is already 24 dB better** (−71.1 against −47.4), and at 200 bins the gap is 76 dB. The reason is in the coefficients: Hann goes exactly to zero at the edges with zero derivative, Hamming stops at 0.08 and that residual step generates a tail decaying as 1/f.

So the correct criterion is not “which has the lowest first side-lobe” but “how far away is the line I want to see”: Hamming only wins in the immediate neighbourhood, Hann everywhere else in the spectrum. Blackman-Harris is a third case: an excellent first side-lobe (−92 dB) but almost no slope (0.9 dB/octave), because its four coefficients are optimized to **minimize the peak** side-lobe, not to make them decay. It is the right choice when a uniform floor is needed, not when depth far from the line is.

The flat-top remains the extreme case for amplitude: scalloping measured at **−0.01 dB** against the rectangular's −3.92, at the price of a 3.72-bin lobe that resolves nothing nearby.
## Periodic or symmetric: which convention

There is a detail from which differences between tools arise. An N-point window can be built with denominator **N** or **N − 1**:

- **periodic** (denominator N) — the window is one exact period of a periodic function: `w[0] = 0` but `w[N−1] ≠ 0`. This is the right convention for **FFT analysis**, because the DFT assumes precisely that the block repeats;
- **symmetric** (denominator N − 1) — the window is symmetric about its centre: `w[0] = w[N−1] = 0`. This is the right convention for **FIR filter design**, where the symmetry guarantees linear phase.

On a Hann at N = 16 the difference is visible by eye: the last sample is **0.0381** in the periodic version and **0** in the symmetric one. This tool uses **periodic**, consistent with its purpose. How much the choice weighs on the metrics:

| N | ENBW periodic | ENBW symmetric | Difference |
|---|---|---|---|
| 8 | 1.50000 | 1.71429 | +14.286 % |
| 16 | 1.50000 | 1.60000 | +6.667 % |
| 64 | 1.50000 | 1.52381 | +1.587 % |
| 256 | 1.50000 | 1.50588 | +0.392 % |
| 1024 | 1.50000 | 1.50147 | +0.098 % |
| 4096 | 1.50000 | 1.50037 | +0.024 % |

At N = 1024 the ENBW difference is a tenth of a percentage point: irrelevant. At N = 8 it is 14 %, that is decisive. The practical rule: for FFT blocks of normal size the two conventions are interchangeable, for short windows (filter banks, small-block analysis, precomputed tables on firmware) they are not — and that is the case where two different tools disagree and an afternoon goes into looking for the mistake somewhere else.

## When to use which window

- **Synchronous / transient signal** (integer number of cycles, or an impulse decaying within the window): **rectangular** — no leakage to correct, maximum resolution.
- **Generic analysis**: **Hann** or **Hamming** — the sensible default, contained leakage without giving up too much resolution.
- **Weak line next to a strong one** (high dynamic range): **Blackman-Harris** — very low side-lobes so the weak line is not lost under the strong one's skirts.
- **Precise amplitude measurement** of a line: **flat-top** — zero scalloping, the read amplitude is correct regardless of where the line falls relative to the bins.

## Limitations

- Radix-2 FFT: N must be a **power of 2**.
- Synthetic test signal (sinusoids + seeded Gaussian noise), not a real acquisition.
- Single-sided spectrum calibrated in peak amplitude (coherent-gain corrected); it is not a power spectral density estimate.
- Demonstrative tool, not a measurement-grade spectrum analyser.

## References

- **F. J. Harris, "On the Use of Windows for Harmonic Analysis with the Discrete Fourier Transform"**, Proceedings of the IEEE 66(1), 1978 — the classic reference on windows, ENBW, scalloping and side-lobes, with the comparative tables still used today.
- **Related tool** — the [FFT / Window Explorer](/en/tools/fft-window-explorer/) puts this page into practice: compose a signal, pick the window and read the spectrum and metrics.
