Skip to content

Commit

Permalink
Merge pull request #309 from AsoboStudio/master
Browse files Browse the repository at this point in the history
spatial sound - Added spread,spatial,reverb curve to UAudioManager
  • Loading branch information
darax committed Oct 27, 2016
2 parents 2608114 + dc635d0 commit 82fc644
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 5 deletions.
Expand Up @@ -149,7 +149,19 @@ private void SetSourceProperties()
{
forEachSource((source) =>
{
source.rolloffMode = AudioRolloffMode.Logarithmic;
if (audioEvent.spatialization == SpatialPositioningType.ThreeD)
{
source.rolloffMode = AudioRolloffMode.Custom;
source.maxDistance = audioEvent.maxDistanceAttenuation3D;
source.SetCustomCurve(AudioSourceCurveType.CustomRolloff, audioEvent.attenuationCurve);
source.SetCustomCurve(AudioSourceCurveType.SpatialBlend, audioEvent.spatialCurve);
source.SetCustomCurve(AudioSourceCurveType.Spread, audioEvent.spreadCurve);
source.SetCustomCurve(AudioSourceCurveType.ReverbZoneMix, audioEvent.reverbCurve);
}
else
{
source.rolloffMode = AudioRolloffMode.Logarithmic;
}
});
}

Expand Down
Expand Up @@ -60,6 +60,25 @@ public class AudioEvent : IComparable, IComparable<AudioEvent>
[Range(SpatialSoundSettings.MinimumGainDecibels, SpatialSoundSettings.MaximumGainDecibels)]
public float maxGain = SpatialSoundSettings.DefaultMaxGain;

[Tooltip("The volume attenuation curve for simple 3D sounds. Only used when positioning is set to 3D")]
public AnimationCurve attenuationCurve = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f); // By default simple attenuation

[Tooltip("The spatial attenuation curve for simple 3D sounds. Only used when positioning is set to 3D")]
public AnimationCurve spatialCurve = AnimationCurve.EaseInOut(0f, 1f, 1f, 1f); // by default Full 3D sound

[Tooltip("The spread attenuation curve for simple 3D sounds. Only used when positioning is set to 3D")]
public AnimationCurve spreadCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 0f); // by default no spread

[Tooltip("The lowpass attenuation curve for simple 3D sounds. Only used when positioning is set to 3D")]
public AnimationCurve lowPassCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 0f); // by default no lowpass

[Tooltip("The reverb attenuation curve for simple 3D sounds. Only used when positioning is set to 3D")]
public AnimationCurve reverbCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 0f); // by default no reverb

[Tooltip("The maximum attenuation distance for simple 3D sounds. Only used when positioning is set to 3D")]
[Range(1f, 500f)]
public float maxDistanceAttenuation3D = 100f;

[Tooltip("The distance, in meters at which the gain is 0 decibels. Only used when positioning is set to SpatialSound.")]
[Range(SpatialSoundSettings.MinimumUnityGainDistanceMeters, SpatialSoundSettings.MaximumUnityGainDistanceMeters)]
public float unityGainDistance = SpatialSoundSettings.DefaultUnityGainDistance;
Expand Down
Expand Up @@ -114,10 +114,37 @@ private void DrawEventInspector(SerializedProperty selectedEventProperty, TEvent

// Positioning
selectedEvent.spatialization = (SpatialPositioningType)EditorGUILayout.Popup("Positioning", (int)selectedEvent.spatialization, this.posTypes);
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("roomSize"));
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("minGain"));
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("maxGain"));
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("unityGainDistance"));

if (selectedEvent.spatialization == SpatialPositioningType.SpatialSound)
{
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("roomSize"));
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("minGain"));
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("maxGain"));
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("unityGainDistance"));
EditorGUILayout.Space();
}
else if (selectedEvent.spatialization == SpatialPositioningType.ThreeD)
{
Rect editorSize = new Rect(0f, 0f, 1f, 1f);
float curveHeight = 30f;
float curveWidth = 300f;

//Simple 3D Sounds properties
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("maxDistanceAttenuation3D"));

//volume attenuation
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));
//Spatial green
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));
//spread lightblue
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));
//lowpass purple
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));
//Yellow reverb
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));

EditorGUILayout.Space();
}

// Bus
EditorGUILayout.PropertyField(selectedEventProperty.FindPropertyRelative("bus"));
Expand Down

0 comments on commit 82fc644

Please sign in to comment.