Reputation: 12314
I have 2 100% identical WAVE files I convert to FFT. Overlaying them I get a perfect match.
However if I chop off a non-frame sized chunk at the beginning of one of the data then the FFT's don't match (aligned from end).
I'm guessing that this is because of what frequencies are contained within the frame. If a frequency is divided amongst two frames it will show up with lower energy in both compared to if it was concentrated in one frame.
How can I compensate/bypass this effect?
Upvotes: 1
Views: 987
Reputation: 8401
You probably want to apply a window function before computing the FFT.
http://www.google.com/search?q=windowing+fft
http://en.wikipedia.org/wiki/Discrete_Fourier_transform:
"Using the DFT implies that the finite segment that is analyzed is one period of an infinitely extended periodic signal; if this is not actually true, a window function has to be used to reduce the artifacts in the spectrum. "
I think you're on the right track breaking up the signal into overlapping frames but you need to consider your matching criteria (figure out some heuristics, e.g. the 3 dominant frequencies), the size of the frames (too small and you'll miss lower frequencies, too high and you have less resolution) etc. Do some research, I'm sure many people have tackled this problem and published papers.
Upvotes: 1
Reputation: 70703
The only exact way to do this is to IFFT your data (assuming a non-lossy initial window), then re-window it and re-FFT it using the new offset. Might be better to just make a bunch of sets of FFT frames, each with a different initial offset.
Upvotes: 1
Reputation: 1260
Why would you expect the result of the Fourier transform to be identical after you cut off part of one of the samples? I'm not sure what you're trying to compensate for, that's expected behavior.
If you're comparing two samples to see how much they differ in "signature" then you probably want to normalize the result of your DFT. Sum all the energy values in each frequency bin and then divide the value in each bin by that sum, so that the sum of all the energy in the result is 1. Allows you to compare two different samples apples-to-apples regardless of length.
Note that this is only one, perhaps over-simplified, way of normalizing the DFT. There are countless others. Depending on your input data and what you plan to do with it, a log normalization might be better than a linear one.
Upvotes: 0