Windowing and FFTs

Remember that the Fourier Transform was meant to be used with periodic functions. Most of the time, when we pick a chunk of signal to analyze it's not periodic, and this results in spectral "leakage."

I took nf's guitar sample and cut out a 65536-sample chunk. Here's what the beginning of that chunk looked like:

a waveform

This "leakage" can be reduced (at the cost of peak resolution) by "windowing" the non-periodic waveform to make it look a little more periodic. Windowing means multiplying the signal we have by a tapering function (sometimes called an apodization function). Different windows give different frequency responses.

Here are some of the more common windows, and the frequency responses they give:


Rectangle

When no window is being used, we can say we're using the "rectangle window."


Hamming

y=0.54+0.46\cos(\pi x)


Blackman

y=0.42+0.5\cos(\pi x)+0.08\cos(2\pi x)


Hann

Named after the Austrian meteorologist Julius von Hann. Some people call it the "Hanning" window, to help confuse it with the "Hamming" window. If you think back to your trigonometric identities, you'll find that an alternative representation of the cosine-squared Hann looks a lot like the formula for the Hamming window, although they are different.

y=\cos\-^2\left(\frac{\pi x }{2}\right)


Gaussian

Remember how derivatives and integrals of natural exponents (ex) stay natural exponents? The Fourier Transform of a Gaussian function is still a Gaussian funcion.

y=e^{-0.5 (ax)^2}



Welch

y=1-x^2


Bartlett

Sometimes known as the "triangle" window.


Code

As always: window.c

Graphs drawn by gnuplot.
Math rendered by MiKTeX.

If you spot any mathematical inaccuracies, please let me know.