Programmatically Create Aggregate Audio Devices In Swift Using CoreAudio

南楼画角 提交于 2020-01-03 18:37:19

问题


I am researching creating multi-output devices on either OS X or iOS, and I found out that CoreAudio would allow you to create aggregate devices. My first question is, does iOS allow you to do this. I know that this is certainly possible on OS X, but I've heard that iOS will not allow it. I would really appreciate an example of how you would go about detecting multiple audio output devices and creating an aggregate device, all using swift. I have checked here, but it doesn't fully answer my question, and the answer it does have is based on Objective-C. I'd appreciate any help, and thanks in advance!


回答1:


The aggregate audio device API is not publicly available on iOS, so you cannot create those devices yourself.

However iOS will create aggregate devices* for you depending on the most recently attached audio hardware and some other rules if you activate an AVAudioSession that uses the .multiRoute category.

When you get a route change notification due to an audio interface being added or removed, you can create a remote IO audio unit with the right number of channels. I haven’t tried using multi route audio with AVAudioEngine nor have I tried using only a subset of the available channels.

* They’re probably aggregate devices, although you never see them or interact with them directly.



来源:https://stackoverflow.com/questions/38810339/programmatically-create-aggregate-audio-devices-in-swift-using-coreaudio

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