[fix](trx-rs): sync sdr rds tuning and deemphasis default

Make the primary SoapySDR DSP channel follow the tuned\nfrequency so RDS decoding stays aligned with the active\nfrequency rather than the hardware center.\n\nMove the default WFM deemphasis setting to server SDR\nconfig and default it to 50 us, then pass that value into\nthe SoapySDR backend.\n\nCo-authored-by: Codex <codex@openai.com>

Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
2026-02-28 11:04:40 +01:00
parent 855d21fd8a
commit 6f09022563
4 changed files with 26 additions and 2 deletions
@@ -296,6 +296,15 @@ pub struct ChannelDsp {
}
impl ChannelDsp {
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 {
0.0
} else {
2.0 * std::f64::consts::PI * channel_if_hz / self.sdr_sample_rate as f64
};
}
fn pipeline_rates(
mode: &RigMode,
sdr_sample_rate: u32,
@@ -73,6 +73,7 @@ impl SoapySdrRig {
audio_sample_rate: u32,
audio_channels: usize,
frame_duration_ms: u16,
wfm_deemphasis_us: u32,
initial_freq: Freq,
initial_mode: RigMode,
sdr_sample_rate: u32,
@@ -113,7 +114,7 @@ impl SoapySdrRig {
audio_sample_rate,
audio_channels,
frame_duration_ms,
75,
wfm_deemphasis_us,
channels,
);
@@ -180,7 +181,7 @@ impl SoapySdrRig {
center_offset_hz,
center_hz: hardware_center_hz,
retune_cmd,
wfm_deemphasis_us: 75,
wfm_deemphasis_us,
})
}
@@ -196,6 +197,7 @@ impl SoapySdrRig {
48_000,
1,
20,
50,
Freq { hz: 144_300_000 },
RigMode::USB,
1_920_000,
@@ -266,6 +268,11 @@ impl RigCat for SoapySdrRig {
*cmd = Some(hardware_hz as f64);
}
}
if let Some(dsp_arc) = self.pipeline.channel_dsps.get(self.primary_channel_idx) {
let channel_if_hz = (self.freq.hz as i64 - self.center_hz) as f64;
dsp_arc.lock().unwrap().set_channel_if_hz(channel_if_hz);
}
Ok(())
})
}
@@ -280,6 +287,10 @@ impl RigCat for SoapySdrRig {
if let Ok(mut cmd) = self.retune_cmd.lock() {
*cmd = Some(self.center_hz as f64);
}
if let Some(dsp_arc) = self.pipeline.channel_dsps.get(self.primary_channel_idx) {
let channel_if_hz = (self.freq.hz as i64 - self.center_hz) as f64;
dsp_arc.lock().unwrap().set_channel_if_hz(channel_if_hz);
}
Ok(())
})
}