Update your Audio Unit (AU) host app to take advantage of the new features and capabilities of AUv3.
The latest Audio Unit standard, AUv3, provides a robust plug-in model built on app extensions. This model provides several benefits to host apps, including greater security and stability, multiple view configurations, and support for shared user presets.
You can adopt the new API while still retaining your ability to host AUv2 audio units. The framework’s bridging layer enables this capability by automatically translating AUv3 calls into their AUv2 equivalents, which means you can use a single API and work with both new and legacy audio units.
For a downloadable sample app that uses the core features of the AUv3 API, see Incorporating Audio Effects and Instruments.
Find Audio Units
The AVFoundation framework’s
AVAudio class provides a convenient way to find audio components registered with the host system. You use it to search for audio units by description, predicate, or test case, and the component manager returns an array of
AVAudio objects matching your search criteria. The following code example shows how to use each approach to find all audio effects available on the system.
Instantiate Audio Units
Once you've found the list of available audio components, the next step is to instantiate the component you want to use. To instantiate the audio unit, use the
instantiate method as shown below.
Interact with an Audio Unit
The way you interact with audio units using the AUv3 API differs from how you do so with the AUv2 API. With AUv2, you used C functions to operate on an audio unit. For example, the following code sets the maximum number of frames to render using the AUv2 API.
In comparison, the AUv3 API provides a more natural interface that enables you to interact directly with the audio unit instance by calling its properties and methods. Using the AUv3 API, you set the maximum number of frames to render as shown below.
The following table lists the AUv2 function and its AUv3 method or property equivalent.
Allocates the audio unit's needed resources.
Frees the audio unit's rendering resources.
Renders audio samples in a real-time context.
Resets the audio unit's state.
Schedules a change to an audio unit parameter value.
Modifies an audio unit property value.
Accesses the parameter tree object that's used to get and set parameter values.
Present the Audio Unit’s User Interface
To present the audio unit's user interface, call its
request method. This method asynchronously retrieves the audio unit's view controller instance and returns it in a callback closure. The callback is invoked on a background thread, so you need to dispatch control back to the main queue before adding the audio unit’s user interface into your app’s view hierarchy.