How do I create an AUAudioUnit that implements mul

2019-05-07 00:46发布

In Apple's docs for creating an AUAudio Unit (Here: https://developer.apple.com/documentation/audiotoolbox/auaudiounit/1387570-initwithcomponentdescription) they claim that

A single audio unit subclass may implement multiple audio units—for example, an effect that can also function as a generator, or a cluster of related effects.

There are no examples of this online that I can find. Ideally it would be nice if your answer/solution involved using Swift and AVAudioEngine but I'd happily accept any answer that gets me moving in the right direction.

Thanks in advance.

1条回答
Viruses.
2楼-- · 2019-05-07 01:00

I posted some source code to my test app which instantiates an AVAudioUnit generator subclass object using AVAudioEngine, Swift and C, on GitHub here:

https://github.com/hotpaw2/auv3test5

Note that Apple recommends NOT using Swift inside the real-time audio context, so that portion of my source code is written in C, inside an Objective C wrapper class.

If you use initWithComponentDescription:options:error:, you can pass an option to configure your new audio unit subclass object to do whatever (using something like a switch statement on the option).

查看更多
登录 后发表回答