gpt4 book ai didi

ios - 如何在 iOS 的多 channel 混音器中实现缓冲?

转载 作者:行者123 更新时间:2023-11-29 13:48:37 26 4
gpt4 key购买 nike

我正在使用 MixerHostAudio 同时加载多个音频文件。

我无法将整个文件加载到内存中,因为应用程序崩溃了!

谁能帮我实现一个缓冲文件的算法?

或者至少给我举个例子?

我设法做到了这一点:

我指出了调用渲染函数的代码:

    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;
}

--- 现在我只缺少缓冲完成时的部分,我可以告诉程序获取下一个 block ....

有什么想法吗?

谢谢

埃尔南

最佳答案

您需要使用环形缓冲区来处理您的音频。

这里有一个简单的例子。

ring buffer

关于ios - 如何在 iOS 的多 channel 混音器中实现缓冲?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6103597/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com