Hanning Window: How it works
Window functions such as the hanning window are widely used in digital signal processing in order to minimize artifacts during discrete Fourier transformations. In this practical tip, we will explain how the Hanning window works and how it affects the spectrum.
Hanning Window: How it works
With a Hanning Window, you can manipulate a signal section to reduce errors in a discrete Fourier analysis. What it is used for and what it does can be summarized as follows:
- With a Fourier transformation you convert a temporal or spatial signal into a spectrum.
- You can find an example in our practical tip on FM synthesis. A YouTube video shows the time series of a complex sound and its spectrum.
- If you apply the Fourier transformation over a finite section of your time signal, errors - also called artifacts - can arise.
- If frequencies are contained in the signal whose period is not an integral multiple of the window length, the frequency "leaks" during the transformation into adjacent frequencies. This phenomenon is called "spectral leakage".
- Spectral leakage from a signal section without hanning windowing can be seen in this YouTube video. The spectrum shows very high amplitudes of frequencies that are significantly higher than the actual frequency.
- Spectral leakage is mainly caused by the steep rise at the beginning and end of the signal section.
- You need a windowing function to reduce spectral leakage.
- The Hanning window is a function of the duration of the signal section from which you want to perform a Fourier analysis. You multiply each value of the signal section by the corresponding value of the Hanning function.
- The Hanning function is: 1/2 [1 - cos (2 pi n / T)], n = 0, ..., T-1
- The figure shows a signal section (blue), the Hanning function (dashed line) and the signal that results from the weighting of the section with the Hanning window (violet).
- A Fourier transform of the signal manipulated in this way contains significantly lower frequencies. For this, the main lobe, i.e. the amplitude of the direct neighboring frequencies, is higher than without the fenestration.
- A YouTube video of the same output signal - manipulated by hanning windowing - illustrates the reduction in spectral leakage.
- After an inverse Fourier transformation, you have to undo the windowing to get the output signal again.
With the help of this practical tip and our tip on editing WAV in Mathematica, you can program spectral analyzes independently. There are different window functions that have different main lobes and different strong and wide leakage effects.