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.
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).
来源:https://stackoverflow.com/questions/46761477/how-do-i-create-an-auaudiounit-that-implements-multiple-audio-units