From 14d58ce989074e4c9f290d224db54d1b7f6ffb74 Mon Sep 17 00:00:00 2001 From: Stan Grams Date: Wed, 4 Mar 2026 23:14:23 +0100 Subject: [PATCH] [fix](trx-server): hard-gate CW decode to CW/CWR modes Enforce CW decode processing only when mode is CW/CWR and decoder is enabled, even within the receive loop, and remove CW path RMS zero-gating to preserve weak tone decoding. Co-authored-by: Codex Signed-off-by: Stan Grams --- src/trx-server/src/audio.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/trx-server/src/audio.rs b/src/trx-server/src/audio.rs index 0870eb0..980bb22 100644 --- a/src/trx-server/src/audio.rs +++ b/src/trx-server/src/audio.rs @@ -1108,6 +1108,8 @@ pub async fn run_cw_decoder( match recv { Ok(frame) => { let state = state_rx.borrow(); + let process_enabled = state.cw_decode_enabled + && matches!(state.status.mode, RigMode::CW | RigMode::CWR); if state.cw_auto != last_auto { last_auto = state.cw_auto; decoder.set_auto(last_auto); @@ -1125,9 +1127,17 @@ pub async fn run_cw_decoder( decoder.reset(); info!("CW decoder reset (seq={})", last_reset_seq); } + if !process_enabled { + if was_active { + decoder.reset(); + was_active = false; + } + active = false; + continue; + } // Downmix to mono if stereo - let mut mono = if channels > 1 { + let mono = if channels > 1 { let num_frames = frame.len() / channels as usize; let mut mono = Vec::with_capacity(num_frames); for i in 0..num_frames { @@ -1137,8 +1147,6 @@ pub async fn run_cw_decoder( } else { frame }; - apply_decode_audio_gate(&mut mono); - was_active = true; for evt in decoder.process_samples(&mono) { if let Some(logger) = decode_logs.as_ref() {