Example of saving audio from RemoteIO?

与世无争的帅哥 提交于 2019-12-22 19:26:09

问题


I've searched around but haven't found any good examples or tutorials of saving audio out of a RemoteIO Audio Unit.

My setup: Using the MusicPlayer API, I have several AUSamplers -> MixerUnit -> RemoteIO

Audio playback works great. I would like to add functionality to save the audio output to a file. Would I do this in a render callback on the RemoteIO?

Any tips or pointers to example code much appreciated!


回答1:


Due to the tight latency requirements of Audio Unit callbacks, one should not to do any synchronous file access (or any other calls that could potentially block, involve memory management or OS locking actions) inside the RemoteIO callback. Instead, just copy the audio data out to another buffer (a larger circular buffer for example), and set some state indicating how much data has been copied. Then, in another thread, when the amount of data is sufficient, write the contents of that buffer out to a file. This could be a raw PCM file, which can later be converted by AVAssetReader/Writer into another audio file type.



来源:https://stackoverflow.com/questions/10045369/example-of-saving-audio-from-remoteio

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!