Tutorial – Ambisonics in Unity

A Quick Overview of Ambisonics

With the rise of VR and 360 degree videos, Ambisonic audio has gained popularity in recent years and have far more applications now than they did when they were created in the 1970s. Simply put, Ambisonics are a method for recording and playing back 360 degree audio – this is commonly utilised for fixed point viewing and is particularly useful for 360 video and fixed point VR.

The primary difference between multi-channel Ambisonic recordings and multi-channel surround sound files is that whilst surround sound audio files have tracks that are routed to specific speaker setups such as 5.1 or 7.1, Ambisonics are speaker agnostic and can be decoded into any speaker array. The multiple channels exist to represent the full 3D representation of sound from the recording point.

The most common format for Ambisonics at the moment ‘B-format’ WAV files. This is the format that Unity uses, specifying that it should also use ACN component ordering and SN3D normalization.

To actually record these things in a way that’s compatible with Unity you’ll need a 4-channel recorder that will record in the settings specified above and something like this microphone here.

Ambisonics in Unity

Okay, now we’ve gotten past the “what the hell actually are these things?” section – we can carry on to how we actually use them in Unity. If you don’t have any B-format ambisonic recordings on hand but want to test this out, then you can grab some example files that will work from the lovely folks for work on Ambisonic Toolkit.

Creating an Ambisonic Audio Source is actually a really quick and easy process in Unity, so it shouldn’t take long until you’re up and running.

Project Settings

The first step to using Ambisonics in Unity is to specify the decoding plugin to use in the Audio Project Settings (Edit > Project Settings > Audio). The setting we’re interested in here is the Ambisonic Decoder Plugin, and we want to make sure it’s set to ‘Resonance Audio’ (Resonance Audio is the Google Audio plugin which is now natively tied into Unity 2018. If you are using a version of Unity prior to 2018.1, you can download the Resonance Audio packages here – it’s actually not a bad idea to use this package anyway as it seems like Unity’s native integration is still not ‘feature full’.

AudioManagerSettings
Import Settings

Next up, just drag into Unity the Ambisonics you want to use (if you’re using the examples from Ambisonic Toolkit then any of the B-Format or 4-Channel files seem to work okay). Once imported, you need to select all of the Ambisonics you want to try out and ensure they’re marked as ‘Ambisonic’ in the files Import Settings.

ImportSettings
Creating an Audio Source and Mixer

Before we go ahead and start creating the Audio Source, we need to create an Audio Mixer that utilises the Resonance Audio Renderer. To do this, open up the Audio Mixer window (Window > Audio > Audio Mixer in 2018.2 or CTRL+8) and create a new Audio Mixer. For simplicity, we’re just going to add the Resonance Audio Renderer onto the Master channel using the ‘add’ button at the bottom of the channel. This is where we will route our audio source once it’s created.

AudioMixer

Finally, we simply create a new Audio Source (Create > Audio > Audio Source) and edit the Inspector settings of this new Game Object so that the settings look something like the below, setting our Audio Clip to the Ambisonic we want to test and the Mixer Group to the one we just created. We also need to ensure that the ‘Spatialize’ option is turned off and that the Spatial Blend is set over to 2D.

AudioSource

Hey presto! That’s all you need to do in order to the Ambisonics working in Unity. This will give you a global soundscape that will automatically update the audio relative the the current positioning of the Audio Listener. I’ve made a quick example of this integration which you can see below.