Reputation: 681
I want to read data from wave, mp3, and aiff files and use this data for fft. AudioToolbox Framework looks good, but there is a lot of different and similar functions and its confusing for me.
Can you help me with list of functions ? So I need to get numberOfFrames, channel, sampleRate, bitRate and array with audioData.
thanks.
Upvotes: 0
Views: 663
Reputation: 316
You need to load your file, and get property and read.
ExtAudioFileRef myfile;
ExtAudioFileOpenURL(yourURL, &myfile);
// after you get a AudioStreamBasicDescription
AudioStreamBasicDescription desc={0};
ExtAudioFileGetProperty(myfile, kExtAudioFileProperty_FileDataFormat, sizeof(AudioStreamBasicDescription), &desc);
AudioBufferList *ioData = CreateAudioBuffer(desc);
UInt32 nbFrames = 512;
while(nbFrames != 0)
{
nbFrames = 512;
ExtAudioFileRead(myfile, &nbFrames, ioData);
WorkWithFrame(ioData, nbFrames);
}
ExtAudioFileDispose(myfile);
You need to write CreateAudioBuffer with data malloc and WorkWithFrames.
I hope this can help you.
Upvotes: 1