How to create an AUAudioUnitBusArray with variable number of buses

In the documentation for AUAudioUnitBusArray, there is this passage:

Some audio units (e.g. mixers) support variable numbers of busses, via subclassing.

I tried to implement this by subclassing AUAudioUnitBusArray, creating my own internal array to store the buses, and overriding isCountChangeable to true and setBusCount to now increase the number of buses if the count is less than the current count. However, I don't think this will work because AUAudioUnitBus has several properties that I can't set such as ownerAudioUnit and index. I would also have to change all the observer functions like addObserver(toAllBusses:forKeyPath:options:context:), which seems overkill for a class that is designed for subclassing.

I know about replaceBusses(busArray:) but wouldn't that override the current buses in the bus array since it's copying them?

Replies

The documentation is referring to subclassing of the audio unit, not the AUAudioUnitBusArray. The bus array object (including the number of elements) is under control of the audio unit, and is not intended to be changed except by the audio unit itself, if it supports that. Similarly, replaceBusses(busArray:) is used by (possibly subclassed) audio units to change their own bus array.

  • But then why is there an isCountChangeable member of AUAudioUnitBusArray whose discussion mentions that "The base implementation default value is false"?

Add a Comment