# how do windowing functions not distort the signal?

I'm trying to gain a better understanding of windowing functions, but so far I can't tell why they're used. As an example, I'm familiar with the Hamming Window:

$w(k) = 0.54-0.46cos( \frac{2{\pi}k}{N-1})$ if $0<k<N$

But I don't understand how this can be done without distorting the signal. Are these specially chosen functions that just happen to retain the spectrum of the signal sample? Can it be proven mathematically that multiplying by this function retains the spectrum? And what is the advantage to using this, rather than simply windowing it and not multiplying it by any windowing function at all (i.e. a windowing function of 1)?

They do "distort" the signal, as you noted. Multiplying by a window function does not "retain" the spectrum of the original signal. Recall the multiplication property of the Fourier transform:

$$x(t) w(t) \Leftrightarrow X(\omega) * W(\omega)$$

where the $*$ denotes convolution. So, multiplying by a window function in the time domain yields convolution of the input signal and window function's spectra in the frequency domain. In this way, there is some "distortion" of the input signal's spectrum.

As you noted, however, there are cases where using window functions can be useful. There is a good illustration of the tradeoffs here. I will shamelessly steal the plot for reproduction here:

Summarizing the discussion briefly:

• If you don't use a window, that is equivalent to using a rectangular window, assuming you are analyzing a finite-length signal (and if you aren't, then you better be patient). The rectangular window has a very slow decay rate on its sidelobes. You have to move away from the main lobe a long way in frequency in order to achieve a certain amount of attenuation.

• Say you had a case where you wanted to analyze two tones in a signal, where one is 40 dB stronger than the other. Compare this to the plot of the rectangular window's frequency response in the linked answer above. You can see that for that case, the sidelobe response of the rectangular window never drops below ~30-35 dB or so (except for the very narrow nulls). That means that the sidelobe response from the stronger signal would "wash out" the other peak, thwarting your attempt to analyze both signals simultaneously.

• The solution to such a problem is to use a window function: there are a few illustrated there, but there are a lot of them. Select one that has enough sidelobe attenuation for your application. For example, the Blackman-Harris window has greater than 90 dB of sidelobe attenuation, which provides a lot more dynamic range than the rectangular window.

• You pay a price for such a choice, though. The "distortion" that you referred to, caused by the convolution of the input signal and window spectra, comes into play. Note that the greater the dynamic range of the window function (i.e. the lower its sidelobes are), the wider its main lobe is. This can affect your ability to resolve two tones that are very close to one another (if they are too close, then the width of the window's main lobe will cause them to smear together).

This is the inherent tradeoff when selecting a window function.