# HG changeset patch # User Chris Cannam # Date 1405610597 -3600 # Node ID 12d364f12d37f8836f81a3895500ad8f6bee9acf # Parent 57990edc441b5c58b9295dd616e2502c92c495f0 delete/delete[] fix; max gain diff -r 57990edc441b -r 12d364f12d37 flattendynamics-ladspa.cpp --- 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;