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 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

Hanning is an effective default. Blackman excels when minimising leakage takes priority over frequency resolution.

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.