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.