# Am I handling offline FFT correctly?

I need some help clarifying FFTs and what they represent. I have a buffer containing compressed audio. Due to limitations, I can't handle the full uncompressed audio but can decompress small segments at a time.

Lets say I take 10 seconds of uncompressed samples, I would need to store this in PCMaudiobuffer of size 10 * 44100 * sizeof(float) and I'd have 441000 samples. I then loop through these 441000 samples with a length of 1024 (with a 512 overlap).

for(int i =0; i < 441000; i += 512)
{
//code to copy (i + 1024) from PCMaudiobuffer to tempbuffer. (not shown)

//perform FFT
InPlaceFFT(tempbuffer);

//copy the first 512 values of the tempbuffer across to
//a new buffer so tempbuffer can be reused in the loop
CopyArray(512, finalbuffer);
}


Assuming all of this is correct, this is where I'm confused. Am I right in copying only the first 512 values (N/2) to the finalbuffer? (I'm using the Accelerate framework's FFT method). Is this an efficient/correct way of performing FFTs offline? Lastly, I want to be able to create a frequency spectrum from finalbuffer. To do this do I simply loop through every 44100 (1 second) and calculate the magnitude, or is 1 second generally too inaccurate for a frequency spectrum?

I may be misunderstanding all of this, so feel free to tell me to throw all this out the window :) Thanks for any help, this is quite confusing!

Edit The Apple docs on this aren't easy to follow, but I'm using the method outlined here in vDSP_fft_zrip. (The formatting of the Apple site sometimes messes up the anchor position, so you may have to scroll down slightly). I found this post to be a helpful guide on how to use it. Thanks.

• Could you add some context of exactly what signal processing steps you're trying to implement? It's hard for anyone to say how you should move data in and out of your FFTs without an indication of what the overall desired effect is. With regard to your question about calculating a frequency spectrum, the FFT can be used to do that; some more specification of what you're looking for is useful. Do you want a time-frequency representation of the signal, do you want a high-resolution spectrum of the whole signal, etc. – Jason R Sep 26 '11 at 15:19
• Hey Jason. I'd like to be able to perform onset detection offline. The detection starts off relatively simple - just check if certain frequencies are above a threshold but may get a bit more complex by using spectral flux. So, the user would provide an mp3 and, as fast as possible, my system would be able to give all the timings of when an onset occurs. Whilst I don't need to render the time-frequency representation, I think the data would need to be in that format anyway for me to be able to get the seconds at which there's an onset. – XSL Sep 26 '11 at 16:33