Both the AUAudioUnit and AVAudioUnit APIs look really similar,
what's the difference? When to use which one?
An AVAudioUnit is connected as a node in an AVAudioEngine. An AUAudioUnit is typically connected in an AUGraph. The functionalities should be similar, as both are audio units, but using an AVAudioEngine is the modern way of audio control in iOS and therefore AVAudioUnits have a more modernized API behind them.
I'm sure there are use cases where one can be preferred over the other, but I'd say use AVAudioUnits unless there's something specific you need that they don't provide. The customizability of AUAudioUnits and their processing graph is great, but in my experience comes with a steep learning curve and a lot more code. Many sleepless nights I've spent inspecting my AUGraphs, but AVAudioEngine has been very kind to me.
Also, AVAudioNodes, and therefore AVAudioUnits, are not functional until attached to a AVAudioEngine, however you can set up AUAudioUnits without an AUGraph using render callbacks.
Note that AUAudioUnit
represents a V3 audio unit, even though it starts with 'AU'. It is available in iOS 9. Older APIs also start with 'AU' (such as AUSampler) but they are V2.
In general in your app you should use AVAudioUnit
. Note that it is available only in iOS 8+. As tnev mentioned above, you can use the AVAudioNode
classes to easily set up AVAudioEngine
. You cannot do this with AUAudioUnit
.
If you are writing your own audio unit you should use AUAudioUnit
by subclassing it.
EDIT: Also use AUAudioUnit
if you intend to display the viewController of V3 audio units.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With