changeset 10:46ed42184699

Some decay on the long-term-only version
author Chris Cannam
date Tue, 22 Jul 2014 13:28:05 +0100
parents 9853fe9c7820
children e662e661ae65
files flattendynamics-ladspa.cpp
diffstat 1 files changed, 6 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/flattendynamics-ladspa.cpp	Tue Jul 22 13:18:33 2014 +0100
+++ b/flattendynamics-ladspa.cpp	Tue Jul 22 13:28:05 2014 +0100
@@ -198,8 +198,11 @@
         return f;
     }
 
-    if (m_rmsLongTerm > m_maxRmsLongTerm) {
+    if (m_rmsLongTerm >= m_maxRmsLongTerm) {
         m_maxRmsLongTerm = m_rmsLongTerm;
+    } else {
+        float decay = 0.999;
+        m_maxRmsLongTerm = m_rmsLongTerm + (m_maxRmsLongTerm - m_rmsLongTerm) * decay;
     }
 
     if (m_rmsShortTerm > m_maxRmsShortTerm) {
@@ -208,6 +211,8 @@
 
     float fixedGain = targetMaxRMS / m_maxRmsLongTerm;
 
+    float targetGain = fixedGain;
+/*
     float frac = m_rmsShortTerm / m_maxRmsShortTerm;
 
     // push up toward top of 0,1 range
@@ -217,15 +222,6 @@
 
     float targetGain = fixedGain * (targetRMS / m_rmsShortTerm);
 
-/*
-
-    float frac = m_rmsShortTerm / m_maxRmsLongTerm;
-    
-    // push up toward top of 0,1 range
-    frac = pow(frac, 0.5);
-
-    float targetRMS = targetMaxRMS * frac;
-    float targetGain = targetRMS / m_rmsShortTerm;
 */
 
     if (targetGain > maxGain) {