DSPRelated.com
Forums

Windowing and spectrum amplitude

Started by Alberto February 15, 2005
I have a program that does real time spectral analysis of audio signals.
If I interactively change the window used before the FFT, choosing
between Hamming, Hann, Balckman, etc. etc I can of course see the 
widening or the narrowing of the peaks corresponding to steady frequencies,
but I notice also a changing value for the amplitude of the peaks,
depending on the window used. I compute the values of the peak amplitudes 
for display using the Parseval relation, but now I would also take 
into consideration a corrective factor depending on which window is used.

I browsed the Oppenheim & Schafer, but I have found no information
on this subject. Can anybody be of help ?  Many thanks

Alberto di Bene
"Alberto" <i2phdNOSPAMTHANKS@weaksignals.com> wrote in message
news:8GoQd.34476$QG6.596974@twister2.libero.it...
> I have a program that does real time spectral analysis of audio signals. > If I interactively change the window used before the FFT, choosing > between Hamming, Hann, Balckman, etc. etc I can of course see the > widening or the narrowing of the peaks corresponding to steady
frequencies,
> but I notice also a changing value for the amplitude of the peaks, > depending on the window used. I compute the values of the peak amplitudes > for display using the Parseval relation, but now I would also take > into consideration a corrective factor depending on which window is used. > > I browsed the Oppenheim & Schafer, but I have found no information > on this subject. Can anybody be of help ? Many thanks
I'm not sure if I'm completely correct here... but I think what you are seeing is related to the width of the main lobe of each of the windowing functions. If your signal of interest does not lie exactly on the FFT bin, then it's amplitude will be slightly off from the peak. How much 'off' is dependent on how sharply your main lobe rolls off from the peak. Cheers Bhaskar
> > Alberto di Bene
Bhaskar Thiagarajan wrote:
> I'm not sure if I'm completely correct here... > but I think what you are seeing is related to the width of the main lobe of > each of the windowing functions. If your signal of interest does not lie > exactly on the FFT bin, then it's amplitude will be slightly off from the > peak. How much 'off' is dependent on how sharply your main lobe rolls off > from the peak. >
Bhaskar, thanks for your answer, but from what I directly see by just watching at the displayed spectrum, the amplitude of the peak does not change when I move slightly the frequency. Instead, if I specify "no window", then the peak widens, as is to be expected, and its amplitude increases by an amount that, going from Hamming to no window, by eye is about 6 dB. Is this number that I would like to find specified somewhere for the various kind of windows. Thanks. Alberto di Bene
Alberto wrote:

> I have a program that does real time spectral analysis of audio signals. > If I interactively change the window used before the FFT, choosing > between Hamming, Hann, Balckman, etc. etc I can of course see the > widening or the narrowing of the peaks corresponding to steady frequencies, > but I notice also a changing value for the amplitude of the peaks, > depending on the window used. I compute the values of the peak > amplitudes for display using the Parseval relation, but now I would also > take into consideration a corrective factor depending on which window is > used. > > I browsed the Oppenheim & Schafer, but I have found no information > on this subject. Can anybody be of help ? Many thanks >
I suspect that there is no one consistent way to do this. I generally try to scale my windows so that the total energy content stays the same, which means that a pure tone that hits a harmonic right on the nose will have a lower bin amplitude as it is spread into other bins by the windowing function -- but if you add up the power in the few significant bins they should add up to the right number. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com
It's kind of easier to understand if you look at it in the time domain . All
that a windowing function does is taper the amplitude of your data on either
end. So less amplitude means less power. If you think of this "tapering" as
an RMS reduction you should be able to convert this to dB for each type of
window.

"Alberto" <i2phdNOSPAMTHANKS@weaksignals.com> wrote in message
news:8GoQd.34476$QG6.596974@twister2.libero.it...
> I have a program that does real time spectral analysis of audio signals. > If I interactively change the window used before the FFT, choosing > between Hamming, Hann, Balckman, etc. etc I can of course see the > widening or the narrowing of the peaks corresponding to steady
frequencies,
> but I notice also a changing value for the amplitude of the peaks, > depending on the window used. I compute the values of the peak amplitudes > for display using the Parseval relation, but now I would also take > into consideration a corrective factor depending on which window is used. > > I browsed the Oppenheim & Schafer, but I have found no information > on this subject. Can anybody be of help ? Many thanks > > Alberto di Bene
"Alberto" <i2phdNOSPAMTHANKS@weaksignals.com> wrote in message
news:UorQd.34207$lB4.920287@twister1.libero.it...
> Bhaskar Thiagarajan wrote: > > I'm not sure if I'm completely correct here... > > but I think what you are seeing is related to the width of the main lobe
of
> > each of the windowing functions. If your signal of interest does not lie > > exactly on the FFT bin, then it's amplitude will be slightly off from
the
> > peak. How much 'off' is dependent on how sharply your main lobe rolls
off
> > from the peak. > > > Bhaskar, > > thanks for your answer, but from what I directly see by just watching at > the displayed spectrum, the amplitude of the peak does not change when I > move slightly the frequency. Instead, if I specify "no window", then the > peak widens, as is to be expected, and its amplitude increases by an
amount
> that, going from Hamming to no window, by eye is about 6 dB. > Is this number that I would like to find specified somewhere for the
various
> kind of windows. Thanks.
My first guess wasn't correct (as your follow up email suggests). Some of the others are on the right track. The window eats into the overall signal power since it attenuates the signal near the ends. This leads to a term called as Coherent Power Gain for windows. A very nice treatment of this and other windowing concepts can be found here http://www.bores.com/courses/advanced/windows/10_cpg.htm A nice summary of this gain (or correction) for various windows can be found here http://www.bores.com/courses/advanced/windows/10_end.htm You can use the values from this table as your correction factor (it's in linear scale - so you'll have to convert to dB) Cheers Bhaskar
> > Alberto di Bene
"Alberto" <i2phdNOSPAMTHANKS@weaksignals.com> wrote in message 
news:8GoQd.34476$QG6.596974@twister2.libero.it...
>I have a program that does real time spectral analysis of audio signals. > If I interactively change the window used before the FFT, choosing > between Hamming, Hann, Balckman, etc. etc I can of course see the widening > or the narrowing of the peaks corresponding to steady frequencies, > but I notice also a changing value for the amplitude of the peaks, > depending on the window used. I compute the values of the peak amplitudes > for display using the Parseval relation, but now I would also take into > consideration a corrective factor depending on which window is used. > > I browsed the Oppenheim & Schafer, but I have found no information > on this subject. Can anybody be of help ? Many thanks > > Alberto di Bene
There are several different things that you might want to correct for. One thing you might want to correct for is the peak amplitude in the frequency domain of pure sinusoidal signals (which is what you mention above). Windowing is a block multiply in the time domain, which corresponds to a convolution in the frequency domain. So, to preserve the peak amplitude of a sinewave in the frequency domain, you want to scale the window so that it has a peak value of 1 in the frequency domain. This is equivalent to saying that the window's average level in the time domain must be 1. For example, a Hann window needs to be scaled so that it has a peak value of 2 in the middle so that it has an average level of 1. For sum-of-cosine windows like those you mention above, the correct scale factor is the inverse of the DC term of the window (Hann is 0.5 + 0.5*cos(), so the DC term is 0.5, so the scale factor is 2). Another thing you might want to correct for is average RMS level. This is useful if you are measuring broad-band signals like noise, or perhaps like some audio signals (?). To do this, you want your window to have an RMS level of one, so that it doesn't change the overall average energy of the signal. For a Hann window, you need a peak value of sqrt(8/3) ~= 1.633 in the middle to get an RMS level of 1 (exercise left to the reader...). Again, for sum-of-cosine windows like those you mention above, you can work out a simple formula, something like 1/sqrt(a_0^2 + sum_1ton(a_n^2)/2). For Hann, this is 1/sqrt(0.5^2 + 0.5^2/2) = 1/sqrt(0.25 + 0.125) = 1/sqrt(0.375) = 1/sqrt(3/8) = sqrt(8/3). Oops, I guess I didn't leave it as an exercise for the reader after all. Yet another thing you might want to correct for is the time-domain peak level of the signal. About the best you can do for this is to assume the time-domain peak is near the middle where the window's peak is, in which case the typical window definition requires no scaling. The above scale factors, unfortunately, are all different from each other for every window except the Uniform window. -- Eric Backus
Can anyone tell me what "Parseval relation" is without resorting to 
triple integrals from -infinity to +infinity?

I don't need to know how to use it. I just wish to be able to read 
comp.dsp ;)

Richard Owlett wrote:

> Can anyone tell me what "Parseval relation" is without resorting to > triple integrals from -infinity to +infinity?
The energy of a signal in the frequency domain equals the energy of the same signal in the time domain. Ciao, Peter K.
Peter K. wrote:

> Richard Owlett wrote: > > >>Can anyone tell me what "Parseval relation" is without resorting to >>triple integrals from -infinity to +infinity? > > > The energy of a signal in the frequency domain equals the energy of the > same signal in the time domain. > > Ciao, > > Peter K. >
DUH! Think I asked "wrong" question. Should I have asked "What does 'Parseval relation' imply?" Or should I ask "Just how confused am I?"