A tone landing exactly on a bin centre gives one clean spike. Any other frequency smears energy across the entire spectrum. That is not a defect — when the window is repeated end to end, a non-integer number of cycles creates a discontinuity at the join, and the leakage is the correct spectrum of that artificial cliff.
Spectral leakage, and what a window does about it
Interactive
Window length 64On a bin centre yesEnergy outside the peak 0.0%
A real 64-point DFT, computed live. At exactly 8 cycles the tone lands on a bin centre and the spectrum is a single clean spike. Nudge it to 8.5 and energy smears across every bin — that is leakage, and it is the transform correctly reporting the discontinuity created when the window is repeated end to end. Doing nothing is still a choice — it is a rectangular window, with the worst side lobes of all at about minus thirteen decibels. There is no universally best window: narrow main lobe to separate close tones, low side lobes to see a weak one beside a strong one.
Windowing tapers the signal to zero at both ends so the repetition joins smoothly. You distort the data in a known way to remove a much worse artefact. Applying no window is applying a rectangular one, which has the worst side lobes of all — there is no neutral option.
Zero padding is not resolution
This confusion wastes a lot of time. Zero padding interpolates: more closely spaced points, a smoother-looking plot, the same underlying spectrum. Two peaks merged into one hump stay one hump — you have drawn it more finely, not resolved it.
Real resolution comes from observation time and nothing else. To separate two frequencies you must watch long enough for them to drift measurably out of step. Two tones one hertz apart need about a second. No amount of computation shortens that.
Relatedly: the spectrum of noise is wildly jagged, and taking more samples does not smooth it — you get more bins, each just as noisy. The fix is to split the signal into segments, window and transform each, and average the magnitudes. That is Welch’s method, and it trades frequency resolution for a lower-variance estimate.
The payoff: convolution by multiplication
Convolution in time equals multiplication in frequency. That single fact is the most valuable property of the transform, and it makes filtering comprehensible: a filter multiplies the spectrum by a set of per-frequency gains. A low-pass response is near one at low frequencies and near zero at high ones, so multiplying keeps one and annihilates the other.
Done naively it produces silently wrong answers. An N-point signal convolved with an M-point kernel needs N + M − 1 output slots, and an N-point transform has only N — so the extra samples wrap around and corrupt the beginning. Pad both signals to at least N + M − 1, then round up to a convenient transform length. 256 samples with a 51-point kernel needs 306, so pad to 512.
Key points
A sinusoid whose frequency lands exactly on a DFT basis frequency produces a single clean spike. Any other frequency produces a broad peak plus ripples extending across the whole spectrum. That is spectral leakage.
Leakage is not a defect of the transform. Because the DFT assumes your window repeats forever, a signal that does not complete a whole number of cycles has a discontinuity at the join, and the leakage is the correct spectrum of that artificial cliff.
Windowing tapers the signal smoothly to zero at both ends, so the periodic extension joins up without a discontinuity. You distort the data in a known way to remove a much worse artifact.
Applying no window is applying a rectangular window. That is a choice with the narrowest main lobe, about two bins, and the worst side lobes, about minus thirteen decibels — roughly twenty two percent leakage.
Hann widens the main lobe to about four bins with side lobes near minus thirty one decibels. Hamming is similar in width with nearest side lobes near minus forty three. Blackman is about six bins wide with side lobes near minus seventy four.
Every window trades main lobe width against side lobe level. Choose a narrow main lobe to resolve two comparable nearby frequencies; choose low side lobes to see a weak component beside a strong one. There is no universally best window.
The flat top window has poor resolution but measures peak amplitude accurately regardless of where the frequency falls between bins. Use it when you need to know how big a tone is rather than what frequency it is.
Zero padding interpolates the spectrum. It gives more closely spaced points and a smoother plot, but it does not separate frequencies that were previously merged. Resolution comes from observation time alone.
The magnitude spectrum of noise is wildly jagged, and taking more samples does not smooth it — you get more bins, each just as noisy.
To get a clean spectrum, split the signal into segments, window and transform each, and average the magnitudes. The variation falls as the square root of the number of segments, so one hundred segments gives a tenfold improvement. This is Welch's method.
Averaging trades frequency resolution for a smoother estimate, because each segment is shorter than the whole record. With a fixed amount of data you can have fine detail or low variance, never both.
The frequency response of a system is the Fourier transform of its impulse response. One impulse measurement characterizes the system at every frequency at once.
An impulse carries little energy, so in practice use a chirp or a pseudorandom sequence and correlate the output with what you sent. Same information, much better signal to noise, and the same reasoning as radar pulse compression.
Convolution in the time domain equals multiplication in the frequency domain. This is the most important property of the transform and it is what makes filtering comprehensible: a filter multiplies the signal's spectrum by a set of per-frequency gains.
Naive frequency domain convolution wraps around and corrupts the start of the output, because N plus M minus one results do not fit in N slots. That is circular convolution.
Prevent it by zero padding both signals to at least N plus M minus one, then rounding up to a convenient transform length. Two hundred and fifty six samples with a fifty one point kernel needs three hundred and six, so pad to five hundred and twelve.
Direct convolution wins for short kernels; the frequency domain method wins above roughly thirty to sixty kernel points and then wins by an enormous margin. For continuous streams the blocks must be stitched with overlap-add.