Mercurial > hg > flattendynamics
diff flattendynamics-ladspa.cpp @ 8:355fb9ea3888
Global-only version that performs reasonably well
author | Chris Cannam |
---|---|
date | Tue, 22 Jul 2014 11:53:30 +0100 |
parents | 4d48ab57fbcc |
children | 9853fe9c7820 |
line wrap: on
line diff
--- 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; }