title | description | author | ms.author | ms.date | ms.topic | keywords |
---|---|---|---|---|---|---|
Spatial audio tutorials - 1. Adding spatial audio to your project |
Add the Microsoft Spatializer plugin to your Unity project to access HoloLens 2 HRTF hardware offload. |
kegodin |
v-hferrone |
02/05/2021 |
article |
mixed reality, unity, tutorial, hololens2, spatial audio, MRTK, mixed reality toolkit, UWP, Windows 10, HRTF, head-related transfer function, reverb, Microsoft Spatializer |
Welcome to the spatial audio tutorial for Unity on HoloLens2. Through this tutorial series, you will learn how to use head-related transfer function (HRTF) offload on HoloLens 2 and How to enable reverb when using HRTF offload.
The Microsoft Spatializer GitHub repository has a completed Unity project of this tutorial sequence.
For an understanding of what it means to spatialize sounds using HRTF-based spatialization technologies and recommendations for when it can be helpful, see spatial sound design.
Processing audio using HRTF-based algorithms requires a large amount of specialized computation. HoloLens 2 includes dedicated hardware that can be utilized to avoid burdening the application processor, thus "offloading" the processing of HRTF-based algorithms. The Microsoft spatializer plugin provides an easy way for your application to take advantage of the dedicated HRTF hardware so your application can use more of the application processor for operations other than spatial audio.
- Importing and Enabling Microsoft spatializer plugin
- Enabling Spatial audio on your developer workstation
- A Windows 10 PC configured with the correct tools installed
- Basic c# programming knowledge
- A HoloLens 2 device configured for development
- Unity Hub with Unity 2019 LTS mounted, and the Universal Windows Platform Build Support module added
We strongly recommend completing the Getting started tutorials series or having some basic prior experience with Unity and MRTK before continuing.
Important
- The recommended Unity version for this tutorial series is Unity 2019 LTS. It supersedes any Unity version requirements or recommendations stated in the prerequisites linked above.
In this section, you will create a new Unity project and get it ready for MRTK development.
For this, first follow the Initializing your project and first application, excluding the Build your application to your device instructions, which includes the following steps:
-
Creating the Unity project and give it a suitable name, for example, MRTK Tutorials
-
Creating and setting the scene and give the scene a suitable name, for example, SpatialAudio
Then follow the Changing the Spatial Awareness Display Option instructions to ensure the MRTK configuration profile for your scene is DefaultHoloLens2ConfigurationProfile and change the display options for the spatial awareness mesh to Occlusion.
Download and import the Microsoft Spatializer Microsoft.SpatialAudio.Spatializer.Unity.1.0.18.unitypackage
Tip
For a reminder on how to import a Unity custom package, you can refer to the Importing the tutorial assets instructions.
After importing the Microsoft Spatializer you need to enable it. Open Edit -> Project Settings -> Audio, and change Spatializer Plugin to "Microsoft Spatializer".
On desktop versions of Windows, spatial audio is disabled by default. Enable it by right-clicking on the volume icon in the task bar. To get the best representation of what you'll hear on HoloLens 2, choose Spatial sound -> Windows Sonic for Headphones.
Note
This setting is only required if you plan to test your project in the Unity editor.
In this tutorial you have learnt how to Import and enable the Microsoft Spatializer plugin and also to enable the spatial audio on your workstation. In the next tutorial you will learn how to add spatial audio in the unity project.
[!div class="nextstepaction"] Next Tutorial: 2. Spatializing button interaction sounds