## What is Windowing and when/why do we need it?

Started by 7 years ago●8 replies●latest reply 7 years ago●7723 viewsThis is the first question to make it into the new #FAQ section.

The hope is that your collective insights will make this page a great resource for the EE community to learn about the basics of Windowing in the DSP world: what it is, when and why we need it, when we don't need it, Matlab examples, etc.

Please don't forget:

- that you can add images to your post simply by drag and dropping them into the editor
- that you can add great looking equations to your post through Mathjax (read here for details)
- to click on the 'thumbs up' button for the contributions that you find the most insightful

In the hope to encourage the participation of many, I will start keeping track of the total number of thumbs-ups every user receives for FAQs. From time to time, I will draw a prize (a dsp book probably) to be sent to the winner. The more thumbs-ups you accumulate, the more chances you have to win the prize.

Thanks a lot for your time!

Sometimes we have to teach new hires about windowing on a basic level. They've already seen it in school, but maybe don't "feel" the need, and just think of it on a list that includes lots of signal processing concepts. We show them a waveform, say 10000 samples, and ask them how they would apply an FFT to it in Matlab. Of course they always know Matlab (or Octave), so they give a Matlab'ish type answer and it's easy. Then we ask, now what if you have to do this to continuous data -- you can't see the end of it, and it may never stop ?

Most say something like "process it in chunks". Some add something like "make sure we keep up with the data". And that starts a conversation about how to determine the chunk size, how to deal with the edges of the chunk ("truncation" has been mentioned already), how to sew the chunks together, and how to make processing each chunk efficient. What we want them to keep in mind is that windowing is fundamental to handling continuous streams of data.

"Windowing" can mean a couple of things:

1) A limitation in temporal or spatial or spectral extent (etc.) - whether intentional or simply a function of the limitations of observation or measurement. The "limitation" may also be a single period of a periodic function or record. [From now on, I'll use "time" with the understanding that it may be "frequency" or "space" or ....]

2) A finite function applied to (multiplied) over a time function or record in order to achieve a desired effect.

So, in (1), we may refer to an "observation window" meaning that there is an observation or measurement time that is either selected or imposed. This by itself has no weighting involved and is called a "rectangular window" or "gate function", etc. Importantly, the Fourier transform of a rectangular window is of the form sinx/x or what's called a "sinc" function. This is a fundamental characteristic. The shorter the rectangular window, the wider the sinc and vice versa. Thus the reference to the Heisenberg uncertainty principle.

In (2), we impose a weighting function over the rectangular window. Why would we do this? For example, the sharp edges of the rectangular window in time introduce broad spectral content. And, broad spectral content is detrimental to spectral analysis.

Imagine a rectangular window that's multiplied by a bell-shaped curve - clearly this will remove the sharp transitions at the ends and reduce the broad spectral energy that the sharp edges contain.

A good deal of effort has gone into analyzing and designing such "windows" or "weighting functions" with the idea of helping one understand their characteristics and to help one implement them efficiently. Some key references are:

"On the Use of Windows for Harmonic Analysis with the Discrete Fourier Transform" Fredric J. Harris, Proceedings IEEE, vol. 66, pp 51-83

Nuttall, A. H. (February 1981). "Some windows with very good sidelobe behavior". *IEEE Transactions on Acoustics, Speech, Signal Processing*. ASSP-29: 84–91.

G.C. Temes, V. Barcilon, and F.C. Marshall III. The optimization of bandlimited systems. *Proc. IEEE, Vol 61,* pages 196-234, 1973.

Here are two on-line references on how windows are used in DSP:

In spectral analysis:

http://www.dspguide.com/CH9.PDF

In filter design:

Hi Steve. Nice to hear from you.

[-Rick-]

Windowing, to my best understanding, is

In Signal processing:

1.to trancate signals which are of your interest

2.to reduce memory requirement and accelerate computation process

In filter design: to make FIR filter

I think windowing is needed out of practical reasons. In the context of signal processing, almost all signals we are interested in are restrained to a certain period of time(For example, In a radar system, we usually analysis the received signal within a duration of a few pulses), thus by windowing we get useful signals. In the context of filter design, there is a filter type of FIR(finite impluse reponse), the design technique lies on windowing. There are plenty of prototypes out there, all you need to do is to apply windowing and make it implementable and computational effective.

From a university student in his forth year

It is deeply and fundamentally mathematical. It is actually related to Heisenberg's uncertainty and is called The Gabor Limit. The more precise you know things in time, the less precisely you can know their frequency ... and ... vice-versa.

Any truncated time-domain sequence MUST have an infinite frequency-domain sequence.

Any truncated frequency-domain sequence MUST have an infinite time-domain sequence.

To demonstrate ... as you crank up the Alpha of a Keyser or Dolph filter, the time window gets narrower and making time more accurate (throwing away information, by the way) while the stopband gets deeper and deeper with the main lobe widening, so the frequency information becomes LESS specific.

The best we can hope for is a tapering where some time or frequency region is significant and outside of that region the information has been "Windowed-out" to become insignificant. Window shapes in the time or frequency domains are chosen to optimize some needed parameter. Sometimes that optimization is selecting single-frequency boomer out of the otherwise flat background noise, for this a Dolph is optimal, and a Blackman-Harris is really fast and easy to calculate. Sometimes, we need the least distortion of the peak amplitude for some spectral analysis reason. At this point you might get Remez going or use one of the Flat-Top windows. The rectangular window (also known as Dirichlet) is the best there is at providing an unbiased estimator when you DON'T KNOW whether you are working on broadband or narrowband signals.

The point is that you have to look at the work you are doing to choose the right Window function.

The most egalitarian window is Gaussian. It gives the same tail shapes in time as it gives in frequency and they tail off really fast.

Hope this helps.

from a 40-year DSP veteran.

To keep my life simple I first avoid analogy with my bedroom window and second I view it as nothing more than a scale factor over a finite given samples. This scale factor usually goes up then down under different names. It may be square and then this window is same as no-window, a bit silly terminology gymnastics. As far as I know it is useful when applied on truncated (well any) stream before FFT to reduce the phase discontinuity at start-to-end of stream and therefore should not be applied if phase is already ok or that we are targetting equivalent operation between time and frequency domain.

I used windowing for multiple signal processing purposes. the most frequent one is windowing prior to FFT. I was using FFT to determine the spectral strength of fundamental frequency. I applied windowing prior to FFT as I was not in a position to ensure coherent sampling. If had my fundamental aligned with the sampling frequency i'll get frequency in a bin. for any other case, frequency peak will reflect more than one bin. use of appropriate window will make the frequency more concentrated in less number of bins - practically 3 bin. with the amplitude value of these 3 bins we can determine the spectral position and the amplitude more accurately using simple parabolic or Gaussian interpolation. there are more than 16 commonly used windows for this purpose or similar, I tried some of them- Blackman Harris and Hann window are two cases I find it gave me accurate results for my case.

Another case where I used windowing is for overlap and add case. in that case, the window has to have an additional property such that the a^2+b^2 = 1. where a and b are the lower and upper half of the window in the overlapping order. similar windowing is used in the time-to frequency transforms in most of the audio codecs.

There are other purposes for windowing, like synthesis and analysis windows for multirate processing. looks like they are called window just because they are time domain dot-product. some of the window shapes are not that intuitive as the overlap and add case. you will understand the point if you just plot the polyphase synthesis C-window used in MP3 :).

Coming back to the common windowing used prior to FFT, the shape is decided based on the time-frequency resolution requirement. one thing is for sure, it is worth spending some time to decide your window for your application based on the specific signal characteristics which you are expecting as input. common signal types are tones/harmonics, noise, voice, glitches/attacks, and mix of one or more... It is not uncommon to spend your time on deciding the type of window depending on the type of signal. recollecting classical short window / long window switching in MPEG audio codecs are example. I'm sure positioning the windowing is also worth considering for your specific needs !