Contents

instantiate(with:options:completionHandler:)

Creates an instance of an audio unit component asynchronously and wraps it in an audio unit class.

Declaration

class func instantiate(with audioComponentDescription: AudioComponentDescription, options: AudioComponentInstantiationOptions = [], completionHandler: @escaping  @Sendable (AVAudioUnit?, (any Error)?) -> Void)
class func instantiate(with audioComponentDescription: AudioComponentDescription, options: AudioComponentInstantiationOptions = []) async throws -> AVAudioUnit

Parameters

  • audioComponentDescription:

    The component to create.

  • options:

    The options the method uses to create the component.

  • completionHandler:

    A handler the framework calls in an arbitrary thread context when creation completes. Retain the Avaudiounit this handler provides.

Discussion

You must create components with flags that include requiresAsyncInstantiation asynchronously through this method if they’re for use with AVAudioEngine.

The AVAudioUnit instance is usually a subclass that the method selects according to the components type. For example, AVAudioUnitEffect, AVAudioUnitGenerator, AVAudioUnitMIDIInstrument, or AVAudioUnitTimeEffect.