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.
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 |
Kaiser |
configurable |
configurable (via beta) |
configurable (via beta) |
Hanning is an effective default. Blackman excels when minimising leakage takes priority over frequency resolution. Kaiser is the most flexible — its beta parameter lets you dial in exact sidelobe/main-lobe trade-offs.
- pyminidsp.hann_window(n)[source]¶
Generate a Hanning (Hann) window of length n.
Generate a Hanning (Hann) window:
\[w[n] = 0.5\bigl(1 - \cos(2\pi n / (N-1))\bigr)\]Tapers to zero at both ends and is the default for FFT analysis.
- pyminidsp.hamming_window(n)[source]¶
Generate a Hamming window of length n.
Generate a Hamming window:
\[w[n] = 0.54 - 0.46 \cos(2\pi n / (N-1))\]Similar to Hanning, but with a lower first sidelobe.
- pyminidsp.blackman_window(n)[source]¶
Generate a Blackman window of length n.
Generate a Blackman window:
\[w[n] = 0.42 - 0.5\cos(2\pi n/(N-1)) + 0.08\cos(4\pi n/(N-1))\]Much lower sidelobes than Hanning/Hamming, with a wider main lobe.
- pyminidsp.rect_window(n)[source]¶
Generate a rectangular window of length n (all ones).
Generate a rectangular window (all ones). Useful as a baseline reference — equivalent to no tapering.
- pyminidsp.kaiser_window(n, beta)[source]¶
Generate a Kaiser window of length n with shape parameter beta.
Unlike other window functions, Kaiser windows require a beta parameter that controls the trade-off between main-lobe width and side-lobe level. Higher beta gives lower sidelobes but a wider main lobe.
- Parameters:
- Returns:
numpy array of length n.
- Return type:
Generate a Kaiser window of length n with shape parameter beta.
Unlike the other window functions, Kaiser windows take a beta parameter that controls the trade-off between main-lobe width and side-lobe level:
beta ≈ 5: similar to Hamming
beta ≈ 8.6: similar to Blackman
beta ≈ 14: very high sidelobe suppression
\[w[n] = \frac{I_0\!\left(\beta\sqrt{1 - \left(\frac{2n}{N-1} - 1\right)^2}\right)}{I_0(\beta)}\]