I'm trying to build a Render Callback function that will load a variety of short sound files, and (according to my custom logic) put them in my mixer Unit's iOData audioBufferList. How do I load an aif or caf file into the program, and appropriately import its samples into the ioData?
Asked
Active
Viewed 653 times
1 Answers
2
See Extended Audio File Services Reference, particularly "ExtAudioFileOpenURL" and "ExtAudioFileRead". Remember not to do anything too time consuming in the render callback (e.g. opening a file may be considered time consuming, allocating memory definitely is).

Jon Burgess
- 2,035
- 2
- 17
- 27
-
Right, so I can use the Audio File Services to load my audio files in ViewDidLoad:, but what about the second part of my question? Would I use ExtAudioFileRead, and point the iOData at the Render callback's ioData object? – DanF Feb 24 '11 at 16:05
-
1@DanF Yes, e.g.: `OSStatus renderCallback(..., AudioBufferList *ioData) { ...; UInt32 numFrames = inNumberFrames; ExtAudioFileRef audioFile = // Your file ref previously opened with ExtAudioFileOpenURL OSStatus result = ExtAudioFileRead(audioFile, &numFrames, ioData); // Check for error // numFrames actually read may be less than request (e.g. if EOF) }` – Jon Burgess Feb 25 '11 at 02:00