I was looking for the reason why my v3 AudioUnit can not display a custom UI in host apps such as AUv3Host or Hosting AU...
As as result, It is seemed that my AU needs to set preferredContentSize property.
In FilterDemo, the property seems to be set in viewDidLoad in FilterDemoViewController.
So, I also set the property as follows:
By the way, in the code which was generated when we added AudioUnit App Extension,- (void) viewDidLoad {[super viewDidLoad];self.preferredContentSize = NSMakeSize(480, 272);}
viewDidLoad implementation was
However, because the audioUnit instance was always nil, the program immediately returns from viewDidLoad.- (void) viewDidLoad {[super viewDidLoad];if (!audioUnit) {return;}// Get the parameter tree and add observers for any parameters that the UI needs to keep in sync with the AudioUnit}
The audioUnit object is set in createAudioUnitWithComponentDescription:error:, which conforms to AUAudioUnitFactory protocol as follows:
But, because viewDidLoad is called earlier than when createAudioUnitWithComponentDescription:error: is called, audioUnit property remains nil in viewDidLoad.- (AUAudioUnit *)createAudioUnitWithComponentDescription:(AudioComponentDescription)desc error:(NSError **)error {audioUnit = [[MyAudioUnit alloc] initWithComponentDescription:desc error:error];return audioUnit;}
I doubt that codes automatically generated by AudioUnit App Extension target are strange (not qualified as standard AudioUnit).
I have wasted a time because I suspected auto layout or other factors.
Next, I want to add UIs to the custom view.