Immersive Audio in RealityKit 🎧

Enhance your AR apps with spatial audio in RealityKit/ARKit

Ethan Saadia
1 min readSep 23, 2019

This is part of my RealityKit Snippets collection of short code examples for getting things done in RealityKit.

Audio in RealityKit

To make your augmented reality experiences even more realistic, RealityKit has tools to incorporate sound. The sound capabilities include:

  • Loading and playing audio files
  • Adjusting sound to user orientation
  • Attaching sound to physical locations (The sound level changes as you move closer to/further away from an entity)

Add audio to an entity

Options

inputMode changes how the sound reacts to the real world.

  • .nonSpatial plays the audio normally regardless of position and orientation.
  • .ambient adjusts the left/right audio balance to follow which way the user is facing.
  • .spatial has the same features as .ambient but also changes the sound’s volume based on the user’s position. The closer the user moves toward the entity, the louder the sound.

The .spatial and .ambient modes sound best with headphones!

loadingStrategy tells RealityKit whether to preload your sounds when you first create your audio resource or to stream them as you play them. Which option you choose depends on how large your sounds are and how often the sound is needed.

--

--

Ethan Saadia

Founder at PhotoCatch. Developing 3D content creation tools for everyone. 2x  WWDC Scholar. Developer, Engineer, and Entrepreneur.