How to Implement Buffering in the Multichannel Mixer on iOS?
Im Using the MixerHostAudio to load Several Audio Files at the Same Time.
I Cant load the Whole files to the memory because the APP CRASHES!
Can someone help me implement an Algorythm for Buffering thesae files?
Or at least point me to an example?
I managed to get this far:
I PinPointed the Code where the call to the Rendering Function is Called:
UInt32 numberOfPacketsToRead = (UInt32) totalFramesInFile;
result = ExtAudioFileRead (audioFileObject, &numberOfPacketsToRead, bufferList);
free (bufferList);
if (noErr != result) {
[self printErrorMessage: @"ExtAudioFileRead failure - " withStatus: result];
// If reading from the file failed, then free the memory f开发者_如何学JAVAor the sound buffer.
free (soundStructArray[audioFile].audioDataLeft);
soundStructArray[audioFile].audioDataLeft = 0;
if (2 == channelCount) {
free (soundStructArray[audioFile].audioDataRight);
soundStructArray[audioFile].audioDataRight = 0;
}
ExtAudioFileDispose (audioFileObject);
return;
}
--- NOW Im only missing the part when the Buffering is finished and I Can Tell the Program to get the Next Chunk....
Any Ideas?
Thanks
Hernan
You need to use a ring buffer to process your audio.
There is a simple example to be found here.
ring buffer
精彩评论