High ratio (20:1) clamps near threshold.
| 182 | |
| 183 | // High ratio (20:1) clamps near threshold. |
| 184 | void 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. |
| 217 | void testMakeupGain() |
no test coverage detected