Skip to content
VIRAJ

Case OS · Swift / Spatial audio

RealityAudio

If something is behind you, you should hear it behind you

  • SWIFT
  • SPM
  • OPEN SOURCE

If something is behind you, you should hear it behind you.

The idea

RealityAudio came out of a problem I ran into while building Revenants. We had objects and events placed around a real room, but the audio didn't naturally belong to that space. A sound could be positioned somewhere in AR, yet still feel like it was simply playing through the phone's speakers.

I wanted to make audio behave more like it does in the real world. If something is behind you, you should hear it behind you. If you turn toward it, the sound should change. If the source moves, you should be able to follow it. The audio needed to understand where the listener and the sound were in relation to each other.

The build

I built RealityAudio to handle that spatial relationship, using AVAudioEngine and Apple's spatial-audio capabilities to position and update sounds dynamically as the listener moves through the environment. I designed it as a reusable Swift package rather than keeping the system locked inside Revenants, so the same approach could be used in other spatial and AR experiences.

What I learned

What started as a technical problem inside a game became a project I could share independently. RealityAudio was later featured by DevBytes, and it became one of those projects where solving one very specific problem ended up teaching me how to build a tool that could be useful beyond the original idea.

Technology

  • Swift Package Manager
  • AVAudioEngine
  • AVFoundation
  • RealityKit
  • ARKit