Skip to content

Commit

Permalink
Rename: AutoGain -> PeakTracking
Browse files Browse the repository at this point in the history
  • Loading branch information
keijiro committed Apr 10, 2019
1 parent f6ed4cf commit d0ef178
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
11 changes: 5 additions & 6 deletions Assets/Lasp/Editor/AudioLevelMonitorEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ sealed class AudioLevelTrackerEditor : Editor
{
SerializedProperty _filterType;
SerializedProperty _dynamicRange;
SerializedProperty _autoGain;
SerializedProperty _peakTracking;
SerializedProperty _gain;
SerializedProperty _holdAndFallDown;
SerializedProperty _fallDownSpeed;
SerializedProperty _normalizedLevelEvent;

static GUIContent _labelAutoGain = new GUIContent("Auto Gain Control");
static GUIContent _labelDynamicRange = new GUIContent("Dynamic Range");
static GUIContent _labelDynamicRangeWide = new GUIContent("Dynamic Range (dB)");
static GUIContent _labelGain = new GUIContent("Gain (dB)");
Expand All @@ -28,7 +27,7 @@ void OnEnable()
{
_filterType = serializedObject.FindProperty("_filterType");
_dynamicRange = serializedObject.FindProperty("_dynamicRange");
_autoGain = serializedObject.FindProperty("_autoGain");
_peakTracking = serializedObject.FindProperty("_peakTracking");
_gain = serializedObject.FindProperty("_gain");
_holdAndFallDown = serializedObject.FindProperty("_holdAndFallDown");
_fallDownSpeed = serializedObject.FindProperty("_fallDownSpeed");
Expand All @@ -49,9 +48,9 @@ public override void OnInspectorGUI()

EditorGUILayout.PropertyField(_filterType);
EditorGUILayout.PropertyField(_dynamicRange, wide ? _labelDynamicRangeWide : _labelDynamicRange);
EditorGUILayout.PropertyField(_autoGain, _labelAutoGain);
EditorGUILayout.PropertyField(_peakTracking);

if (_autoGain.hasMultipleDifferentValues || !_autoGain.boolValue)
if (_peakTracking.hasMultipleDifferentValues || !_peakTracking.boolValue)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(_gain, _labelGain);
Expand All @@ -77,7 +76,7 @@ public override void OnInspectorGUI()
{
EditorGUILayout.Space();
if (GUILayout.Button("Reset Auto Gain"))
foreach (AudioLevelTracker t in targets) t.ResetAutoGain();
foreach (AudioLevelTracker t in targets) t.ResetPeak();
}

EditorGUILayout.Space();
Expand Down
15 changes: 8 additions & 7 deletions Assets/Lasp/Runtime/AudioLevelTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ public Lasp.FilterType filterType {
set { _filterType = value; }
}

[SerializeField] bool _autoGain = true;
[UnityEngine.Serialization.FormerlySerializedAs("_autoGain")]
[SerializeField] bool _peakTracking = true;

public bool autoGain {
get { return _autoGain; }
set { _autoGain = value; }
public bool peakTracking {
get { return _peakTracking; }
set { _peakTracking = value; }
}

[SerializeField, Range(-10, 40)] float _gain = 6;
Expand Down Expand Up @@ -69,7 +70,7 @@ public AudioLevelEvent normalizedLevelEvent {
#region Runtime public properties and methods

public float calculatedGain {
get { return _autoGain ? -_peak : _gain; }
get { return _peakTracking ? -_peak : _gain; }
}

public float inputAmplitude {
Expand All @@ -80,7 +81,7 @@ public float normalizedLevel {
get { return _amplitude; }
}

public void ResetAutoGain()
public void ResetPeak()
{
_peak = kSilence;
}
Expand Down Expand Up @@ -109,7 +110,7 @@ void Update()
var dt = Time.deltaTime;

// Automatic gain control
if (_autoGain)
if (_peakTracking)
{
// Gradually falls down to the minimum amplitude.
const float peakFallSpeed = 0.6f;
Expand Down

0 comments on commit d0ef178

Please sign in to comment.