I have a situation where at any one time my AudioUnit can be represented by only a few parameters or literally many 100s.
This dynamic situation is under the control of the user and the maximum number of parameters and their hierarchy cannot be predicted in advance. ( at least not accurately ).
When the parameters are to change I am setting the parameterTree property by creating a new tree with the child nodes and posting KVC notifications …
.. create childGroups …
[self willChangeValueForKey:@"parameterTree"];
self.parameterTree = [AUParameterTree createTreeWithChildren: childGroups ];
[self didChangeValueForKey:@"parameterTree"];
Most the of the app’s User Interface and AudioUnit is coded in Swift, the engine is in coded in C/C++ with an objectiveC AUAudioUnit class that acts as the go between hence the above.
However there is a popular host app that crashes when I do this and it looks like the host is hanging on to the parameterTree object that’s it’s passed originally when the AU first launches but never updates it even after the KVC notifications are posted.
So after that long explanation… Am I doing this correctly? OR Is there a solution that can create and rebuild a tree without making a new AUParameterTree object?
If I can do that the host in question may not crash, ( although it might anyway because all the parameters have changed ).
I have posted a code example to the host developer but sadly got a response which gave me the impression he was not prepared to work on a fix.
Thanks!
Pretty sure replacing a ParameterTree is a supported feature. And it seem only way to rebuild it is to fully replace it. This is from the headers:
"The tree's elements are mostly immutable (except for values and implementor hooks); the only way to modify them is to publish a new tree."
I'm curious, which host is crashing?
I don't see how holding on to an old AUParameterTree object would cause a crash. Unless the host code that keeps a reference uses __unsafe_unretained.