Window Functions¶
Window functions taper finite signal blocks before FFT processing to prevent spectral leakage — the spreading of energy into neighbouring frequency bins caused by discontinuities at block edges.
The DFT assumes the input is one period of a periodic signal. When the signal doesn’t have an integer number of cycles in the block, the endpoints are mismatched. A window smoothly tapers the signal to zero at the edges, greatly reducing this leakage.
Four window types¶
Hanning (Hann) — the default choice for FFT analysis.
import pyminidsp as md
win = md.hann_window(256)
Hamming — similar to Hanning but with a lower first sidelobe.
win = md.hamming_window(256)
Blackman — strongest sidelobe suppression, widest main lobe.
win = md.blackman_window(256)
Rectangular — all ones (no tapering). Narrowest main lobe but maximum sidelobe leakage.
win = md.rect_window(256)
Comparison¶
Window |
Edge values |
Sidelobe level |
Main lobe width |
|---|---|---|---|
Rectangular |
1.0 |
Highest |
Narrowest |
Hanning |
0.0 |
Low |
Medium |
Hamming |
0.08 |
Lower first sidelobe |
Medium |
Blackman |
0.0 |
Lowest |
Widest |
Rule of thumb: start with Hanning. Use Blackman when minimising leakage matters more than frequency resolution.