views:

86

answers:

2

Hi,

I have a question regarding use of FFT. Using function getBand(int i) with Minim i can extract the amplitude of a specific frequency and do pretty maps of it. Works great.

However, this is a more of a curiosity question. When i look at the values extracted from playing the same song two twice using the same frequency (so the amplitude should be identical) but i get very different values - why is this?

0.0,0.0,0.0,0.0,0.0,0.08706585,0.23708777,0.83046436,0.74603105,0.30447206
0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.08706585,0.4790409,0.9608221,0.83046436,0.74603105
+3  A: 

Are you sure the inputs are exactly the same in both cases ? If you're just taking a random segment of a song then the output of an FFT will be very different for different starting points in the song.

Paul R
Yes input is "exactly" (it's an mp3 file - which i start playing from the start and killing somewhere after a few seconds, but should not the FFT up until that point when i kill it be the same then?), this is more or less the same code I wrote (i would post it but i don't have access to it right now): http://code.compartmental.net/minim/examples/FFT/ForwardFFT/ForwardFFT.pde
Anders
You would need to have the same number of samples each time, and the value of each sample would have to be identical for both runs. If you don't start sampling at exactly the same sample each time then the FFT output will be different. You also need to make sure that you are processing a complete buffer each time. You should probably test that your FFT is behaving correctly by using a suitable test input, e.g. synthesize a sine wave, and verify that you get the correct output.
Paul R
Voted up, thanks for the answer + comments.
Anders
+2  A: 

The mp3 decoding could be flaky and/or the lead-in buffering of the fft routine could be flakey, (different length of silence preceeding the series). In this case it looks like the lead-in is around 2 steps greater in the 2nd output.

Then, if the time interval at which the ffts are performed is longer than the fft window size, a difference in the lead-in can cause the fft windows to land on quite different parts of the series, which could explain the very different values later in the outputs.

The situation should be clearer if you can increase the 'time resolution' (amount of ffts performed per given time) -or increase the fft window size, so the fft measurements arent done sparsely. Idealy they should overlap before we could expect to match a pattern between scans done out of step.

strainer
Voted up, thanks for the answer.
Anders