ZiggidyCreative
ZiggidyCreative

Reputation: 335

How Can I Create Spatial Audio in iOS with Swift?

I'm trying to get spatial audio working using Dolby Atmos media files.

Question: Do I need to use SceneKit, RealityKit and or CoreMotion with CMHeadphoneMotionManager to build this functionality or does it come out of the box by setting allowedAudioSpatializationFormats simply with AVPlayer?

More Info: App I'm trying to build is a spatial music app, not a game or something using 3D objects.

The apple documentation is unclear as to how to actually achieve this.

For an example, use AirPods Pro with custom iOS app to hear the spatial audio ie. "Music" with instruments surrounding the listener.

Thanks!

Upvotes: 2

Views: 2429

Answers (3)

himwho
himwho

Reputation: 1

If you want to create someething that utilizes the headtracking from AirPods and other IMU enabled apple products, but without all the discoloration from their 5.1 binaural stage or the limitations of dolby atmos, you can explore that idea here: https://github.com/Mach1Studios/Pod-Mach1SpatialAPI/tree/master/Examples/spatialaudioplayer-example

If you want to explore using this headtracking data for another mixing approach yourself you can check out this example too: https://github.com/Mach1Studios/M1-AirPodOSC

(Disclaimer: these examples are designed for a vector format that has no additional audio effect processing, so we can treat multichannel and spatial audio mixing more traditionally since proprietary formats like dolby atmos / apple spatial limit what is creatively possible via runtime effect processing that can alter from app to app which is not ideal or needed for most spatial music mixing cases.)

Upvotes: 0

Joke coder
Joke coder

Reputation: 273

I am going to make a little deduction because I haven't researched a lot yet, but according to the documentation you can choose the audio type. My deduction (you noted "use AirPods Pro with Apple TV to hear the spatial audio") is that it's hardware related. However:

If the device doesn’t support spatial audio, it falls back to mono.

Upvotes: 1

user8942934
user8942934

Reputation: 36

You can use AVAudioEngine. Here is a reference https://developer.apple.com/library/archive/samplecode/AVAEGamingExample/Introduction/Intro.html

Upvotes: 0

Related Questions