Why are there so many windowing functions?

Many windowing functions are listed here in the Mathematica documentation. I tried using a few to reduce leakage when computing a Discrete Fourier Transform. From what I could tell it made little difference which windowing function is used. Two of them that are very dissimilar are the BartlettHannWindow and BlackmanHarrisWindow. Could someone provide an example where the BarttletHannWindow is a very good choice, and another where the BlackmanHarrisWindow is a very good choice. That might help me understand why there are so many to choose from.

Aside from reduction of spectral leakage, there is a one major trade-off to be made when choosing a window function. Below you can see a figure with various parameters. Two of them are most important:

• Main Lobe Width
• Peak Side Lobe Level

Width of the main lobe affects resolution of your analysis. I am sure you know that multiplication in time domain is convolution in frequency domain. By default you always use rectangular window, which has frequency response in a form of $\mathrm{sinc}$ function.

For example it might be the case that two pure sinusoids (Fourier Transform being Dirac deltas) with frequencies being very close to each other, peaks can be very hard to distinguish and thus become one. On figure below I compared 4 window functions for two sinusoids separated exactly by 3 frequency bins. You can see how wide is the main lobe of Nuttall window and how it affects the separation, whereas Rectangular window is the window with narrowest possible width of main lobe (i.e. lowest Normalized Equivalent Noise Bandwidth - NENBW)

On the other hand level of first side lobe affects the ability to recognize adjacent frequencies when spectral leakage is present and side lobes of frequency with high amplitude are almost "covering" other frequency next to it with much lower amplitude:

And here is the trade-off... You can't get very low level of side lobes and very narrow main lobe, i.e. it's not possible to have window function with main peak like in rectangular window, and very low level of side lobes as in Nuttal window. Here is the comparison of some windows:

Apart from parameters mentioned above, there is more features such as:

• Side Lobe Roll-off rate (how fast side lobes decrease - for example see Bartlett and Nuttal above)
• Existence of analytical frequency response equation (useful when performing theoretical calculations)
• Summing of window samples to constant value in time domain when doing overlap (for example Hann window with $33\%$ of overlap)

This is extremely useful when you want to perform STFT and then reconstruct time domain signal.

So now to answer your question. Why do we have so many window functions?

Depending on task whether it is simple FFT analysis of: closely spaced sinusoids, white noise, impulsive sounds, or even FIR filter design, different type of window is recommended. Obviously in 90% of cases people are using Hamming/Hanning window or no window at all. Nevertheless for some specific signals you might find that extracted features depending on window choice tend to be more discriminative.