Voice: apply automatic gain control to the microphone (#587) #595
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/587-quiet-voice"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #587
Root cause
Automatic gain control was never applied. The setting is on by default
(
fluxer-coreCaptureConfig::auto_gain), andfluxer_voice::apm::Apmwraps WebRTC's audioprocessing module, but nothing used it.
apps/fluxer/src/audio_rt.rschain_configdroppedauto_gain("Echo cancellation and automatic gain … are left out"), and the LiveKit source iscreated with
auto_gain_control: false(crates/fluxer-voice/src/rtc.rs:439). So each Flaxativemicrophone was sent at whatever level the device captured: about −30 to −40 dBFS for typical
speech. The original's Chromium brings the same microphone to about −18 to −23 dBFS. When
everyone in the call uses Flaxative, everyone sounds 7 to 17 dB too quiet.
Measurements (levels in dBFS RMS)
push_remote→ mixer → resample → device ring (NullHost; 48/44.1 kHz × 1/2/6 ch; mono and stereo frames)i16→f32device conversion (cpalfrom_sample)NativeAudioStream(mono) →RoomEvent::AudioThe real speech is the ALSA test recordings (
/usr/share/sounds/alsa/*.wav), measured locallyand not committed. The level is the RMS over the 10 ms speech frames (those within 30 dB of the
loudest frame). RNNoise, the gate and the soft clip change speech by less than 0.1 dB. The
playback and receive paths lose nothing.
Change
fluxer-audio: adds aCaptureProcessortrait.CaptureChain::set_processorandAudioEngine::set_capture_processorrun it first in the chain. This is where Chromium appliesgetUserMediaprocessing in the original, before its RNNoise → gate → volume → soft clipgraph. As a result, the gate, the denoiser and the level meter all see the levelled signal.
apps/fluxer: whenauto_gainis on, the runtime putsfluxer_voice::apm::Apm(AGC2adaptive digital plus high-pass filter) in front of the chain. The processor is replaced only
when its configuration changes, so moving sliders keeps the AGC's state. Echo cancellation is
still not wired, because it needs the playback signal (#90).
Tests
apps/fluxeraudio_rt::tests::default_capture_levels_quiet_speech_like_the_original: withthe default settings, synthetic speech at −30 and −40 dBFS leaves the chain within −25 to
−18 dBFS and never reaches full scale. Without the processor it fails (−30.4 dBFS).
fluxer-audioengine::playback_keeps_the_level_of_a_remote_voice(±0.5 dB),f32_devices_get_the_same_scale_as_i16_devices, anddsp::chain_runs_the_processor_first_and_keeps_it_across_settings.fluxer-voicelivekit_interop::a_tone_arrives_at_the_level_it_was_sent(±0.5 dB;FLUXER_LIVEKIT_TESTS=1, passed locally).FLUXER_SCREENSHOT_TESTS=1 cargo xtask ciis green locally.Not measured here
has no session volume, and the cpal host does not set one.
Chromium also uses AGC1's analog input-volume controller, which raises the OS microphone
volume. This change does not do that, so a very quiet microphone may still need its system
volume raised.
lossless with a Flaxative speaker.
🤖 Generated with Claude Code