[fix](trx-backend-soapysdr): hard-limit iq magnitude before wfm discriminator

Normalize IQ samples exceeding unit magnitude before the FM
discriminator. The discriminator only uses phase, so clamping
amplitude prevents overdeviated signals from producing clipped
composite baseband without losing frequency information.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
2026-03-01 01:58:16 +01:00
parent 13de90d664
commit 8f6a5af4ec
@@ -852,6 +852,17 @@ impl ChannelDsp {
} }
} }
// Hard-limit IQ magnitude before the WFM discriminator so overdeviated
// signals don't produce clipped composite baseband.
if self.wfm_decoder.is_some() {
for sample in decimated.iter_mut() {
let mag = (sample.re * sample.re + sample.im * sample.im).sqrt();
if mag > 1.0 {
*sample /= mag;
}
}
}
// --- 4. Demodulate + post-process ----------------------------------- // --- 4. Demodulate + post-process -----------------------------------
// WFM: full composite decoder (handles its own DC blocks + deemphasis), // WFM: full composite decoder (handles its own DC blocks + deemphasis),
// then apply post-audio AGC on the decoded PCM. Other modes use the // then apply post-audio AGC on the decoded PCM. Other modes use the