From a8ed9e8fa4431ebde0a6e07467d2a410c201a680 Mon Sep 17 00:00:00 2001 From: Stan Grams Date: Sun, 1 Mar 2026 00:24:33 +0100 Subject: [PATCH] [fix](trx-backend-soapysdr): lower wfm internal rate ceiling Co-authored-by: OpenAI Codex Signed-off-by: Stan Grams --- .../trx-backend/trx-backend-soapysdr/src/dsp.rs | 14 ++++++++++++-- 1 file changed, 12 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 35fe1d6..a49fb1f 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 @@ -365,6 +365,14 @@ pub struct ChannelDsp { } impl ChannelDsp { + fn clamp_bandwidth_for_mode(mode: &RigMode, bandwidth_hz: u32) -> u32 { + if *mode == RigMode::WFM { + bandwidth_hz.min(192_000) + } else { + bandwidth_hz + } + } + pub fn set_channel_if_hz(&mut self, channel_if_hz: f64) { self.channel_if_hz = channel_if_hz; self.mixer_phase_inc = if self.sdr_sample_rate == 0 { @@ -385,7 +393,7 @@ impl ChannelDsp { } let target_rate = if *mode == RigMode::WFM { - audio_bandwidth_hz.max(audio_sample_rate.saturating_mul(4)).max(228_000) + audio_bandwidth_hz.max(audio_sample_rate.saturating_mul(4)).max(192_000) } else { audio_sample_rate.max(1) }; @@ -395,6 +403,7 @@ impl ChannelDsp { } fn rebuild_filters(&mut self, reset_wfm_decoder: bool) { + self.audio_bandwidth_hz = Self::clamp_bandwidth_for_mode(&self.mode, self.audio_bandwidth_hz); let (next_decim_factor, channel_sample_rate) = Self::pipeline_rates( &self.mode, self.sdr_sample_rate, @@ -459,6 +468,7 @@ impl ChannelDsp { pcm_tx: broadcast::Sender>, ) -> Self { let output_channels = output_channels.max(1); + let audio_bandwidth_hz = Self::clamp_bandwidth_for_mode(mode, audio_bandwidth_hz); let frame_size = if audio_sample_rate == 0 || frame_duration_ms == 0 { 960 * output_channels } else { @@ -557,7 +567,7 @@ impl ChannelDsp { /// /// Changes take effect on the next call to `process_block`. pub fn set_filter(&mut self, bandwidth_hz: u32, taps: usize) { - self.audio_bandwidth_hz = bandwidth_hz; + self.audio_bandwidth_hz = Self::clamp_bandwidth_for_mode(&self.mode, bandwidth_hz); self.fir_taps = taps.max(1); self.rebuild_filters(false); }