Let AGC raise the noise floor further to bring up a distant voice

AGC2 won't amplify the background noise above -50 dBFS, which also caps
the gain for a voice barely above that noise: a distant talker ended up
5 dB quieter than a near one with noise suppression on, 12 dB with it
off. A "Boost quiet speech" setting (0-20 dB, default 0) raises the cap,
live, on desktop and Android.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 22:08:50 +00:00
co-authored by Claude Opus 5.5
parent 491cbcb259
commit 73a15a8cfc
10 changed files with 87 additions and 2 deletions
@@ -166,6 +166,26 @@ class AudioProcessorTest {
"quiet speech should be raised by more than 12 dB");
}
@Test
void gainBoostLetsTheNoiseFloorRiseFurther() {
// -60 dBFS of noise alone: AGC2 starts at 15 dB of gain and, with no speech to
// raise it, can only lower it, down to what keeps the noise under its cap.
Random random = new Random(3);
float[] noise = new float[RATE * 3];
for (int i = 0; i < noise.length; i++) noise[i] = (float) (random.nextGaussian() * 0.001);
AudioProcessor plain = new AudioProcessor();
plain.setGainControl(true);
AudioProcessor boosted = new AudioProcessor();
boosted.setGainControl(true);
boosted.setGainBoost(20);
double plainDb = 20 * Math.log10(rms(run(plain, noise, Set.of()), RATE * 2, RATE * 3));
double boostedDb = 20 * Math.log10(rms(run(boosted, noise, Set.of()), RATE * 2, RATE * 3));
assertEquals(-50, plainDb, 1.5, "the noise is held at AGC2's -50 dBFS cap");
assertEquals(-45, boostedDb, 1.5, "with the cap 20 dB higher, the initial 15 dB of gain stays");
}
private static double rms(float[] x, int from, int to) {
double sum = 0;
for (int i = from; i < to; i++) sum += x[i] * x[i];