Subject: Re: On the use of windows From: "Crockett, Brett" <BGC@xxxxxxxx> Date: Thu, 6 Apr 2006 15:26:38 -0700The use of and impact of windowing in spectral analysis and synthesis are very well known, especially in the audio coding world. I would point people to some papers by my colleague Louis Fielder here at Dolby and in particular his work on the Dolby E coding system. This system uses a number of windows of varying lengths and shapes and Louis did extensive work on optimizing the windows for the coding system. I would like to reiterate what Fred points out: using windows to avoid edge effects can have a very serious impact in the resulting analysis and potential synthesis. I like to point out to newcomers that multiplication of the window in the time domain is the same as convolution in the frequency domain and that this will obviously change the resulting spectrum of the windowed data. (Sine waves are a good test signal to learn about the effects as the spectral smearing is more obvious). Brett Brett G Crockett | Senior Member of the Technical Staff, Sound Technology, Research | Dolby Laboratories Inc. | 100 Potrero Avenue San Francisco, CA 94103-4813 | Tel. 415.558.0357 | Fax. 415.863.1373 -----Original Message----- From: AUDITORY Research in Auditory Perception [mailto:AUDITORY@xxxxxxxx On Behalf Of Fred Herzfeld Sent: Thursday, April 06, 2006 2:10 PM To: AUDITORY@xxxxxxxx Subject: On the use of windows Hello List, Once again the use of Windows to remove the edge effects reared its ugly head and once again I must make it very clear that the use of any window is very dangerous. One window that exemplifies most windows is the raised cosine function which can be written as: W(j) = 0.5*(1-Cos(2*pi*(j-1)/N)) for j=0 to N-1 EQUATION (1) where j is the bin number: N is the length of the FFT window in Bins If W(j) is used by itself as the input to a FFT routine then of course Bin number zero will have the DC value of W(j) = 0.5 and since W(j) just exactly fits one cycle into the FFT the result in Bin number one will have an amplitude of 0.5 and a phase of 180 degrees. Next consider a single sinusoid as input to the FFT using a rectangular window that is W(j) = 1 for all j EQUATION (2) where the input signal is: S(j) = 1.0 Cos(2*pi*5*(j-1)/N -phi/180*pi) EQUATION (3) where phi = 30 is the angle in degrees in this example. The output of the FFT should then be all zeroes except for Bin 5 which should have the amplitude 1.0 and the phase in degrees of 30. So far so good. But now add (actually multiply) the raised cosine window to the function in EQUATION (3). The output of the FFT will now be (because of the window): All bins will be zero except for Bin 5 will now have A=0.5 and phi=30 . WOW! The function amplitude has decreased by half. And the adjacent bins Bin 4 and Bin 6 no longer have zero values ! Bin 4 and bin 5 will each have an amplitude of 0.5 and a phase angle of 120 degrees. So first the amplitude has decreased by a factor of 2 and the phase of these two components is now 120 degrees. The "spectrum" hardly looks like the original single sinusoid. Why does this happen with just the addition of the raised cosine window. The answere is very simple. We are in effect modulating the single sinusoid by the raised cosine. The fact that the raised cosine goes smoothly to zero at each end does not really matter. All that does is generate a DC component. The raised cosine is in effect a single sinusoid which falls exactly into the first Bin thus forming the product of two sinusoids. Think back about amplitude modulation. That IS what we have. We see the results as the two upper and lower) sidebands of the original signal in Bin 5. I call this the "Modulation Error" and as far as I know it has not been dealt with in the literature. Therefore if the signal being transformed by the use of the FFT is a sum of sinusoids, the multiplication of this sum by ANY window will produce "Modulation Errors"!! To further indicate how violent a window can act use the window given in EQUATION (1) along with : Bin 5: 1*Cos(2*pi*5*(J-1)/N - 30/180*pi) EQUATIONS (4) Bin 6: 2*Cos(2*pi*6*(J-1)/N - 30/180*pi) Bin 7: 3*Cos(2*pi*7*(J-1)/N - 30/180*pi) Bin 8: 4*Cos(2*pi*8*(J-1)/N - 30/180*pi) Bin 3: -1*Cos(2*pi*35*(J-1)/N - 30/180*pi) In Bin 5 I have the same function as in EQUATION (3) and the additional 4 sinusoidal terms are as show in EQUATION (4). Without any window we then get zeroes in all Bins except: Bin 3: amplitude = 1; phase = 210 degrees EQUATIONS (5) Bin 5: amplitude = 1; phase = 30 degrees Bin 6: amplitude = 2; phase = 30 degrees Bin 7: amplitude = 3; phase = 30 degrees Bin 8: amplitude = 4; phase = 30 degrees Lastly if I now again add the raised cosine window I get: Bin 2: amplitude = 0.25 phase = 30 degrees EQUATIONS (6) Bin 3: amplitude = 0.50 phase = 210 degrees Bin 8: amplitude = 1.25 phase = 30 degrees Bin 8: amplitude = 1.00 phase = 210 degrees Well, isn't that interesting. Without a window we have entries in 5 Bins which agrees with the input to the FFT. With a raised cosine window there are entries in only 4 Bins and on top of that Bins 5,6,7 which have outputs without a window are now zero when the raised cosine is used. The other entries Bins 2,3,4,8,9 are also incorrect. It is now to be realized that with "Modulation Error" caused by any window each and every frequency component generates two sidebands which will affect the immediately adjacent (upper and lower) components if they exist and if they do not exist. The exposition I have given above is the best reason I can give for not using a window function with the FFT, the STFFT, the Fourier Series etc. I will be very please to receive your responses and will answer each one. Fred Herzfeld -- Fred Herzfeld, MIT '54 78 Glynn Marsh Drive #59 Brunswick, Ga.31525 USA ----------------------------------------- This message (including any attachments) may contain confidential information intended for a specific individual and purpose. If you are not the intended recipient, delete this message. If you are not the intended recipient, disclosing, copying, distributing, or taking any action based on this message is strictly prohibited.