views:

1116

answers:

4
+2  A: 

FFT's because they are windowed and sampled cause aliasing and sampling in the frequency domain as well. Filtering in the time domain is just multiplication in the frequency domain so you may want to just apply a filter which is just multiplying each frequency by a value for the function for the filter you are using. For example multiply by 1 in the passband and by zero every were else. The unexpected values are probably caused by aliasing where higher frequencies are being folded down to the ones you are seeing. The original signal needs to be band limited to half your sampling rate or you will get aliasing. Of more concern is aliasing that is distorting the area of interest because for this band of frequencies you want to know that the frequency is from the expected one.

The other thing to keep in mind is that when you grab a piece of data from a wave file you are mathmatically multiplying it by a square wave. This causes a sinx/x to be convolved with the frequency response to minimize this you can multiply the original windowed signal with something like a Hanning window.

Rex Logan
+2  A: 
tom10
You raise a good point that the quickest and easiest test of whether the FFT is clipping, aliasing, or adding noise to the signal is simply to take the FFT of the signal, then inverse transform it and see if you recover the original signal. My gut feeling is that the FFT is working perfectly and that this is simply a case of misinterpreting the output of the FFT.
las3rjock
+1  A: 

It's worth mentioning for a 1D FFT that the first element (index [0]) contains the DC (zero-frequency) term, the elements [1:N/2] contain the positive frequencies and the elements [N/2+1:N-1] contain the negative frequencies. Since you didn't provide a code sample or additional information about the output of your FFT, I can't rule out the possibility that the "noisy power values at non-existent frequencies" aren't just the negative frequencies of your spectrum.


EDIT: Here is an example of a radix-2 FFT implemented in pure Python with a simple test routine that finds the FFT of a rectangular pulse, [1.,1.,1.,1.,0.,0.,0.,0.]. You can run the example on codepad and see that the FFT of that sequence is

[0j,                    Negative frequencies
(1+0.414213562373j),    ^
0j,                     |
(1+2.41421356237j),     |
(4+0j),                <= DC term
(1-2.41421356237j),     |
0j,                     v
(1-0.414213562373j)]    Positive frequencies

Note that the code prints out the Fourier coefficients in order of ascending frequency, i.e. from the highest negative frequency up to DC, and then up to the highest positive frequency.

las3rjock
Good point. Also, in numpy, the function fftfreq returns the frequency bins in the order returned from the fft function.
tom10
Thanks, seems to be working quite well with calculated waves of mine, but I still have problem with processing even synthetic wave files, either I have a problem with my file processing routine or the wave editor itself. Even if there is not and this is the leakage I can not get around, I still need to find a safe way exclude non significant values. It looks worse with logarithmic scale of course.
M. Utku ALTINKAYA
+1  A: 
Trevor Boyd Smith
"Mirror images" of the signal? A clipping sine wave (as shown) would produce harmonic distortion.
endolith