# What is the advantage of applying a Hamming window for MFCC calculations?

I am trying to implement MFCC by following this and I found that there is a step in which signals are divided into frames and then passed on to Hamming windowing process. The reason given there is to correct the discontinuity at the start and last samples of the frame. OK that sounds good, then the output of the window is fed for FFT process. So I thought of doing this sample code separately.

My code:-

%Creating a signal to perform hamming windowing on.
fs=8000;
ts=1/fs;
N=1000;
t=(0:ts:(N-1)*ts);
x=sin(2*pi*60*t);

figure,subplot(221),plot(t,x,'.-'),title('Original Speech'),xlabel('Time');grid on
f=(-fs/2:fs/(N-1):fs/2);
subplot(223),plot(f,fftshift(abs(fft(x)))),title('Frequency Spectrum'),xlabel('Freq (Hz)');grid on
windowed=x.*hamming(length(x))';
subplot(222),plot(t,windowed,'.-'),title('Hamming Window Applied'),xlabel('Time');grid on
subplot(224),plot(f,fftshift(abs(fft(windowed)))),title('Frequency Spectrum After Hamming'),xlabel('Freq (Hz)');grid on


The plot generated is:- My Problem is:-

What is the advantage of Hamming Windowing. I am a noob, so according to me, firstly we are loosing the amplitude at the staring and ending of the signal in the time domain and secondly, in the frequency domain, there is very little difference. So what is the advantage of doing all this much computation. Please explain with as much detail as possible.

And it would be nice if someone could point out to more detailed (according to them) tutorial then what I am referencing or what they read while learning MFCC themselves.

• Window is used to reduce side lobe. The idea is not to allow sudden jump at the ends of the signal. – Creator Sep 22 '15 at 21:23
• Zoom in closer to that frequency and show the magnitude in decibels to better see the difference. – Olli Niemitalo Sep 23 '15 at 8:57
• @olli the difference that I see is that in fft of original wave, the two spikes are connected at the bottom whereas in the fft of windowed signal there is a small lobe between the two spikes....does that states something? Please explain. – Mohit Sep 23 '15 at 9:40
• IF you don't apply any window, you actually apply square window. If you transform square window into frequency you will get main lob with additional side lobes, in most caseses something we don't want because it contaminates signal. If you apply hamming window, the side lobes are reduced. However, there is traide off, depending on the window, and considering the same width of each windows, you increase the width of the main lobe. There are windows such as Kaiser which take an extra parameter. The parameter let you control, side lobes aplitude over main lobe width in cost of one another. – Celdor Sep 23 '15 at 14:15
• There is difference in frequency. The difference is that, your frequency will have additional components caused by sinc function which is a transform of a square window in time domain. This sinc function is convolved with a frequency signal which intriduces additional lobes. You cannot avoid this effect but you can reduce its influence by applying different windows. – Celdor Sep 23 '15 at 14:23

## 1 Answer

Ideally you would only see that frequency as a narrow peak but because of the finite-length window you also get that other artificial crud: Windowing equals time domain multiplication by the window function (here rectangular or Hamming). Time domain multiplication equals frequency domain convolution: All frequencies will be replaced by the Fourier transform of the window function. This is what those look like:

The convolution spreads the true frequency to frequency bins around it. By using a window function other than the rectangular one there is less of the sidelobes compared to the main lobe, so less artificial long-distance spread making the result cleaner and better suited for frequency-selective analysis. You seem to have by accident chosen a frequency where you don't see the sidelobes with the rectangular window because the dips between the sidelobes land between your frequency bins. So you just see slopes.

• But as the hamming window reduces the amplitude of both sides, the fft will be more focused on the middle part of time domain i.e. frequencies in the middle of the signal will have more preference. Correct me if I am wrong. – Mohit Sep 23 '15 at 10:20
• That is correct. But using overlap (one window beginning at the middle of the previous one) you can cover everything equally. – Olli Niemitalo Sep 23 '15 at 10:27