MCPcopy Create free account
hub / github.com/aethersdr/AetherSDR / testLimitRatio

Function testLimitRatio

tests/client_comp_test.cpp:184–214  ·  view source on GitHub ↗

High ratio (20:1) clamps near threshold.

Source from the content-addressed store, hash-verified

182
183// High ratio (20:1) clamps near threshold.
184void testLimitRatio()
185{
186 ClientComp comp;
187 comp.prepare(kSampleRate);
188 comp.setEnabled(true);
189 comp.setThresholdDb(-12.0f);
190 comp.setRatio(20.0f);
191 comp.setKneeDb(0.0f);
192 comp.setMakeupDb(0.0f);
193 comp.setAttackMs(50.0f);
194 comp.setReleaseMs(500.0f);
195 comp.setLimiterEnabled(false);
196
197 const float amp = std::pow(10.0f, -3.0f / 20.0f); // -3 dBFS peak
198 const int warm = static_cast<int>(kSampleRate) * 3;
199 auto warmBuf = makeTone(1000.0, warm, amp);
200 processBlocks(comp, warmBuf.data(), warm);
201
202 const int frames = static_cast<int>(kSampleRate);
203 auto buf = makeTone(1000.0, frames, amp);
204 processBlocks(comp, buf.data(), frames);
205
206 const float measPeak = peakAbsStereo(buf.data(), frames);
207 const float measDbfs = linToDb(measPeak);
208 const float expected = -12.0f + 9.0f / 20.0f;
209 const float errDb = measDbfs - expected;
210 report("20:1 ratio: -3 dBFS in -> near threshold out",
211 std::fabs(errDb) < 1.5f,
212 "measured=" + std::to_string(measDbfs) + " dBFS, expected="
213 + std::to_string(expected));
214}
215
216// Makeup gain applied to below-threshold signal = clean linear boost.
217void testMakeupGain()

Callers 1

mainFunction · 0.85

Calls 15

setKneeDbMethod · 0.80
setMakeupDbMethod · 0.80
setLimiterEnabledMethod · 0.80
makeToneFunction · 0.70
processBlocksFunction · 0.70
peakAbsStereoFunction · 0.70
linToDbFunction · 0.70
reportFunction · 0.70
prepareMethod · 0.45
setEnabledMethod · 0.45
setThresholdDbMethod · 0.45
setRatioMethod · 0.45

Tested by

no test coverage detected