Getting Started with Spatial Audio for Mixed Reality

Published Sep 25 2020 10:00 AM 1,854 Views
Microsoft

 

HoloLens applications have the power to overlay digital objects on top of the real world. Getting these holograms to look visually accurate comes with its own set of challenges, but how should they sound? This post will cover the audio side of developing for mixed reality, providing some tips and tricks for making your application’s audio more immersive.

 

Adding audio to your application is an easy way to increase user engagement and confidence. For example, even the simple act of adding a sound to confirm a button click can let the user know when their input has been recognized. Going one step further – enabling spatial audio for that same button click can make the user interface feel like it is coexisting in the same physical room as the user, rather than just some button floating in space. This short video demonstrates these differences (best listened to over headphones for the closest representation of what a user will hear with HoloLens).

 

To get started, you’ll need to add an audio spatializer plugin to your Unity project. I recommend including the Microsoft Spatializer. This has the added benefit of offloading all spatial audio processing to dedicated hardware on the HoloLens 2, freeing up more CPU for your application’s core business logic. If you’re looking to get started quickly, you can download this plugin directly from the releases tab on Github. If you need to customize the plugin for any reason, you can also build it directly from the repository – it is fully open source.

 

Once you have the plugin added to your Unity project, you can enable spatial audio for an audio source by clicking the Spatialize checkbox and setting the Spatial Blend to 1.0. You’ll also notice that there is a volume roll-off curve. Unity’s default curve may or may not work for your application. For example, we recommend disabling distance attenuation for UI sounds. To do this, flatten the curve out as seen below. Don’t be afraid to experiment with this volume curve! All applications have different requirements, so different curves can be useful.

Unity Audio Source settings to enable spatial audio and disable distance attenuationUnity Audio Source settings to enable spatial audio and disable distance attenuation

 

What about for sounds for more interesting holograms? Spatial audio has the benefit of helping a user distinguish between multiple sound sources playing simultaneously. Instead of a cacophony of sounds, users can enjoy increased ability to locate holograms when spatial sound is enabled, as seen in this video.

 

 

One important note about the Microsoft Spatializer – to leverage the hardware acceleration capabilities of the HoloLens 2, the Unity audio mixer functionality is bypassed. If you are accustomed to routing audio sources to different mixer groups to better control volume or effects processing, you’ll need to apply those effects on a per-source basis instead of using the audio mixer. Unity comes with some built-in audio effects, such as EQ filters and reverb. Additionally, some other Unity plugins, such as WebRTC, rely on the audio effect infrastructure to operate properly. If you want to use audio effects in conjunction with the Microsoft Spatializer, make sure to check the “Spatialize Post Effects” checkbox on the audio source, otherwise these components won’t work properly.

 

A quick note on when not to use spatial audio. Given how easy it is to enable spatial audio, you may be inclined to enable it for all the audio in your application! However, there are cases when this can be distracting. In general, spatial audio works best for things that also have a visual component (i.e. menus, holograms, etc.). For audio-only parts of your application, such as narrators or background music, spatial audio may actually be more of a distraction. Consider disabling spatial audio for these sounds so the user may enjoy them without looking around for some visual cue of where they are coming from.

 

If you want more information about adding spatial audio to your application, definitely check out the full set of documentation, and try out the spatial audio tutorial. If you’re developing with the Unreal Engine, these same principals apply but there’s a slightly different setup process. You can learn more about using spatial audio in the Unreal Engine here. If you’ve done all this and are ready to explore what else you can do with audio, check out Project Acoustics! It can add an additional layer of immersion to your application by simulating room effects. If you’ve gotten stuck somewhere along the way, let us know in the comments, or feel free to file an issue on the Microsoft Spatializer issues page.

 

2 Comments
Microsoft

Does this work with Hololens 1?

Microsoft

@Ritaarrigo the Microsoft Spatializer plugin does not work on HoloLens 1, but all the same concepts still apply. For spatializers that work on HoloLens 1, you can try using the "MS HRTF Spatializer" included in the Windows XR Plugin package, or the spatializer plugin included with Project Acoustics.

%3CLINGO-SUB%20id%3D%22lingo-sub-1675605%22%20slang%3D%22en-US%22%3EGetting%20Started%20with%20Spatial%20Audio%20for%20Mixed%20Reality%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1675605%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHoloLens%20applications%20have%20the%20power%20to%20overlay%20digital%20objects%20on%20top%20of%20the%20real%20world.%20Getting%20these%20holograms%20to%20look%20visually%20accurate%20comes%20with%20its%20own%20set%20of%20challenges%2C%20but%20how%20should%20they%20sound%3F%20This%20post%20will%20cover%20the%20audio%20side%20of%20developing%20for%20mixed%20reality%2C%20providing%20some%20tips%20and%20tricks%20for%20making%20your%20application%E2%80%99s%20audio%20more%20immersive.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAdding%20audio%20to%20your%20application%20is%20an%20easy%20way%20to%20increase%20user%20engagement%20and%20confidence.%20For%20example%2C%20even%20the%20simple%20act%20of%20adding%20a%20sound%20to%20confirm%20a%20button%20click%20can%20let%20the%20user%20know%20when%20their%20input%20has%20been%20recognized.%20Going%20one%20step%20further%20%E2%80%93%20enabling%20spatial%20audio%20for%20that%20same%20button%20click%20can%20make%20the%20user%20interface%20feel%20like%20it%20is%20coexisting%20in%20the%20same%20physical%20room%20as%20the%20user%2C%20rather%20than%20just%20some%20button%20floating%20in%20space.%20This%20short%20video%20demonstrates%20these%20differences%20%3CSPAN%20class%3D%22TextRun%20SCXW188070664%20BCX9%22%20data-contrast%3D%22auto%22%3E%3CSPAN%20class%3D%22NormalTextRun%20SCXW188070664%20BCX9%22%3E%20(best%20listened%20to%20over%20headphones%20for%20the%20closest%20representation%20of%20what%20a%20user%20will%20hear%20with%20HoloLens)%3C%2FSPAN%3E%3C%2FSPAN%3E.%3C%2FP%3E%0A%3CP%3E%3C%2FP%3E%3CDIV%20class%3D%22video-embed-center%20video-embed%22%3E%3CIFRAME%20class%3D%22embedly-embed%22%20src%3D%22https%3A%2F%2Fcdn.embedly.com%2Fwidgets%2Fmedia.html%3Fsrc%3Dhttps%253A%252F%252Fwww.youtube.com%252Fembed%252Fu7nmLkHhdLg%253Ffeature%253Doembed%26amp%3Bdisplay_name%3DYouTube%26amp%3Burl%3Dhttps%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253Du7nmLkHhdLg%26amp%3Bimage%3Dhttps%253A%252F%252Fi.ytimg.com%252Fvi%252Fu7nmLkHhdLg%252Fhqdefault.jpg%26amp%3Bkey%3Db0d40caa4f094c68be7c29880b16f56e%26amp%3Btype%3Dtext%252Fhtml%26amp%3Bschema%3Dyoutube%22%20width%3D%22200%22%20height%3D%22112%22%20scrolling%3D%22no%22%20title%3D%22YouTube%20embed%22%20frameborder%3D%220%22%20allow%3D%22autoplay%3B%20fullscreen%22%20allowfullscreen%3D%22true%22%3E%3C%2FIFRAME%3E%3C%2FDIV%3E%3CP%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20get%20started%2C%20you%E2%80%99ll%20need%20to%20add%20an%20audio%20spatializer%20plugin%20to%20your%20Unity%20project.%20I%20recommend%20including%20the%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fspatialaudio-unity%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EMicrosoft%20Spatializer%3C%2FA%3E.%20This%20has%20the%20added%20benefit%20of%20offloading%20all%20spatial%20audio%20processing%20to%20dedicated%20hardware%20on%20the%20HoloLens%202%2C%20freeing%20up%20more%20CPU%20for%20your%20application%E2%80%99s%20core%20business%20logic.%20If%20you%E2%80%99re%20looking%20to%20get%20started%20quickly%2C%20you%20can%20download%20this%20plugin%20directly%20from%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fspatialaudio-unity%2Freleases%2Ftag%2Fv1.0.18%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ethe%20releases%20tab%3C%2FA%3E%3CSPAN%3E%20on%20Github%3C%2FSPAN%3E.%20If%20you%20need%20to%20customize%20the%20plugin%20for%20any%20reason%2C%20you%20can%20also%20build%20it%20directly%20from%20the%20repository%20%E2%80%93%20it%20is%20fully%20open%20source.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20you%20have%20the%20plugin%20added%20to%20your%20Unity%20project%2C%20you%20can%20enable%20spatial%20audio%20for%20an%20audio%20source%20by%20clicking%20the%20Spatialize%20checkbox%20and%20setting%20the%20Spatial%20Blend%20to%201.0.%20You%E2%80%99ll%20also%20notice%20that%20there%20is%20a%20volume%20roll-off%20curve.%20Unity%E2%80%99s%20default%20curve%20may%20or%20may%20not%20work%20for%20your%20application.%20For%20example%2C%20we%20recommend%20disabling%20distance%20attenuation%20for%20UI%20sounds.%20To%20do%20this%2C%20flatten%20the%20curve%20out%20as%20seen%20below.%20Don%E2%80%99t%20be%20afraid%20to%20experiment%20with%20this%20volume%20curve!%20All%20applications%20have%20different%20requirements%2C%20so%20different%20curves%20can%20be%20useful.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22UnityScreencap.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F219625iD35F76B2C4B68895%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22UnityScreencap.png%22%20alt%3D%22Unity%20Audio%20Source%20settings%20to%20enable%20spatial%20audio%20and%20disable%20distance%20attenuation%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EUnity%20Audio%20Source%20settings%20to%20enable%20spatial%20audio%20and%20disable%20distance%20attenuation%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhat%20about%20for%20sounds%20for%20more%20interesting%20holograms%3F%20Spatial%20audio%20has%20the%20benefit%20of%20helping%20a%20user%20distinguish%20between%20multiple%20sound%20sources%20playing%20simultaneously.%20Instead%20of%20a%20cacophony%20of%20sounds%2C%20users%20can%20enjoy%20increased%20ability%20to%20locate%20holograms%20when%20spatial%20sound%20is%20enabled%2C%20as%20seen%20in%20this%20video.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorMikeChemi_2%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3C%2FP%3E%3CDIV%20class%3D%22video-embed-center%20video-embed%22%3E%3CIFRAME%20class%3D%22embedly-embed%22%20src%3D%22https%3A%2F%2Fcdn.embedly.com%2Fwidgets%2Fmedia.html%3Fsrc%3Dhttps%253A%252F%252Fwww.youtube.com%252Fembed%252FuilXLXluRX4%253Ffeature%253Doembed%26amp%3Bdisplay_name%3DYouTube%26amp%3Burl%3Dhttps%253A%252F%252Fwww.youtube.com%252Fwatch%253Fv%253DuilXLXluRX4%26amp%3Bimage%3Dhttps%253A%252F%252Fi.ytimg.com%252Fvi%252FuilXLXluRX4%252Fhqdefault.jpg%26amp%3Bkey%3Db0d40caa4f094c68be7c29880b16f56e%26amp%3Btype%3Dtext%252Fhtml%26amp%3Bschema%3Dyoutube%22%20width%3D%22200%22%20height%3D%22112%22%20scrolling%3D%22no%22%20title%3D%22YouTube%20embed%22%20frameborder%3D%220%22%20allow%3D%22autoplay%3B%20fullscreen%22%20allowfullscreen%3D%22true%22%3E%3C%2FIFRAME%3E%3C%2FDIV%3E%3CP%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOne%20important%20note%20about%20the%20Microsoft%20Spatializer%20%E2%80%93%20to%20leverage%20the%20hardware%20acceleration%20capabilities%20of%20the%20HoloLens%202%2C%20the%20Unity%20audio%20mixer%20functionality%20is%20bypassed.%20If%20you%20are%20accustomed%20to%20routing%20audio%20sources%20to%20different%20mixer%20groups%20to%20better%20control%20volume%20or%20effects%20processing%2C%20you%E2%80%99ll%20need%20to%20apply%20those%20effects%20on%20a%20per-source%20basis%20instead%20of%20using%20the%20audio%20mixer.%20Unity%20comes%20with%20some%20built-in%20audio%20effects%2C%20such%20as%20EQ%20filters%20and%20reverb.%20Additionally%2C%20some%20other%20Unity%20plugins%2C%20such%20as%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2FMixedReality-WebRTC%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EWebRTC%3C%2FA%3E%2C%20rely%20on%20the%20audio%20effect%20infrastructure%20to%20operate%20properly.%20If%20you%20want%20to%20use%20audio%20effects%20in%20conjunction%20with%20the%20Microsoft%20Spatializer%2C%20make%20sure%20to%20check%20the%20%E2%80%9CSpatialize%20Post%20Effects%E2%80%9D%20checkbox%20on%20the%20audio%20source%2C%20otherwise%20these%20components%20won%E2%80%99t%20work%20properly.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EA%20quick%20note%20on%20when%20not%20to%20use%20spatial%20audio.%20Given%20how%20easy%20it%20is%20to%20enable%20spatial%20audio%2C%20you%20may%20be%20inclined%20to%20enable%20it%20for%20all%20the%20audio%20in%20your%20application!%20However%2C%20there%20are%20cases%20when%20this%20can%20be%20distracting.%20In%20general%2C%20spatial%20audio%20works%20best%20for%20things%20that%20also%20have%20a%20visual%20component%20(i.e.%20menus%2C%20holograms%2C%20etc.).%20For%20audio-only%20parts%20of%20your%20application%2C%20such%20as%20narrators%20or%20background%20music%2C%20spatial%20audio%20may%20actually%20be%20more%20of%20a%20distraction.%20Consider%20disabling%20spatial%20audio%20for%20these%20sounds%20so%20the%20user%20may%20enjoy%20them%20without%20looking%20around%20for%20some%20visual%20cue%20of%20where%20they%20are%20coming%20from.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20want%20more%20information%20about%20adding%20spatial%20audio%20to%20your%20application%2C%20definitely%20check%20out%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fmixed-reality%2Fdevelop%2Funity%2Fspatial-sound-in-unity%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ethe%20full%20set%20of%20documentation%3C%2FA%3E%2C%20and%20try%20out%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fmixed-reality%2Fdevelop%2Funity%2Ftutorials%2Funity-spatial-audio-ch1%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Espatial%20audio%20tutorial%3C%2FA%3E.%20If%20you%E2%80%99re%20developing%20with%20the%20Unreal%20Engine%2C%20these%20same%20principals%20apply%20but%20there%E2%80%99s%20a%20slightly%20different%20setup%20process.%20You%20can%20learn%20more%20about%20using%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fwindows%2Fmixed-reality%2Fdevelop%2Funreal%2Funreal-spatial-audio%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Espatial%20audio%20in%20the%20Unreal%20Engine%20here%3C%2FA%3E.%20If%20you%E2%80%99ve%20done%20all%20this%20and%20are%20ready%20to%20explore%20what%20else%20you%20can%20do%20with%20audio%2C%20check%20out%20%3CA%20href%3D%22http%3A%2F%2Faka.ms%2Facoustics%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EProject%20Acoustics%3C%2FA%3E!%20It%20can%20add%20an%20additional%20layer%20of%20immersion%20to%20your%20application%20by%20simulating%20room%20effects.%20If%20you%E2%80%99ve%20gotten%20stuck%20somewhere%20along%20the%20way%2C%20let%20us%20know%20in%20the%20comments%2C%20or%20feel%20free%20to%20file%20an%20issue%20on%20the%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fspatialaudio-unity%2Fissues%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EMicrosoft%20Spatializer%20issues%20page%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1675605%22%20slang%3D%22en-US%22%3E%3CP%3EAre%20you%20writing%20an%20application%20for%20mixed%20reality%2C%20but%20don't%20know%20where%20to%20start%20with%20audio%3F%20This%20post%20will%20help%20you%20add%20spatial%20audio%20to%20your%20application%20to%20help%20your%20holograms%20come%20to%20life!%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22MR%20Blog%20Preview.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F221940iAF05F28EBE6CCE2C%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22MR%20Blog%20Preview.png%22%20alt%3D%22MR%20Blog%20Preview.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1675605%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EMicrosoft%20Developers%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EUnity%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EUnreal%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1714905%22%20slang%3D%22en-US%22%3ERe%3A%20Getting%20Started%20with%20Spatial%20Audio%20for%20Mixed%20Reality%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1714905%22%20slang%3D%22en-US%22%3E%3CP%3EDoes%20this%20work%20with%20Hololens%201%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1715005%22%20slang%3D%22en-US%22%3ERe%3A%20Getting%20Started%20with%20Spatial%20Audio%20for%20Mixed%20Reality%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1715005%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F279798%22%20target%3D%22_blank%22%3E%40Ritaarrigo%3C%2FA%3E%26nbsp%3Bthe%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fspatialaudio-unity%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EMicrosoft%20Spatializer%3C%2FA%3E%20plugin%20does%20not%20work%20on%20HoloLens%201%2C%20but%20all%20the%20same%20concepts%20still%20apply.%20For%20spatializers%20that%20work%20on%20HoloLens%201%2C%20you%20can%20try%20using%20the%20%22MS%20HRTF%20Spatializer%22%20included%20in%20the%20Windows%20XR%20Plugin%20package%2C%20or%20the%20spatializer%20plugin%20included%20with%20%3CA%20href%3D%22http%3A%2F%2Faka.ms%2Facoustics%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3EProject%20Acoustics%3C%2FA%3E.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Version history
Last update:
‎Sep 24 2020 02:57 PM
Updated by: