Load a pure 440 Hz sine wave in your DAW, open a spectrum analyzer set to rectangular window, and look closely at the bins around 440 Hz. You will see energy at 430 Hz, 450 Hz, 460 Hz, and beyond, even though the signal contains exactly one frequency. No nonlinearity. No harmonic content. Just an artifact of how the FFT works.
This is spectral leakage, and it is controlled by one parameter most spectrum analyzers expose without explanation: the window function.
The FFT's Silent Assumption
The Discrete Fourier Transform takes a finite block of N samples and computes which sinusoids sum to reproduce it. To do this, it implicitly assumes that block repeats forever. This periodicity assumption is the source of the problem.
If your 440 Hz sine happens to complete an exact integer number of cycles within the block, the assumption holds. The FFT is exact. But if the tone falls between two bins, the block captures a fractional number of cycles, and the assumed repetition introduces a sharp discontinuity at the frame boundary. That discontinuity is broadband. Its energy spreads across every frequency bin: spectral leakage.
The implicit window that creates this problem is the rectangular window: value 1 inside the frame, 0 outside. It is what every FFT uses unless you specify something else.
The Cost: -13 dB
The frequency response of the rectangular window has a main lobe at the target frequency and sidelobes, peaks of residual energy that extend across adjacent bins. The first sidelobe of the rectangular window is only 13 dB below the main lobe.
That is almost nothing. A 0 dBFS sine at 440 Hz will produce a visible "signal" at -13 dBFS two bins away. In a harmonic distortion measurement, a converter with genuinely no second harmonic would appear to have -13 dBFS THD just from the window. Beyond the first sidelobe, the rectangular window's sidelobes fall at 6 dB per octave. At 20 bins away from a 0 dBFS tone, the leakage is still around -36 dB.
Fredric J. Harris catalogued this in his 1978 IEEE Proceedings paper "On the Use of Windows for Harmonic Analysis with the Discrete Fourier Transform" (vol. 66, pp. 51-83), still the standard reference. His survey formalized the window performance metrics that DSP engineers use today: peak sidelobe level, sidelobe rolloff rate, main lobe width, and coherent gain.
Tapering to Zero
The fix is to multiply the frame by a function that tapers toward zero at both edges. If the sample values at the frame boundaries are near zero, the discontinuity at the assumed repetition point disappears. The cost is losing some information at the edges, which widens the main lobe in frequency.
This tradeoff between sidelobe level and main lobe width is unavoidable. It follows from the time-frequency uncertainty principle: a narrow window in time produces a wide response in frequency, and vice versa. Every window function is a choice about where to sit on that curve.
Julius von Hann and the Meteorologist's Accident
The most common taper is the Hann window, named after Julius von Hann (1839-1921), an Austrian meteorologist. Hann developed a weighted moving average for smoothing neighboring weather station readings, using weights of 1/4, 1/2, 1/4. He never worked on signal processing. Engineers later recognized that this smoothing operation had excellent frequency-domain properties and adopted it.
Because engineers used "hann" as a verb ("to hann the data"), the window acquired the misnomer "Hanning," which persists in older DSP literature, MATLAB, and NumPy. The correct name is Hann.
The Hann window is a raised cosine:
w[n] = 0.5 * (1 - cos(2*pi*n / (N-1)))
It goes to exactly zero at both endpoints. Its first sidelobe is at -31.5 dB, roughly 18 dB better than the rectangular window. More importantly, the sidelobes fall at 18 dB per octave rather than 6. At 20 bins away from a 0 dBFS tone, the leakage is around -88 dB: invisible for almost any practical purpose.
Richard Hamming's Optimization
Richard Hamming, at Bell Labs, noticed that the sidelobes of the rectangular window and the Hann window are approximately phase-reversed relative to each other. A weighted sum of the two should cause partial cancellation. He found the combination that minimized the peak sidelobe:
w[n] = 0.54 - 0.46 * cos(2*pi*n / (N-1))
The result is the Hamming window. At 0.54/0.46, the weights no longer sum to zero at the edges. The Hamming window has a floor of 0.08 at both boundaries. Hamming deliberately chose this because the cancellation effect it produces drops the peak sidelobe to approximately -42.76 dB, about 11 dB below the Hann case.
The tradeoff is that the Hamming window's sidelobes do not fall monotonically. They plateau at a floor around -42 dB instead of rolling off continuously. If a strong interfering signal is far away in frequency, the Hann window's -18 dB/octave rolloff wins. If the interferer is nearby, the Hamming window's lower peak sidelobe wins.
This also clarifies the naming confusion. Hann, Hanning, and Hamming are three distinct things: "Hann" is the correct name for the raised-cosine window; "Hanning" is an erroneous verb-derived form of the same thing; and "Hamming" is a different window entirely, designed by a different person for a different purpose.
Blackman-Harris: -92 dB
For precision measurement, neither the Hann nor Hamming window is sufficient. The Blackman-Harris family extends the approach by summing four cosine terms instead of two:
w[n] = a0 - a1*cos(2*pi*n/N) + a2*cos(4*pi*n/N) - a3*cos(6*pi*n/N)
The four-term minimum version uses coefficients a0=0.35875, a1=0.48829, a2=0.14128, a3=0.01168. The peak sidelobe drops to -92 dB, more than 60 dB better than the Hann window and 79 dB better than the rectangular window.
The cost is a main lobe roughly four bins wide. Two tones closer than four bins cannot be resolved as separate peaks. At a 4096-point FFT and 44100 Hz sample rate, one bin is about 10.8 Hz, so the Blackman-Harris window cannot distinguish two tones separated by less than 43 Hz. The Hann window, with a two-bin main lobe, resolves down to about 22 Hz at the same FFT size.
Spectrum analyzers that display wide dynamic range use Blackman-Harris precisely to avoid the situation where a -80 dBFS noise floor appears contaminated by leakage from a 0 dBFS fundamental sitting ten bins away.
The Kaiser Window: Continuous Control
The Kaiser window parameterizes the sidelobe-mainlobe tradeoff via a single scalar beta, using the zeroth-order modified Bessel function I0 internally. At beta=0 the Kaiser window is rectangular. As beta increases, the main lobe widens and the sidelobes fall.
For FIR filter design, the Kaiser window is the standard choice because beta can be set directly from the required stopband attenuation. For stopband attenuation greater than 50 dB:
beta = 0.1102 * (As - 8.7)
where As is the target attenuation in dB. At beta=8.6 the peak sidelobe is around -80 dB with a main lobe about three bins wide. Oversampling filters in audio plugins frequently use Kaiser-windowed FIR designs precisely because stopband attenuation is a hard specification, and beta maps directly onto it.
Practical Decisions
The window choice depends on what you are measuring:
Rectangular: Use only when the signal fills an exact integer number of cycles within the analysis frame. Otherwise the -13 dB sidelobes will contaminate every result.
Hann: Default for almost everything. Spectrum analyzer displays, STFT frames in pitch detection algorithms and time-stretching, general-purpose analysis. The -18 dB/octave rolloff keeps distant leakage negligible.
Hamming: Where you need the lowest possible sidelobe near the main lobe and can tolerate higher residual energy far from the main lobe. Less common in modern audio tools.
Blackman-Harris: Spectrum analyzers measuring distortion or noise, where the analyzer itself must not introduce artifacts at the level of the signal being measured. High-end analyzer plugins use it.
Kaiser: FIR filter design for oversampling, resampling, and antialiasing. The parametric beta provides a direct, specification-driven path to the required stopband attenuation.
Two practical consequences for mixing and sound design: first, when you use a spectrum analyzer to identify problem frequencies in a mix, a narrow FFT size with a Hann window gives you both reasonable frequency resolution and low sidelobe contamination. Increasing the FFT size gives better frequency resolution at the cost of slower time response, which is independent of window choice. Second, if you ever write analysis code and use an FFT without applying a window, every measurement you make will be off by up to 13 dB in the adjacent bins. The window is not optional.