comparison 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
comparison
equal deleted inserted replaced
7:4d48ab57fbcc 8:355fb9ea3888
84 m_sumOfSquaresLongTerm(0.f), 84 m_sumOfSquaresLongTerm(0.f),
85 m_sumOfSquaresShortTerm(0.f), 85 m_sumOfSquaresShortTerm(0.f),
86 m_rmsLongTerm(0.f), 86 m_rmsLongTerm(0.f),
87 m_rmsShortTerm(0.f), 87 m_rmsShortTerm(0.f),
88 m_maxRmsLongTerm(0.f), 88 m_maxRmsLongTerm(0.f),
89 m_maxRmsShortTerm(0.f),
89 m_gain(1.f) 90 m_gain(1.f)
90 { 91 {
91 reset(); 92 reset();
92 } 93 }
93 94
160 m_sumOfSquaresLongTerm = 0.0; 161 m_sumOfSquaresLongTerm = 0.0;
161 m_sumOfSquaresShortTerm = 0.0; 162 m_sumOfSquaresShortTerm = 0.0;
162 m_rmsLongTerm = 0.f; 163 m_rmsLongTerm = 0.f;
163 m_rmsShortTerm = 0.f; 164 m_rmsShortTerm = 0.f;
164 m_maxRmsLongTerm = 0.f; 165 m_maxRmsLongTerm = 0.f;
166 m_maxRmsShortTerm = 0.f;
165 m_gain = 1.f; 167 m_gain = 1.f;
166 } 168 }
167 169
168 void 170 void
169 FlattenDynamics::updateParameters() 171 FlattenDynamics::updateParameters()
198 200
199 if (m_rmsLongTerm > m_maxRmsLongTerm) { 201 if (m_rmsLongTerm > m_maxRmsLongTerm) {
200 m_maxRmsLongTerm = m_rmsLongTerm; 202 m_maxRmsLongTerm = m_rmsLongTerm;
201 } 203 }
202 204
205 if (m_rmsShortTerm > m_maxRmsShortTerm) {
206 m_maxRmsShortTerm = m_rmsShortTerm;
207 }
208
209 float fixedGain = targetMaxRMS / m_maxRmsShortTerm;
210
211 float targetGain = fixedGain;
212
213 /*
214
203 float frac = m_rmsShortTerm / m_maxRmsLongTerm; 215 float frac = m_rmsShortTerm / m_maxRmsLongTerm;
204 216
205 // push up toward top of 0,1 range 217 // push up toward top of 0,1 range
206 frac = pow(frac, 0.5); 218 frac = pow(frac, 0.5);
207 219
208 float targetRMS = targetMaxRMS * frac; 220 float targetRMS = targetMaxRMS * frac;
209 float targetGain = targetRMS / m_rmsShortTerm; 221 float targetGain = targetRMS / m_rmsShortTerm;
222 */
223
210 if (targetGain > maxGain) { 224 if (targetGain > maxGain) {
211 targetGain = maxGain; 225 targetGain = maxGain;
212 } 226 }
213 227
214 float catchUpSamples = catchUpSeconds * m_sampleRate; 228 float catchUpSamples = catchUpSeconds * m_sampleRate;