Question

I am using FMOD for audio analysis, using system::getSpectrumto get the frequency data. My question here is about what data does FMOD use behind the scene to perform the FFT. For example, if my output rate is at 44100Hz and I call getSpectrum() 30 times a second (every 0.03333 seconds) with 1024 samples:

system.getSpectrum(data, 1024, 0, FMOD_DSP_FFT_WINDOW_BLACKMANHARRIS);

Does FMOD just take the last 1024 PCM samples that were played and perform the FFT on those? In this case, if 1470 samples were actually read and played between getSpectrum() calls, only the last 1024 samples are dealt with and we lose the info on the intermediate 446 floats. Then the precision of the interval at which I call getSpectrum becomes incredibly important, because I don't get the same results if I call it after 0.033 seconds onnce and after 0.034 seconds the next, which makes the whole thing very dependent on FPS and totally undetermined. Can anyone provide me with insight on the under-the-hood mechanics of FMOD and how to get this to be deterministic?

Was it helpful?

Solution 2

I had to contact FMOD support for the answer. I short, FMODs FFT is updated every 1024 samples, and it is up to me to get the new data ASAP, and check if it's different from thelast time I got it.

Link to Question on FMOD Forums

OTHER TIPS

Normally, if you are processing audio data at approximate video frame intervals or other similar timer events, you first calculate the number of new audio samples that have arrived (plus any samples left over from previously), divide by the FFT frame length and/or offset, truncate to an integer, and process that many frames, and save the remainder of unprocessed samples for the next processing time so you don't "lose info on them".

You usually don't just call your FFT once per 30 Hz callback without checking the amount of new audio samples and buffering them as needed.

If you don't want the graphic display to jitter, you will have to do some interpolation among the audio frame results, and/or synchronize your audio and video clocks more precisely while using frame offsets that divide in nicely.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top