Signal well above threshold → unity gain (no attenuation).
| 114 | |
| 115 | // Signal well above threshold → unity gain (no attenuation). |
| 116 | void testAboveThresholdPassthrough() |
| 117 | { |
| 118 | ClientGate gate; |
| 119 | gate.prepare(kSampleRate); |
| 120 | gate.setEnabled(true); |
| 121 | gate.setThresholdDb(-40.0f); |
| 122 | gate.setRatio(10.0f); |
| 123 | gate.setAttackMs(0.5f); |
| 124 | gate.setReleaseMs(50.0f); |
| 125 | gate.setHoldMs(0.0f); |
| 126 | gate.setFloorDb(-40.0f); |
| 127 | |
| 128 | // Prime envelope with a long burst at -6 dBFS. |
| 129 | const float ampIn = dbToLin(-6.0f); |
| 130 | auto buf = makeTone(1000.0, 4800, ampIn); // 200 ms |
| 131 | processBlocks(gate, buf.data(), 4800); |
| 132 | |
| 133 | // Now measure the trailing block — envelope is fully settled. |
| 134 | const int tailFrames = 512; |
| 135 | auto tail = makeTone(1000.0, tailFrames, ampIn); |
| 136 | processBlocks(gate, tail.data(), tailFrames); |
| 137 | |
| 138 | const float outPeak = peakAbsStereo(tail.data(), tailFrames); |
| 139 | const float grDb = linToDb(outPeak / ampIn); |
| 140 | |
| 141 | report("above-threshold: unity gain (no reduction)", |
| 142 | std::fabs(grDb) < 0.5f, |
| 143 | "GR=" + std::to_string(grDb) + " dB"); |
| 144 | } |
| 145 | |
| 146 | // Signal below threshold, soft expander (ratio 2:1, floor -15 dB): |
| 147 | // expected reduction = min(floor, (T - env) * (ratio - 1)) |
no test coverage detected