# Hanning and Hamming Window

I am new in the field of signal processing. What's the different between Hamming and Hanning window? When we use the former and latter?

• I suggest you work your way through the article on window functions found on wikipedia: en.wikipedia.org/wiki/Window_function . There, all kinds of window functions are explained in detail. Also, you will see that the difference between a Hann and a Hamming window is quite small. – Max Apr 2 at 11:25

## 1 Answer

Max is right that the difference between Hamming and Hann windows are small. (BTW, I am a proponent of the movement to totally do away with them term "Hanning". There is no Dr. Hanning nor Mr./Ms. Hanning that the window is named after.)

The Hamming window is 92% Hann window and 8% rectangular window. Hamming found out that he was able to reduce the height of the maximum side lobe by doing that.

Another issue that I just thought of: The Hann window (and some others) is a complementary window; that is that the latter half of the window of one frame adds to the first half of the following frame to 1. For analysis, the property of being complementary is usually not important, but for synthesis (or reconstruction), this property is salient.

So if you like symmetry about 0, the Hann window having even length $$N$$, is

$$w\left( \tfrac{n}{N} \right) = \begin{cases} \tfrac12 + \tfrac12 \cos\left( 2 \pi \tfrac{n}{N} \right) \qquad & |n| \le \frac{N}{2} \\ 0 \qquad & |n| \ge \frac{N}{2} \\ \end{cases}$$

The property of being complementary is:

$$\sum\limits_{m=-\infty}^{+\infty} w\left( \tfrac{n-mH}{N} \right) = 1$$

then

\begin{align} x[n] &= x[n] \times 1 \\ &= x[n] \times \sum\limits_{m=-\infty}^{+\infty} w\left( \tfrac{n-mH}{N} \right) \\ &= \sum\limits_{m=-\infty}^{+\infty} x[n] w\left( \tfrac{n-mH}{N} \right) \\ &= \sum\limits_{m=-\infty}^{+\infty} x_m[n-mH] \\ \end{align}

where

\begin{align} x_m[n-mH] & \triangleq x[n] w\left( \tfrac{n-mH}{N} \right) \\ x_m[n] & = x[n+mH] w\left( \tfrac{n}{N} \right) \\ \end{align}

So $$x_m[n]$$ is a finite-length frame of signal of length $$N$$ and represents the audio in the neighborhood of $$x[n+mH]$$ or $$m$$ hops from the beginning. $$H = \frac{N}{2}$$ is the frame hop displacement.

The Short-Time Fourier Transform (STFT) is: \begin{align} X_m[k] &= \sum\limits_{n=-\tfrac{N}{2}}^{\tfrac{N}{2}-1} x_m[n] e^{-j 2 \pi nk/N} \\ \\ &= \sum\limits_{n=-\tfrac{N}{2}}^{\tfrac{N}{2}-1} x[n+mH] w\left( \tfrac{n}{L} \right) e^{-j 2 \pi nk/N} \\ \\ &= \sum\limits_{n=0}^{N-1} \hat{x}_m[n] e^{-j 2 \pi nk/N} \\\end{align}

where

$$\hat{x}_m[n] = \begin{cases} x_m[n] \qquad & 0 \le n < \tfrac{N}{2} \\ \\ x_m[n-N] \qquad & \tfrac{N}{2} \le n < N \\ \end{cases}$$

• I prefer to call it the von Hann window function, as it's named after en.wikipedia.org/wiki/Julius_von_Hann – hotpaw2 Apr 3 at 2:38
• I third the elimination of the term "Hanning", I use VonHann. BTW, I generally prefer straight DFTs without windowing (it is only a rectangular window in context of the DFT being considered a sampling of the FT!), but the VonHann is best for good spectrograms. – Cedron Dawg Apr 3 at 15:47