[fix](trx-frontend): narrow weak WFM to 60 kHz
CI / lint (push) Failing after 1s
CI / test (push) Failing after 2s
CI / reuse (push) Failing after 1s

This commit was merged in pull request #13.
This commit is contained in:
sjg
2026-08-01 02:04:14 +02:00
parent d347b493d9
commit 412651d612
@@ -4268,7 +4268,7 @@ const MODE_BW_DEFAULTS = {
FM: [12_500, 2_500, 25_000, 500],
AIS: [25_000, 12_500, 50_000, 500],
VDES: [100_000, 25_000, 200_000, 1_000],
WFM: [180_000, 50_000,300_000,5_000],
WFM: [180_000, 60_000,300_000,5_000],
DIG: [3_000, 300, 6_000, 100],
PKT: [25_000, 300, 50_000, 500],
};
@@ -4390,7 +4390,7 @@ function estimateOccupiedBandwidth(data, centerHz) {
let peak = -Infinity;
for (let i = searchLo; i <= searchHi; i++) peak = Math.max(peak, smoothed[i]);
const snr = peak - noise;
if (!Number.isFinite(snr) || snr < (isWfm ? 5 : 4)) return defaultBw;
if (!Number.isFinite(snr) || snr < (isWfm ? 5 : 4)) return isWfm ? minBw : defaultBw;
// A threshold relative to the noise floor finds occupied bandwidth much
// more reliably than one relative to the peak. The latter fails for WFM,
@@ -4424,10 +4424,10 @@ function estimateOccupiedBandwidth(data, centerHz) {
rawBw = 2 * Math.max(leftHz, rightHz);
}
// Add a transition-band margin. Reject implausibly narrow WFM measurements:
// they are normally a pilot/centre feature or a neighbouring narrow signal.
// Add a transition-band margin. Weak WFM deliberately falls back to the
// 60 kHz mode floor above: a narrower filter trades stereo/RDS content for
// a useful improvement in intelligibility when the signal is very poor.
rawBw *= isWfm ? 1.08 : 1.12;
if (isWfm && rawBw < defaultBw * 0.55) return defaultBw;
const clamped = Math.max(minBw, Math.min(maxBw, rawBw));
return Math.max(stepBw, Math.round(clamped / stepBw) * stepBw);
}