Contents

SKAudioNode

A node that plays audio.

Declaration

class SKAudioNode

Mentioned in

Overview

A SKAudioNode object is used to add an audio to a scene. The sounds are played automatically using AVFoundation, and the node can optionally add 3D spatial audio effects to the audio when it is played.

The currently presented SKScene object mixes the audio from nodes in the scene based on parameters defined in the AVAudio3DMixing protocol. A scene’s audioEngine property allows overall control of volume and playback.

By default, SKAudioNode objects are positional, i.e. their isPositional property is set to true. If you add an audio node to a scene with a listener set, SpriteKit will set the stereo balance and the volume based on the relative positions of the two nodes.

You can explicitly set the volume or stereo balance to an audio node by running actions on it.

SpriteKit includes actions that reduce an audio node’s volume by changing either its occlusion or obstruction. The difference between these actions is that occlusion affects both the direct and reverb paths of the sound while obstruction only affects the direct path. The change volume action offers absolute control over an audio node’s volume.

You can manually set the stereo balance of an audio node with a stereo pan action.

Special effects, such as speeding up or slowing down audio by changing the playback rate and adding reverb are also available as audio actions.

To learn more about audio actions, see Controlling the Audio of a Node in Action Initializers.

Topics

First Steps

Initializing Audio Nodes

Configuring Audio Nodes

Initializers

See Also

Nodes for Environmental Effects