From 3d8fd324885a6646cd52bf39364019e6c33950e9 Mon Sep 17 00:00:00 2001 From: Stan Grams Date: Sat, 28 Feb 2026 20:30:12 +0100 Subject: [PATCH] [fix](trx-backend-soapysdr): prevent double agc on mono wfm Co-authored-by: Codex Signed-off-by: Stan Grams --- .../trx-backend/trx-backend-soapysdr/src/dsp.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/trx-server/trx-backend/trx-backend-soapysdr/src/dsp.rs b/src/trx-server/trx-backend/trx-backend-soapysdr/src/dsp.rs index a649d60..34ad242 100644 --- a/src/trx-server/trx-backend/trx-backend-soapysdr/src/dsp.rs +++ b/src/trx-server/trx-backend/trx-backend-soapysdr/src/dsp.rs @@ -654,8 +654,16 @@ impl ChannelDsp { // AGC is applied to WFM output too so all modes share the same target level. let audio = if let Some(decoder) = self.wfm_decoder.as_mut() { let mut out = decoder.process_iq(&decimated); - for s in &mut out { - *s = self.audio_agc.process(*s); + if !self.wfm_stereo && self.output_channels >= 2 { + for pair in out.chunks_exact_mut(2) { + let mono = self.audio_agc.process(pair[0]); + pair[0] = mono; + pair[1] = mono; + } + } else { + for s in &mut out { + *s = self.audio_agc.process(*s); + } } out } else {