DSPRelated.com
Forums

Hamming window

Started by rajgerman February 19, 2006
rajgerman wrote:
> Thanks for that information but I'm still a little confused. > > The thing is I have a brain signal which is an audio file which I have > fast fourier transformed. Now what I have to do is apply the Hamming > window to that. How would I do that using MATLAB?? It seems confusing.
If x is the brain signal, then windowing with Hamming window in Matlab is simply y = x.*hamming(length(x),'periodic'); Was that the question? Or is your problem that you only have access to the FFTed brain signal X? In that case Y = fft( ifft(X).*hamming(length(X),'periodic') ) ; is equal to the windowed spectrum. Don't forget the 'periodic' flag for the window function, Matlab otherwise returns asymmetric windows (which you paradoxically specified as 'symmetric'). Regards, Andor

"Clay S. Turner" wrote:

> Hello Fred, > > Since the Hamming window is defined in terms of cosines, the Freq domain > version turns out to have only 3 non-zero coefs. This makes for a pretty > easy convolution. The coefs are -0.23, 0.54, -0.23 >
Yes. But isn't it a shifted function? That is, the zero reference for the cosine functions is the middle of the window not the start of the windowed sequence. From the shift theorem -> The shift of half the sequence length in the impulse domain is equal to multiplication in the frequency domain by fs/2. -jim ----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==---- http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups ----= East and West-Coast Server Farms - Total Privacy via Encryption =----
>rajgerman wrote: >> Thanks for that information but I'm still a little confused. >> >> The thing is I have a brain signal which is an audio file which I have >> fast fourier transformed. Now what I have to do is apply the Hamming >> window to that. How would I do that using MATLAB?? It seems confusing. > >If x is the brain signal, then windowing with Hamming window in Matlab >is simply > >y = x.*hamming(length(x),'periodic'); > >Was that the question? Or is your problem that you only have access to >the FFTed brain signal X? In that case > >Y = fft( ifft(X).*hamming(length(X),'periodic') ) ; > >is equal to the windowed spectrum. Don't forget the 'periodic' flag for >the window function, Matlab otherwise returns asymmetric windows (which >you paradoxically specified as 'symmetric'). > >Regards, >Andor > >
Cheers Andor I think that was really helpful. My brain signal is y. x = y.*hamming(length(y),'periodic'); I have also ffted the brain signal. But would it be more useful to apply a hamming window on the normal signal or the ffted signal and why??
What Fred and I each have said, is that you may either:

1)  multiply your data on a sample by sample basis by the samples comprising 
the Hamming window and then FFT the product.

or


2) convolve your FFTed data with the 3 coefs  -0.23, 0.54, -0.23 that are 
the frequency domain version of the Hamming window. You will need to know 
how your FFT orders its data so the convolution can be applied properly.

Clay



"rajgerman" <rajgerman@msn.com> wrote in message 
news:fvGdnWpwjJP7A2TenZ2dnUVZ_tSdnZ2d@giganews.com...
> So are you saying that I do not need to fast fourier transform the audio > signal, but apply the hamminng window first and the nfast fourier > transform?? > > Sorry guys but I'm not to familiar with these topics but thanks for your > help. > > If any of you would provide me their email address I could send you the > files to show you what I mean.
"jim" <"sjedgingN0sp"@m@mwt.net> wrote in message 
news:1140434886_6749@sp6iad.superfeed.net...
> > > "Clay S. Turner" wrote: > >> Hello Fred, >> >> Since the Hamming window is defined in terms of cosines, the Freq domain >> version turns out to have only 3 non-zero coefs. This makes for a pretty >> easy convolution. The coefs are -0.23, 0.54, -0.23 >> > > Yes. But isn't it a shifted function? That is, the zero reference for > the cosine functions is the middle of the window not the start of the > windowed sequence. From the shift theorem -> The shift of half the > sequence length in the impulse domain is equal to multiplication in the > frequency domain by fs/2. > > -jim
Hello Jim, Likewise the zero reference for the frequency domain data is also the middle. This presents no issues. Since you have the data in total before convolving, you can perform a zero delay operation. Just do a cyclic convolution. One needs to be careful about the ordering of the data from the FFT. But even in the case where one takes the FFT data (negative, DC, then positive frequencies) and runs it through a 3 tap FIR filter with the above coefs, the windowed result only has a 1 sample delay compared to the non windowed data. It is all in knowing where the zero reference points are. Clay
>What Fred and I each have said, is that you may either: > >1) multiply your data on a sample by sample basis by the samples
comprising
>the Hamming window and then FFT the product. > >or > > >2) convolve your FFTed data with the 3 coefs -0.23, 0.54, -0.23 that are
>the frequency domain version of the Hamming window. You will need to know
>how your FFT orders its data so the convolution can be applied properly. > >
Cheers Clay I think I much better idea now. How would I though convolve the FFTed data with the 3 coefs -0.23, 0.54, -0.23?? My FFTed data is Y = fft(y);
> > Cheers Clay > > I think I much better idea now. How would I though convolve the FFTed data > with the 3 coefs -0.23, 0.54, -0.23?? > > My FFTed data is Y = fft(y);
If your FFT is like most, the output vector is in an order like 0,1,2,3,...,N/2,-N/2+1,-N/2+2,-N/2+3,...-3,-2,-1 where the numbers above are the frequencies. Other FFTs may have the output in an order like -N/2+1,-N/2+2,-N/2+3,...,-3,-2,-1,0,1,2,3,...,N/2 In both of these cases I've assumed the length N is even. You will need to know how yours is done. Now the convolution goes likes this new H(0) equals 0.54*H(0) - 0.26*(H(-1)+H(1)) new H(1) equals 0.54*H(1) - 0.26*(H(0)+H(2)) new H(2) equals 0.54*(H(2) - 0.26*(H(1)+H(3)) and so on. Whenever the index exceeds N/2 just wrap it back around. For example N/2+1 becomes -N/2+1. Be careful to not use the new value as an input in one of the calculations. All of the inputs are the old values. IHTH, Clay

Clay S. Turner wrote:
>> It's not likely that you want to window the FFTd sequence - as in multiply >> the FFTd sequence. >> It's much more likely that you want(ed) to window the temporal sequence >> (as in multiply) before the FFT. >> Or you could convolve in frequency to get the same affect. >> >> FFT both the temporal data sequence and the temporal window. >> Convolve the two in frequency. >> > > Hello Fred, > > Since the Hamming window is defined in terms of cosines, the Freq domain > version turns out to have only 3 non-zero coefs. This makes for a pretty > easy convolution. The coefs are -0.23, 0.54, -0.23
The three coeficients aren't real are they? The center one is but I seem to remember that the side ones were complex. False memory? Bob -- "Things should be described as simply as possible, but no simpler." A. Einstein
Hi there,

I you plan on analyzing your signal in MATLAB then you can use the
function PWELCH to estimate the power spectrum density of your signal.
This function automatically implements the hanning window and estimates
the PSD for you (as well as plot it):

http://www.mathworks.com/access/helpdesk/help/toolbox/signal/pwelch.html

This estimate is much better than  a simple periodogram. Note that you
need the Signal Processing Toobox to use it...

You can send me the files if you want me to take a look.

-ikaro

rajgerman wrote:
> Could anyone explain the Hamming window in REALLY simple terms and why it > is useful ...
Note that an FFT is usually interpreted as the frequency content of a vector of samples as if these samples were repeated. However, if the first and last sample don't line up (as in a content of n and 1/2 sine waves in your sample window) there will be a sharp transition between the last and first sample of the repeat, which after an FFT might look like some sort of high frequency spike or noise. A Hamming window is a smooth way of rounding down the ends of your sample set to smaller values so that the first and last sample look closer to being continuous, and certain portions of the frequency content (the first hump) of any sharp transistion between the first and last sample are minimized. The rounding off of the edges has to be smooth because any shape will introduce frequency artifacts of their own. A Hamming window is one compromise out of many windows which might help with this method of frequency analysis. Triangular and trapeziodal chopping down of the ends of your bunch of samples is another easy but less smooth and thus lower quality method of doing this. IMHO. YMMV. -- rhn A.T nicholson d.0.t C-o-M