An ambisonic decoder is an audio component that decodes the ambisonic audio format into a specific output format, such as stereo or surround sound. This format depends on your speaker configuration (menu: Edit > Project Settings > Audio > Default Speaker Mode), unless your platform overrides this.
Although Unity supports ambisonic audio, it doesn’t provide built-in decoders by default. Instead, you must either select a third-party decoder, or use your own decoder plug-inA set of code created outside of Unity that creates functionality in Unity. There are two kinds of plug-ins you can use in Unity: Managed plug-ins (managed .NET assemblies created with tools like Visual Studio) and Native plug-ins (platform-specific native code libraries). More info
See in Glossary.
You can set up an ambisonic audio decoder in the same way as you’d set up an Audio SpatializerA plug-in that changes the way audio is transmitted from an audio source into the surrounding space. It takes the source and regulates the gains of the left and right ear contributions based on the distance and angle between the AudioListener and the AudioSource. More info
See in Glossary. However, the following parameters in the AudioPluginInterface.h
file are specific to ambisonic audio decoder plug-ins:
The UnityAudioEffectDefinitionFlags_IsAmbisonicDecoder
effect definition flag
The UnityAudioAmbisonicData
data struct
During the plug-in scanning phase, the UnityAudioEffectDefinitionFlags_IsAmbisonicDecoder
flag notifies Unity that this is an ambisonic decoder effect.
To enable a plug-in to operate as an ambisonic decoder, set a flag in the description bit-field of the effect:
`````
definition.flags |= UnityAudioEffectDefinitionFlags_IsAmbisonicDecoder;
`````
Unity lists your plug-in as an option in the Project Settings window (menu: Edit > Project Settings > Audio > Ambisonic Decoder Plugin).
The UnityAudioAmbisonicData
struct is similar to the UnityAudioSpatializerData
struct that Unity passes into spatializers, and contains an ambisonicOutChannels
integer.
The Ambisonic decoders run early in the audio pipeline in Unity, and the ambisonicOutChannels
variable tells the plug-in how many of the output channels Unity needs to use. ambisonicOutChannels
is automatically set to the DefaultSpeakerMode
’s channel count.
For example, if you play back a first order ambisonic audio clipA container for audio data in Unity. Unity supports mono, stereo and multichannel audio assets (up to eight channels). Unity can import .aif, .wav, .mp3, and .ogg audio file format, and .xm, .mod, .it, and .s3m tracker module formats. More info
See in Glossary that has 4 channels, and your speaker mode is stereo (which has only 2 channels):
An ambisonic decoder’s process callback passes in 4 for the in and out channel count.
The ambisonicOutChannels
field is automatically set to 2.
The plug-in outputs its spatialized data to the first 2 channels and zero out the other 2 channels.
Follow these steps to develop your own ambisonic audio decoder plug-in for Unity:
Create a custom audio plug-in using the Native audio plug-in SDK.
Set a flag in the description bit-field of the effect:
definition.flags |= UnityAudioEffectDefinitionFlags_IsAmbisonicDecoder;
When you are done configuring your plug-in, compile your file. Make sure it is compilable on your preferred platforms.
Optionally, convert your file to a .dll file.
Move your plug-in file into your Unity project’s Asset folder.
For more information on how to work with your ambisonic audio plug-in in Unity, see Ambisonic Audio.
The Unity ambisonic sources framework can support first order ambisonics. The plug-in interface includes information to support binaural stereo and quadA primitive object that resembles a plane but its edges are only one unit long, it uses only 4 vertices, and the surface is oriented in the XY plane of the local coordinate space. More info
See in Glossary output, but the plug-in itself determines which outputs are supported.
Initially, ambisonic decoder plug-ins support first order ambisonic sources and binaural stereo output. There is no support for second order ambisonics.
There is nothing in the framework that’s specific to any of the different ambisonic formats available. If the clip’s format matches the ambisonic decoder plug-in’s expected format, then ambisonic audio should work without issue. Unity’s preferred ambisonic format is B-format, with ACN component ordering, and SN3D normalization.
For information on how to develop a plug-in, refer to Native audio plug-in SDK and Audio spatializer SDK. You must also download the Audio plug-in SDK.
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.