Audio locked on App start. No head tracked audio. Often starts hard panned to left or right

Hey folks. I’m happy to share that we have a workaround! Our friends at Apple let us know about an API that can be used to control how the OS handles spatial audio for your app. You can call setIntendedSpatialExperience at app launch and indicate that you want to bypass spatial audio. To be clear, this will bypass visionOS spatial audio, but Unity spatial audio will still work. What was happening is that our stereo output was being re-spatialized by visionOS, and we don’t want that.

I’ll be adding this to our mainline soon, but in the meantime you can apply this workaround on your own projects by adding the following code on line 141 of Classes/UnityAppController.mm (in the startUnity method) in the generated Xcode project:
[audioSession setIntendedSpatialExperience:AVAudioSessionSpatialExperienceBypassed options:@{} error:nil];

I added this before the existing code that was there: [audioSession addObserver: self forKeyPath: @"outputVolume" options: 0 context: nil];. It can probably go after as well. As far as I can tell, this completely eliminates the audio panning issue.

Hope this helps!

6 Likes