# How to interpret the effect of different windows in short time fourier transform?

There are many categories of windows, e.g., rectangular, Gaussian, and triangular. What are their effects on STFT?

• Also have a look here. – jojek Nov 9 '17 at 12:54

A widnow $w[n]$ truncates and weights the input signal $x[n]$ to prepare it for subsequent spectral analysis. A windows's effect on the input signal's true spectrum $X(e^{j\omega})$ is mathematically described by the convolution of window's Fourier transform $W(e^{j\omega})$ with the signal's true spectrum $X(e^{j\omega})$;

$$V(e^{j\omega}) = \frac{1}{2\pi} \int_{-\pi}^{\pi} W(e^{j\theta})X(e^{j (\omega -\theta)}) d\theta$$

From this convolution there are two main effects observed on $X(e^{j\omega})$

1- A smoothing (smearing) of $X(e^{j\omega})$ due to the main lobe width of the window's Fourier transform $W(e^{j\omega})$, which results in a loss of spectral resolution in the $V(e^{j\omega})$.

2- A leakage due to peak side lobe of $W(e^{j\omega})$, which results in loss of weak signal components that's below leaking nearby strong frequencies.

Main lobe width of any window type is primarily determined by its length. Increasing the length of any window will therefore decrease its main lobe width (hence increase its spectral resolution capability)

A rectangular window has the narrowest main lobe width and the highest peak side lobe, compared to all other windows. And the remainig window types perform a tradeoff between mainlobe width and the peak side lobes.

Peak side lobe is primarily determined by windows's shape. So by changing the shape (type) of the window you adjust it.

The rectangular window is just what, when we have truncated the data, while the other windows provide some data weighting. From their effects on the frequency spectra, The advantage of using a window other than rectangular is to have lower sidelobes.

However, the disadvantage is a loss in frequency resolution, from $\Delta \omega = 4\pi / N$ for the rectangular window to $\Delta \omega = 8\pi / N$ and $16\pi / N$ for Gaussian and Triangular windows respectively.

In addition to what's already been said, using a rectangular window also results in the minumum possible noise floor, which is desirable in some applications.

With regard to obtaining the best amplitude/magnitudes estimates, you should consider using some of the flat top windows, which are designed specifically for this purpose. However, they have a wide main lobe, and thus poor frequency resolution, so they're not suitable for signals where you have sinusoids that are close in frequency.

Anyway, see here http://zone.ni.com/reference/en-XX/help/371361H-01/lvanlsconcepts/char_smoothing_windows/ or here https://en.wikipedia.org/wiki/Window_function if you interested in the theory.

[EDIT 2017-11-10: added details one the used of inverses] Their first effect, in the time domain, is to localize, or (weakly) stationarize the data, as a preprocessing before applying the FFT.

Then in the analysis side, their frequency effect is the same as when used for an FFT, ad detailed on other answers.

Last, in the synthesis side, a different window can be used when recovering a signal from a selection of chunks in the time-frequency domain.

This is used in practice, for instance in image compression. One wavelet/window type is used for the analysis or image decomposition, better at compacting information. Then, this information is quantized, and another wavelet/window is used for decompression: it is smoother, and attenuate, visually, quantization artifacts. Here, the whole transform is not redundant, and this is called biorothogonality.

In the redundant setting, certain analysis windows admit a closed-form inverse with the same window, but this is not always the case, as you c an see from the following picture given in Duality for Frames, 2016, with the analysis window on the left, and the synthesis one on the right. • Isn't using a different window for the synthesis phase undesirable because you're more likely to introduce certain digital artifacts that were not present in the original signal? – dsp_user Nov 9 '17 at 22:01
• Tough comment for a simple answer. Since the STFT is redundant, it may admit several inverses. So if you don't change STFT coefficients, those other inverses are just perfect. So you can design other inverses, that are more optimal in some sense. Those could be useful, for given purposes, but not use for direct inverses. However, when doing processing in the STFT domain, you may want reconstructed data more precise in time, or in frequency, for detection purposes – Laurent Duval Nov 9 '17 at 22:21
• The article you linked to looks very theoretical and I suppose it may be useful in certain situations (though I don't pretend to even understand what it involves :) – dsp_user Nov 10 '17 at 7:09
• Now that you brought this up and since I'm doing some audio manipulations in the frequency domain (which sometimes/often sound bad when inverted back), I think I might give this idea a try. – dsp_user Nov 10 '17 at 8:33