# HG changeset patch # User Chris Cannam # Date 1406026410 -3600 # Node ID 355fb9ea3888347a6fb04d34b3f94be67e5a8494 # Parent 4d48ab57fbcc9c18ef6c132668e4c475f1bbf948 Global-only version that performs reasonably well diff -r 4d48ab57fbcc -r 355fb9ea3888 flattendynamics-ladspa.cpp --- a/flattendynamics-ladspa.cpp Tue Jul 22 11:27:59 2014 +0100 +++ b/flattendynamics-ladspa.cpp Tue Jul 22 11:53:30 2014 +0100 @@ -86,6 +86,7 @@ m_rmsLongTerm(0.f), m_rmsShortTerm(0.f), m_maxRmsLongTerm(0.f), + m_maxRmsShortTerm(0.f), m_gain(1.f) { reset(); @@ -162,6 +163,7 @@ m_rmsLongTerm = 0.f; m_rmsShortTerm = 0.f; m_maxRmsLongTerm = 0.f; + m_maxRmsShortTerm = 0.f; m_gain = 1.f; } @@ -200,6 +202,16 @@ m_maxRmsLongTerm = m_rmsLongTerm; } + if (m_rmsShortTerm > m_maxRmsShortTerm) { + m_maxRmsShortTerm = m_rmsShortTerm; + } + + float fixedGain = targetMaxRMS / m_maxRmsShortTerm; + + float targetGain = fixedGain; + +/* + float frac = m_rmsShortTerm / m_maxRmsLongTerm; // push up toward top of 0,1 range @@ -207,6 +219,8 @@ float targetRMS = targetMaxRMS * frac; float targetGain = targetRMS / m_rmsShortTerm; +*/ + if (targetGain > maxGain) { targetGain = maxGain; } diff -r 4d48ab57fbcc -r 355fb9ea3888 flattendynamics-ladspa.h --- a/flattendynamics-ladspa.h Tue Jul 22 11:27:59 2014 +0100 +++ b/flattendynamics-ladspa.h Tue Jul 22 11:53:30 2014 +0100 @@ -57,6 +57,7 @@ float m_rmsShortTerm; float m_maxRmsLongTerm; + float m_maxRmsShortTerm; float m_gain; };