Play an audio file using RemoteIO and Audio Unit

偶尔善良 提交于 2019-12-03 09:09:52

You just need to convert your audio file to pcm data and then feed that data to the RemoteIO interface during the playback callback.

To read your audio file in, you will want to use ExtAudioFileOpenURL and ExtAudioFileRead. Also make sure to set your audio format with ExtAudioFileSetProperty to convert to your target pcm format (which should be packed, signed integer PCM data).

Playback simply involves responding to the RemoteIO callback (which should be identical to aurioTouch's example) and feeding it the PCM data you loaded up.

The only other tricky part is that loading an entire mp3 file as PCM can take up a ton of memory. You might have to write a loading thread so that you can stay under your memory requirements by only loading your relevant chunk of the mp3.

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