如何在 iOS 上的多通道混音器中实现缓冲?
我使用 MixerHostAudio 同时加载多个音频文件。
我无法将整个文件加载到内存中,因为应用程序崩溃了!
有人可以帮助我实现缓冲 thesae 文件的算法吗?
或者至少给我举个例子?
我设法做到了这一点:
我确定了调用渲染函数的代码:
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 for 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;
}
---现在我只缺少缓冲完成时的部分,我可以告诉程序获取下一个块......
有什么想法吗?
谢谢埃尔南
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 for 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用环形缓冲区来处理音频。
这里有一个简单的例子。
环形缓冲区
You need to use a ring buffer to process your audio.
There is a simple example to be found here.
ring buffer