S7 · Lesson 29 · Spectral analysis with windows
The DFT of a windowed sinusoid, leakage and scalloping, resolution, zero padding, coherent gain and equivalent noise bandwidth, and reading amplitudes off a spectrum
Point an FFT at a signal and it returns numbers that look like a spectrum, but they're the spectrum of a finite, windowed piece of the signal, sampled at N frequencies. A tone that doesn't fall exactly on a bin smears across many of them, a strong tone's sidelobes can bury a weak one nearby, and the peak reads up to 4 dB low depending on where the tone happens to sit. Every spectrum analyzer and every FFT plot is shaped by these effects. This lesson quantifies them so the numbers an FFT gives can be read as measurements, with known errors.
- The 32-point DFT magnitudes (stems, in dB) of a tone at bin 8 + d, with a rectangular window and with a Hann window (positive-frequency component, normalized to each window's on-bin peak).
- With d = 0 the rectangular window shows one clean bin, but move the tone between bins and its energy leaks across the whole spectrum, falling off slowly.
- The Hann window always smears over three bins but its leakage dies fast. At d = 0.5 the rectangular peak drops 3.92 dB and the Hann peak only 1.42 dB: the scalloping loss.
Predict
A 1024-point FFT at 8 kHz has 7.8 Hz bins. Will zero-padding it to 8192 points let it separate two tones 4 Hz apart?
No. Resolution is set by how long the signal was observed, here 1024/8000 = 128 ms, which gives main lobes about 7.8 Hz wide even for the rectangular window (and twice that for Hann). Zero padding samples that same spectrum more densely, which helps locate a single peak precisely, but two tones closer than the main-lobe width still merge into one lump. Only a longer record separates them.
Name it
The windowed tone
A tone at bin (d the fractional offset) windowed by w[n] gives a DFT equal to the window's spectrum centered on and sampled at the integer bins. For the rectangular window, .
- Leakage: energy in bins far from the tone, set by the window's sidelobes.
- Scalloping loss: the peak's drop when the tone falls between bins: 3.92 dB for the rectangle at d = ½, 1.42 dB for Hann, 0.01 dB for a flat-top window.
- Resolution: two tones separate only if they're further apart than about the main-lobe half-width, which is 1 bin for the rectangle and 2 bins for Hann and Hamming. That's or in hertz: the record length T = N/f_s sets it.
- Zero padding to M > N points samples the same spectrum at spacing : finer interpolation, no better resolution.
Reading amplitudes and noise
- Coherent gain : 1 for the rectangle, 0.5 for Hann, 0.54 for Hamming. A tone of amplitude A on a bin gives , so .
- Equivalent noise bandwidth bins: 1 for the rectangle, 1.5 for Hann, 1.36 for Hamming, 1.73 for Blackman. Each bin collects noise from ENBW × hertz.
- Processing gain: a tone rises above white noise by dB more than it does in the time domain.
Worked example
A tone falls exactly halfway between two bins. How much lower does its peak read with a rectangular and with a Hann window?
Show the solution
- Rectangular window. which is −3.92 dB.
- Hann window. which is −1.42 dB.
- Why Hann loses less. Its wider main lobe is flatter on top.
Answer the peak reads 3.92 dB low with a rectangular window and 1.42 dB low with a Hann window.
Worked example
A 1024-point Hann-windowed FFT at 48 kHz shows a peak of |X| = 5,000 on a tone's bin, with white noise in the background. What's the tone's amplitude, and how much processing gain does the FFT give?
Show the solution
- Amplitude.
- Processing gain. So a tone 20 dB below the noise in the time domain shows up 8.3 dB above the noise floor in each bin.
- Resolution. Bins are 46.9 Hz apart, and Hann resolves tones about 94 Hz apart.
Answer the tone's amplitude is 19.5, and the FFT gives 28.3 dB of processing gain.
Worked example
A tone sits 20 dB below white noise (SNR −20 dB in the time domain). Will a 4096-point Hann-windowed FFT show it?
Show the solution
- Processing gain.
- SNR in the bin. That's clearly visible, if the tone stays put for the whole record.
- Longer records. Each doubling of N adds 3 dB, which is how spectrum analyzers dig tones out from under noise.
Answer yes: the tone's bin shows an SNR of 14.4 dB.
Check
A tone sits 0.35 bin from the nearest bin of a 64-point rectangular-window DFT. How much does its peak read low?
Check
Roughly how close can two equal tones be and still be resolved by a 512-point Hann-windowed FFT at 44.1 kHz?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
Check
A tone on a bin shows |X| = 1000 in a 256-point DFT with a window whose coherent gain is 0.54. What's its amplitude?
Check
A 1024-point FFT uses a window with ENBW = 1.36 bins. What processing gain does it give a tone in white noise?
Check
A 1024-point record at 8 kHz is zero-padded by a factor of 16. What's the spacing of the resulting spectrum's samples?
Write units the way you normally would: 1.5 Hz, 1500 mHz and 0.0015 kHz are the same answer.
Check
Two tones 5 Hz apart must be resolved with a Hann window at 8 kHz. How many samples must the record have?
Check
A tone is −10 dB below white noise in the time domain and analyzed by a 4096-point FFT with a window of ENBW 1.36 bins.
(a)
What processing gain does the FFT give?
(b)
What SNR does the tone have in its bin?
Check
An N-point FFT at sample rate s with a window of ENBW E bins and coherent gain c shows a tone on a bin with |X| = X.
Step 1
What is the tone's amplitude?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
What noise bandwidth does each bin have, in hertz?
Step 3
What processing gain does it give?
Explain why
Why can a strong tone hide a weak one many bins away when the rectangular window is used?
Unless a tone falls exactly on a bin, its windowed spectrum spreads into every bin according to the window's sidelobes, and the rectangular window's sidelobes are high, the first only 13 dB down, and fall off slowly, about 6 dB per octave of distance. A tone 60 dB weaker sitting ten bins away is therefore buried under the strong tone's leakage, which at that distance is still only about 30 to 40 dB down. A tapered window such as Hann or Blackman has sidelobes that start lower and fall much faster, so the leakage at that distance drops below the weak tone and reveals it, at the price of a wider main lobe that blurs tones that are very close together.
Practice
Keep practicing
10 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.