ioscore-audioavaudioengineauv3

Host AUv3 audio extension and connect to parameter tree


I'm starting to write an AUv3 audio extension and follow the template in Xcode 11.3 that did all the heavy lifting. The extension works well when loaded to other hosts! Now I want to use my own extension in my app and simple play an audio file through, but I have trouble and tearing my hair since a few days (and nights) on how to access the parameters.

I use the AVplayer and AVengine and instantiate the AudioUnitExtension like this:

    // instantiate AudioUnit as AVAudioUnit
[AVAudioUnit instantiateWithComponentDescription:audioDescription options:1 completionHandler:^(AVAudioUnit * audioUnit, NSError *error) { ... do more stuff here}];

To my surprise the createAudioUnitWithComponentDescription method in my extension is not called?! But when I connect it to the AVengine:

[self->_engine attachNode:self->_AV_AudioUnit];

The audio is passing and the effect is applied but in the AVAudioUnit there is no parameter tree so I can not change any processing parameters. It seams that AVAudioUnit != AUAudioUnit and does not have a parameter tree. But the AVengine only allows AVAudioUnits to work with!

I've looked through Apples example and web but could not find any helpful ... would be great if someone could point me to a direction how to set this up!


Solution

  • It took me some long nights to find the cause: The audioUnit can not dynamically be loaded in the same app, that's why the debugger would not stop at breakpoints inside the AU-Unit extension.

    To get the view controller I've instantiated a AV-AudioUnit first and then used a wrapper to get the AU-AudioUnit

    WWDC2015 That AV Audio Unit effect in turn exposed an underlying AU Audio Unit, which is the maiden class of the version 3 Audio Unit API.

    This is done here:

            // wrapper - to get the AU-unit from AV-Unit
        self->_AU_AudioUnit = audioUnit.AUAudioUnit;
    

    Then loading the corresponding ViewController

            // get the corresponding Viewcontroller
        [self->_AU_AudioUnit requestViewControllerWithCompletionHandler:^(AUViewControllerBase * _Nullable viewController) { ... do presenting in container view here }]
    

    I hope this will help someone not spending so much time than I did!