AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
SpatialSoundSettings.cs
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // Licensed under the MIT License. See LICENSE in the project root for license information.
3 
4 using System;
5 using UnityEngine;
6 
7 namespace HoloToolkit.Unity
8 {
13  {
14  Small, // Office to small conference room
15  Medium, // Large conference room
16  Large, // Auditorium
17  None // Similar to being outdoors
18  }
19 
24  public static class SpatialSoundSettings
25  {
26  public const SpatialSoundRoomSizes DefaultSpatialSoundRoom = SpatialSoundRoomSizes.Small;
27 
28  // Ranges and default values for the Microsoft Spatial Sound Spatializer parameters.
29  // See: <https://msdn.microsoft.com/en-us/library/windows/desktop/mt186602(v=vs.85).aspx>
30  // for more details.
31  public const float MinimumGainDecibels = -96.0f;
32  public const float MaximumGainDecibels = 12.0f;
33  public const float MinimumUnityGainDistanceMeters = 0.05f;
34  public const float MaximumUnityGainDistanceMeters = float.MaxValue;
35  public const float DefaultMinGain = MinimumGainDecibels;
36  public const float DefaultMaxGain = MaximumGainDecibels;
37  public const float DefaultUnityGainDistance = 1.0f;
38 
42  private enum SpatialSoundParameters
43  {
44  RoomSize = 1
45  }
46 
52  public static void SetRoomSize(AudioSource audioSource, SpatialSoundRoomSizes room)
53  {
54  SetParameter(audioSource, SpatialSoundParameters.RoomSize, (float)room);
55  }
56 
62  [Obsolete("This spatializer parameter is no longer used, volume attenuation is controlled by the unity volume curve.")]
63  public static void SetMinGain(AudioSource audioSource, float gain)
64  {
65  }
66 
72  [Obsolete("This spatializer parameter is no longer used, volume attenuation is controlled by the unity volume curve.")]
73  public static void SetMaxGain(AudioSource audioSource, float gain)
74  {
75  }
76 
82  [Obsolete("This spatializer parameter is no longer used, volume attenuation is controlled by the unity volume curve.")]
83  public static void SetUnityGainDistance(AudioSource audioSource, float distance)
84  {
85  }
86 
93  private static void SetParameter(AudioSource audioSource, SpatialSoundParameters param, float value)
94  {
95  audioSource.SetSpatializerFloat((int)param, value);
96  }
97  }
98 }
The SpatialSoundSettings class provides a set of methods that simplify making modifications to Micros...
static void SetRoomSize(AudioSource audioSource, SpatialSoundRoomSizes room)
Sets the Spatial Sound room size.
static void SetMaxGain(AudioSource audioSource, float gain)
Sets the Spatial Sound maximum gain.
static void SetMinGain(AudioSource audioSource, float gain)
Sets the Spatial Sound minimum gain.
static void SetUnityGainDistance(AudioSource audioSource, float distance)
Sets the Spatial Sound unity gain distance.
SpatialSoundRoomSizes
Room sizes for the Microsoft Spatial Sound Spatializer.