changeset 3:12d364f12d37

delete/delete[] fix; max gain
author Chris Cannam
date Thu, 17 Jul 2014 16:23:17 +0100
parents 57990edc441b
children e36fe9312ad4
files flattendynamics-ladspa.cpp
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/flattendynamics-ladspa.cpp	Thu Jul 17 14:37:27 2014 +0100
+++ b/flattendynamics-ladspa.cpp	Thu Jul 17 16:23:17 2014 +0100
@@ -11,6 +11,7 @@
 const float historySeconds = 4.f;
 const float catchUpSeconds = 0.5f;
 const float targetRMS = 0.1f;
+const float maxGain = 20.f;
 
 const char *const
 FlattenDynamics::portNames[PortCount] =
@@ -88,7 +89,7 @@
 
 FlattenDynamics::~FlattenDynamics()
 {
-    delete m_history;
+    delete[] m_history;
 }
     
 LADSPA_Handle
@@ -142,7 +143,7 @@
 void
 FlattenDynamics::reset()
 {
-    delete m_history;
+    delete[] m_history;
     m_histlen = int(round(m_sampleRate * historySeconds));
     if (m_histlen < 1) m_histlen = 1;
     m_history = new float[m_histlen];
@@ -186,6 +187,9 @@
     }
 
     float targetGain = targetRMS / m_rms;
+    if (targetGain > maxGain) {
+        targetGain = maxGain;
+    }
     float catchUpSamples = catchUpSeconds * m_sampleRate;
     // asymptotic, could improve?
     m_gain = m_gain + (targetGain - m_gain) / catchUpSamples;