# HG changeset patch # User Chris Cannam # Date 1406032085 -3600 # Node ID 46ed42184699916a3860c47147ba2d2862a65ce1 # Parent 9853fe9c7820d64e5ef210dcc50e212c575ddb16 Some decay on the long-term-only version diff -r 9853fe9c7820 -r 46ed42184699 flattendynamics-ladspa.cpp --- 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) {