views:

37

answers:

1

I'm trying to read a .caf file as an array of float values in order to perform an FFT and retrieve some pitch data. The .caf file is saved as LinearPCM using the AVRecorder class. How in the world do I go about doing this? Reading up on the structure of the .caf files I understand that their is a file header which will need to be ignored, as well as many headers for individual 'chunks' of audio data. Is there any way to determine where the headers are? The recorded audio files are only going to be a few seconds long so their shouldn't be more than one chunk, but I can't seem to find a reference for .caf structure which goes into more details than the Apple Reference Library.

+1  A: 

You want to use the Extended Audio File API

http://developer.apple.com/iphone/library/documentation/MusicAudio/Reference/ExtendedAudioFileServicesReference/Reference/reference.html#//apple_ref/c/func/ExtAudioFileRead

This will do it really easily. There is no reason to try to parse the file manually.

Joshua Weinberg
Use ExtAudioFile to read the file and get the sample data. Linear PCM data could be in any number of float or integer formats, so you might need to convert to the floating point representation you need.
lucius
You can also use AUGraph with offline rendering and a converter node.
Joshua Weinberg