Compare commits

..
Author SHA1 Message Date
sjg bf819aa177 [fix](trx-frontend): narrow weak WFM to 60 kHz
CI / lint (pull_request) Failing after 1s
CI / test (pull_request) Failing after 2s
CI / reuse (pull_request) Failing after 2s
2026-08-01 02:03:53 +02:00
sjg 0f4afda843 [fix](trx-frontend): make auto bandwidth modulation-aware
CI / lint (pull_request) Failing after 0s
CI / test (pull_request) Failing after 0s
CI / reuse (pull_request) Failing after 0s
2026-08-01 02:02:13 +02:00
2 changed files with 12 additions and 38 deletions
@@ -840,8 +840,6 @@ let jogMult = loadSetting("jogMult", 1); // divisor: 1, 10, 100
let jogStep = Math.max(Math.round(jogUnit / jogMult), 1);
let minFreqStepHz = 1;
let lastModeName = "";
let lastWfmCci = 0;
let lastWfmAci = 0;
const VFO_COLORS = ["var(--accent-green)", "var(--accent-yellow)"];
function vfoColor(idx) {
if (idx < VFO_COLORS.length) return VFO_COLORS[idx];
@@ -3295,14 +3293,8 @@ function render(update) {
wfmStFlagEl.classList.toggle("wfm-st-flag-stereo", detected);
wfmStFlagEl.classList.toggle("wfm-st-flag-mono", !detected);
}
if (typeof update.filter.wfm_cci === "number") {
lastWfmCci = Math.max(0, Math.min(100, update.filter.wfm_cci));
updateIntfBar(wfmCciFillEl, wfmCciValEl, lastWfmCci);
}
if (typeof update.filter.wfm_aci === "number") {
lastWfmAci = Math.max(0, Math.min(100, update.filter.wfm_aci));
updateIntfBar(wfmAciFillEl, wfmAciValEl, lastWfmAci);
}
if (typeof update.filter.wfm_cci === "number") updateIntfBar(wfmCciFillEl, wfmCciValEl, update.filter.wfm_cci);
if (typeof update.filter.wfm_aci === "number") updateIntfBar(wfmAciFillEl, wfmAciValEl, update.filter.wfm_aci);
if (samStereoWidthEl && typeof update.filter.sam_stereo_width === "number") {
samStereoWidthEl.value = String(Math.round(update.filter.sam_stereo_width * 100));
}
@@ -4356,7 +4348,7 @@ async function applyBandwidthFromInput() {
} catch (_) {}
}
function estimateOccupiedBandwidth(data, centerHz, interference = {}) {
function estimateOccupiedBandwidth(data, centerHz) {
if (!data || !isBinsArray(data.bins) || data.bins.length < 3 || !Number.isFinite(centerHz)) {
return null;
}
@@ -4436,30 +4428,13 @@ function estimateOccupiedBandwidth(data, centerHz, interference = {}) {
// 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) {
const aci = Math.max(0, Math.min(100, Number(interference.aci) || 0)) / 100;
const cci = Math.max(0, Math.min(100, Number(interference.cci) || 0)) / 100;
// Adjacent-channel energy is outside the wanted modulation, so ACI can
// safely drive the cap all the way from the 300 kHz ceiling to 60 kHz.
const aciCap = maxBw - (maxBw - minBw) * aci;
// CCI overlaps the wanted station and cannot be removed by an RF filter.
// Only distrust the widest edge estimates, retaining at least 65% of the
// useful range between the weak-signal floor and nominal WFM bandwidth.
const cciFloor = minBw + (defaultBw - minBw) * 0.65;
const cciCap = maxBw - (maxBw - cciFloor) * cci;
rawBw = Math.min(rawBw, aciCap, cciCap);
}
const clamped = Math.max(minBw, Math.min(maxBw, rawBw));
return Math.max(stepBw, Math.round(clamped / stepBw) * stepBw);
}
async function applyAutoBandwidth() {
if (!lastSpectrumData || lastFreqHz == null) return;
// WFM interference telemetry belongs to the primary DSP channel. Do not
// apply it to a virtual channel, where it would describe the wrong signal.
const onVirtual = typeof vchanIsOnVirtual === "function" && vchanIsOnVirtual();
const interference = onVirtual ? {} : { cci: lastWfmCci, aci: lastWfmAci };
const estimated = estimateOccupiedBandwidth(lastSpectrumData, lastFreqHz, interference);
const estimated = estimateOccupiedBandwidth(lastSpectrumData, lastFreqHz);
if (!Number.isFinite(estimated) || estimated <= 0) {
syncBandwidthInput(currentBandwidthHz);
return;
+8 -9
View File
@@ -6,9 +6,7 @@
#[cfg(feature = "ft2")]
use std::collections::HashMap;
use std::collections::HashSet;
#[cfg(test)]
use std::collections::VecDeque;
use std::collections::{HashSet, VecDeque};
use std::net::SocketAddr;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
@@ -35,9 +33,10 @@ use trx_core::audio::{
AUDIO_MSG_VCHAN_MODE, AUDIO_MSG_VCHAN_REMOVE, AUDIO_MSG_VCHAN_SUB, AUDIO_MSG_VCHAN_UNSUB,
AUDIO_MSG_VDES_DECODE, AUDIO_MSG_WEFAX_DECODE, AUDIO_MSG_WEFAX_PROGRESS, AUDIO_MSG_WSPR_DECODE,
};
#[cfg(test)]
use trx_core::decode::{AisMessage, AprsPacket, CwEvent};
use trx_core::decode::{DecodedMessage, Ft8Message, LrptImage, LrptProgress, WsprMessage};
use trx_core::decode::{
AisMessage, AprsPacket, CwEvent, DecodedMessage, Ft8Message, LrptImage, LrptProgress,
WsprMessage,
};
use trx_core::rig::state::{RigMode, RigState};
use trx_core::vchan::SharedVChanManager;
use trx_cw::CwDecoder;
@@ -47,9 +46,9 @@ use trx_wspr::WsprDecoder;
use uuid::Uuid;
use crate::config::AudioConfig;
use crate::history_policy::{current_timestamp_ms, lock_or_recover};
#[cfg(test)]
use crate::history_policy::{enforce_capacity, prune_by_age, MAX_HISTORY_ENTRIES};
use crate::history_policy::{
current_timestamp_ms, enforce_capacity, lock_or_recover, prune_by_age, MAX_HISTORY_ENTRIES,
};
use trx_decode_log::DecoderLoggers;
/// Silence timeout before auto-finalising an LRPT pass (30 s without new MCUs).