The AVAudioEngine class defines a group of connected AVAudioNode objects, known as audio nodes. You use audio nodes to generate audio signals, process them, and perform audio input and output.


You create each audio node separately and attach it to the audio engine. You can perform all audio node operations during runtime—connecting them, disconnecting them, and removing them—with only minor limitations:

  • Reconnect audio nodes only when they are upstream of a mixer..

  • If you remove an audio node that has differing input and output channel counts, or which is a mixer, the result will likely be a broken graph.


Creating an Audio Engine Instance


Initializes a newly allocated audio engine.

Attaching and Detaching Audio Nodes

func attach(AVAudioNode)

Attaches a new audio node to the audio engine.

func detach(AVAudioNode)

Detaches a audio node previously attached to the audio engine.

Getting the Input, Output, and Main Mixer Nodes

var inputNode: AVAudioInputNode

The audio engine’s singleton input audio node.

var outputNode: AVAudioOutputNode

The audio engine’s singleton output audio node.

var mainMixerNode: AVAudioMixerNode

The audio engine’s optional singleton main mixer node.

Connecting and Disconnecting Audio Nodes

func disconnectNodeInput(AVAudioNode)

Removes all input connections of the audio node.

func disconnectNodeInput(AVAudioNode, bus: AVAudioNodeBus)

Removes the input connection of an audio node on the specified bus.

func disconnectNodeOutput(AVAudioNode)

Remove all output connections of an audio node.

func disconnectNodeOutput(AVAudioNode, bus: AVAudioNodeBus)

Remove the output connection of an audio node on the specified bus.

func connect(AVAudioNode, to: AVAudioNode, format: AVAudioFormat?)

Establishes a connection between two audio nodes.

func connect(AVAudioNode, to: AVAudioNode, fromBus: AVAudioNodeBus, toBus: AVAudioNodeBus, format: AVAudioFormat?)

Establish a connection between two audio nodes, specifying the input and output busses.

Playing Audio

var musicSequence: MusicSequence?

The music sequence that was previously attached to the audio engine.

func prepare()

Prepares the audio engine for starting.

func start()

Starts the audio engine.

var isRunning: Bool

Returns the audio engine’s running state.

func pause()

Pauses the audio engine.

func stop()

Stop the audio engine and release any previously prepared resources.

func reset()

Resets all of the audio nodes in the audio engine.


static let AVAudioEngineConfigurationChange: NSNotification.Name

Posted when the audio engine configuration changes.


Inherits From

Conforms To

See Also

Audio Engine

class AVAudioNode

The AVAudioNode class is an abstract class for an audio generation, processing, or I/O block.

class AVAudioUnit

The AVAudioUnit class is a subclass of the AVAudioNode class that, depending on the type of the audio unit, processes audio either in real-time or non real-time.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software