Spatial sound in Unity
This page links to resources for spatial sound in Unity.
Spatializer options for mixed reality applications include:
- The MS HRTF Spatializer. Unity provides this as part of the Windows Mixed Reality optional package.
- This runs on CPU in a higher-cost 'single-source' architecture.
- This is provided for backwards compatibility with original HoloLens applications.
- The Microsoft Spatializer. This is available from the Microsoft spatializer GitHub repository.
- This uses a lower-cost 'multi-source' architecture.
- On HoloLens 2, this is offloaded to a hardware accelerator.
For new applications, we recommend the Microsoft Spatializer.
Use NuGet for Unity to install Microsoft.SpatialAudio.Spatializer.Unity and choose Microsoft Spatializer in your project's audio settings. Then:
- Attach an Audio Source to an object in the hierarchy
- Check the Enable spatialization checkbox
- Move the Spatial Blend slider to '1'
- Ensure spatial audio is enabled on your developer workstation. Enable it by right-clicking on the volume icon in the task bar and making sure that Spatial Sound is set to something other than "off." To get the best representation of what you'll hear on HoloLens 2, choose Windows Sonic for Headphones.
For more details, see:
- Microsoft spatializer GitHub repository
- Microsoft's spatializer tutorial
- Unity's audio source documentation
- Unity's spatializer documentation
Unity's default distance-based decay has a minimum distance of 1 meter and a maximum distance of 500 meters, with a logarithmic rolloff. These settings may work for your scenario, or you may find that sources attenuate too quickly or too slowly. For more details, see:
- Sound design in mixed reality for recommended settings.
- Unity's audio source documentation for instructions on setting these curves.
The Microsoft Spatializer disables post-spatializer effects by default. To enable reverb and other effects for spatialized sources:
- Attach the Room Effect Send Level component to each source
- Adjust the send level curve for each source, to control the gain on the audio sent back to the graph for effects processing
See Chapter 5 of the spatializer tutorial for details.
Unity spatial sound examples
For examples of spatial sound in Unity, see: