Skip to content

Commit 82fc644

Browse files
authored
Merge pull request #309 from AsoboStudio/master
spatial sound - Added spread,spatial,reverb curve to UAudioManager
2 parents 2608114 + dc635d0 commit 82fc644

File tree

3 files changed

+63
-5
lines changed

3 files changed

+63
-5
lines changed

Assets/HoloToolkit/SpatialSound/Scripts/UAudioManager/ActiveEvent.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,19 @@ private void SetSourceProperties()
149149
{
150150
forEachSource((source) =>
151151
{
152-
source.rolloffMode = AudioRolloffMode.Logarithmic;
152+
if (audioEvent.spatialization == SpatialPositioningType.ThreeD)
153+
{
154+
source.rolloffMode = AudioRolloffMode.Custom;
155+
source.maxDistance = audioEvent.maxDistanceAttenuation3D;
156+
source.SetCustomCurve(AudioSourceCurveType.CustomRolloff, audioEvent.attenuationCurve);
157+
source.SetCustomCurve(AudioSourceCurveType.SpatialBlend, audioEvent.spatialCurve);
158+
source.SetCustomCurve(AudioSourceCurveType.Spread, audioEvent.spreadCurve);
159+
source.SetCustomCurve(AudioSourceCurveType.ReverbZoneMix, audioEvent.reverbCurve);
160+
}
161+
else
162+
{
163+
source.rolloffMode = AudioRolloffMode.Logarithmic;
164+
}
153165
});
154166
}
155167

Assets/HoloToolkit/SpatialSound/Scripts/UAudioManager/AudioEvent.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,25 @@ public class AudioEvent : IComparable, IComparable<AudioEvent>
6060
[Range(SpatialSoundSettings.MinimumGainDecibels, SpatialSoundSettings.MaximumGainDecibels)]
6161
public float maxGain = SpatialSoundSettings.DefaultMaxGain;
6262

63+
[Tooltip("The volume attenuation curve for simple 3D sounds. Only used when positioning is set to 3D")]
64+
public AnimationCurve attenuationCurve = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f); // By default simple attenuation
65+
66+
[Tooltip("The spatial attenuation curve for simple 3D sounds. Only used when positioning is set to 3D")]
67+
public AnimationCurve spatialCurve = AnimationCurve.EaseInOut(0f, 1f, 1f, 1f); // by default Full 3D sound
68+
69+
[Tooltip("The spread attenuation curve for simple 3D sounds. Only used when positioning is set to 3D")]
70+
public AnimationCurve spreadCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 0f); // by default no spread
71+
72+
[Tooltip("The lowpass attenuation curve for simple 3D sounds. Only used when positioning is set to 3D")]
73+
public AnimationCurve lowPassCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 0f); // by default no lowpass
74+
75+
[Tooltip("The reverb attenuation curve for simple 3D sounds. Only used when positioning is set to 3D")]
76+
public AnimationCurve reverbCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 0f); // by default no reverb
77+
78+
[Tooltip("The maximum attenuation distance for simple 3D sounds. Only used when positioning is set to 3D")]
79+
[Range(1f, 500f)]
80+
public float maxDistanceAttenuation3D = 100f;
81+
6382
[Tooltip("The distance, in meters at which the gain is 0 decibels. Only used when positioning is set to SpatialSound.")]
6483
[Range(SpatialSoundSettings.MinimumUnityGainDistanceMeters, SpatialSoundSettings.MaximumUnityGainDistanceMeters)]
6584
public float unityGainDistance = SpatialSoundSettings.DefaultUnityGainDistance;

Assets/HoloToolkit/SpatialSound/Scripts/UAudioManager/Editor/UAudioManagerBaseEditor.cs

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,37 @@ private void DrawEventInspector(SerializedProperty selectedEventProperty, TEvent
114114

115115
// Positioning
116116
selectedEvent.spatialization = (SpatialPositioningType)EditorGUILayout.Popup("Positioning", (int)selectedEvent.spatialization, this.posTypes);
117-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("roomSize"));
118-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("minGain"));
119-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("maxGain"));
120-
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("unityGainDistance"));
117+
118+
if (selectedEvent.spatialization == SpatialPositioningType.SpatialSound)
119+
{
120+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("roomSize"));
121+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("minGain"));
122+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("maxGain"));
123+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("unityGainDistance"));
124+
EditorGUILayout.Space();
125+
}
126+
else if (selectedEvent.spatialization == SpatialPositioningType.ThreeD)
127+
{
128+
Rect editorSize = new Rect(0f, 0f, 1f, 1f);
129+
float curveHeight = 30f;
130+
float curveWidth = 300f;
131+
132+
//Simple 3D Sounds properties
133+
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("maxDistanceAttenuation3D"));
134+
135+
//volume attenuation
136+
selectedEventProperty.FindPropertyRelative("attenuationCurve").animationCurveValue = EditorGUILayout.CurveField("Attenuation", selectedEventProperty.FindPropertyRelative("attenuationCurve").animationCurveValue, Color.red, editorSize, GUILayout.Height(curveHeight), GUILayout.Width(curveWidth), GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(true));
137+
//Spatial green
138+
selectedEventProperty.FindPropertyRelative("spatialCurve").animationCurveValue = EditorGUILayout.CurveField("Spatial", selectedEventProperty.FindPropertyRelative("spatialCurve").animationCurveValue, Color.green, editorSize, GUILayout.Height(curveHeight), GUILayout.Width(curveWidth), GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(true));
139+
//spread lightblue
140+
selectedEventProperty.FindPropertyRelative("spreadCurve").animationCurveValue = EditorGUILayout.CurveField("Spread", selectedEventProperty.FindPropertyRelative("spreadCurve").animationCurveValue, Color.blue, editorSize, GUILayout.Height(curveHeight), GUILayout.Width(curveWidth), GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(true));
141+
//lowpass purple
142+
selectedEventProperty.FindPropertyRelative("lowPassCurve").animationCurveValue = EditorGUILayout.CurveField("LowPass", selectedEventProperty.FindPropertyRelative("lowPassCurve").animationCurveValue, Color.magenta, editorSize, GUILayout.Height(curveHeight), GUILayout.Width(curveWidth), GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(true));
143+
//Yellow reverb
144+
selectedEventProperty.FindPropertyRelative("reverbCurve").animationCurveValue = EditorGUILayout.CurveField("Reverb", selectedEventProperty.FindPropertyRelative("reverbCurve").animationCurveValue, Color.yellow, editorSize, GUILayout.Height(curveHeight), GUILayout.Width(curveWidth), GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(true));
145+
146+
EditorGUILayout.Space();
147+
}
121148

122149
// Bus
123150
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("bus"));

0 commit comments

Comments
 (0)