A group of connected audio node objects used to generate and process audio signals and perform audio input and output.


class AVAudioEngine : NSObject


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

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

  • If you remove an audio node that has differing input and output channel counts, or that is a mixer, the result is likely to 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 an 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 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.

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.

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

A Boolean value that indicates whether the audio engine is running.

func pause()

Pauses the audio engine.

func stop()

Stops the audio engine and releases any previously prepared resources.

func reset()

Resets all of the audio nodes in the audio engine.

Manually Rendering an Audio Engine

func enableManualRenderingMode(AVAudioEngineManualRenderingMode, format: AVAudioFormat, maximumFrameCount: AVAudioFrameCount)

Sets the engine to operate in manual rendering mode with the specified render format and maximum frame count.

func disableManualRenderingMode()

Sets the engine to render to or from an audio device.

func renderOffline(AVAudioFrameCount, to: AVAudioPCMBuffer) -> AVAudioEngineManualRenderingStatus

Makes a render call to the engine operating in the offline manual rendering mode.

Getting Manual Rendering Properties

typealias AVAudioEngineManualRenderingBlock

A block to render the engine when operating in manual rendering mode.

var manualRenderingBlock: AVAudioEngineManualRenderingBlock

A block to render the engine when operating in manual rendering mode.

var manualRenderingFormat: AVAudioFormat

The render format of the engine in manual rendering mode.

var manualRenderingMaximumFrameCount: AVAudioFrameCount

The maximum number of PCM sample frames the engine can produce in any single render call in manual rendering mode.

var manualRenderingMode: AVAudioEngineManualRenderingMode

The manual rendering mode configured on the engine.

var manualRenderingSampleTime: AVAudioFramePosition

An indication of where the engine is on its render timeline in manual rendering mode.

var isAutoShutdownEnabled: Bool

A Boolean value that indicates when autoshutdown is enabled.

var isInManualRenderingMode: Bool

A Boolean value that indicates whether the engine is operating in manual rendering mode.

Using Connection Points

class AVAudioConnectionPoint

A representation of either a source or destination connection point in the audio engine.

func connect(AVAudioNode, to: [AVAudioConnectionPoint], fromBus: AVAudioNodeBus, format: AVAudioFormat?)

Establish connections between a source node and multiple destination nodes.


static let AVAudioEngineConfigurationChange: NSNotification.Name

A notification posted when the audio engine configuration changes.


enum AVAudioEngineManualRenderingError

Constants that describe error codes that could be returned from manual rendering mode methods.

enum AVAudioEngineManualRenderingMode

The two modes for manual rendering.

enum AVAudioEngineManualRenderingStatus

Status codes returned from the render call to the engine operating in manual rendering mode.


Inherits From

Conforms To

See Also

Multitrack Playback and Recording

Audio Engine Building Blocks

Add audio input, processing, and output to an audio engine instance.

Using Voice Processing

Add voice processing capabilities to your app by using AVAudioEngine.

Building a Signal Generator

Use AVAudioSourceNode and a custom render callback to generate audio signals.

Performing Offline Audio Processing

Add offline audio processing features to your app by enabling offline manual rendering mode.

class AVAudioNode

An abstract class for an audio generation, processing, or I/O block.

class AVAudioUnit

A subclass of the audio node class that, depending on the type of the audio unit, processes audio either in real time or non-real time.