[fix](trx-rs): refine wfm denoise and favicon handling
Co-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Stan Grams <sjg@haxx.space>
This commit is contained in:
@@ -1431,7 +1431,7 @@ function render(update) {
|
||||
if (wfmDenoiseEl && (typeof update.filter.wfm_denoise === "string" || typeof update.filter.wfm_denoise === "boolean")) {
|
||||
const nextDenoise = typeof update.filter.wfm_denoise === "string"
|
||||
? normalizeWfmDenoiseLevel(update.filter.wfm_denoise)
|
||||
: (update.filter.wfm_denoise ? "auto" : "low");
|
||||
: (update.filter.wfm_denoise ? "auto" : "off");
|
||||
if (wfmDenoiseEl.value !== nextDenoise) {
|
||||
wfmDenoiseEl.value = nextDenoise;
|
||||
saveSetting("wfmDenoise", nextDenoise);
|
||||
@@ -2994,8 +2994,7 @@ function levelFromChannels(channels, frameCount) {
|
||||
|
||||
function normalizeWfmDenoiseLevel(value) {
|
||||
const next = String(value ?? "").toLowerCase();
|
||||
if (next === "auto" || next === "low" || next === "medium" || next === "high") return next;
|
||||
if (next === "off") return "low";
|
||||
if (next === "off" || next === "auto" || next === "low" || next === "medium" || next === "high") return next;
|
||||
return "auto";
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
|
||||
<title>trx-rs v{ver}</title>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="/favicon.png?v=4" />
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="/favicon.png?v=4" />
|
||||
<link rel="shortcut icon" href="/favicon.png?v=4" />
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/favicon.png?v=4" />
|
||||
<link rel="icon" type="image/png" sizes="any" href="/favicon.ico?v=5" />
|
||||
<link rel="shortcut icon" href="/favicon.ico?v=5" />
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/favicon.png?v=5" />
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fontsource/dseg14-classic/400.css" />
|
||||
<link rel="stylesheet" href="/style.css" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" />
|
||||
@@ -179,6 +178,7 @@
|
||||
<label class="wfm-control">
|
||||
<span class="wfm-control-label">Denoise Level</span>
|
||||
<select id="wfm-denoise" class="status-input">
|
||||
<option value="off">Off</option>
|
||||
<option value="auto">Auto</option>
|
||||
<option value="low">Low</option>
|
||||
<option value="medium">Medium</option>
|
||||
|
||||
@@ -944,9 +944,9 @@ async fn index() -> impl Responder {
|
||||
|
||||
#[get("/favicon.ico")]
|
||||
async fn favicon() -> impl Responder {
|
||||
HttpResponse::TemporaryRedirect()
|
||||
.insert_header((header::LOCATION, "/favicon.png?v=4"))
|
||||
.finish()
|
||||
HttpResponse::Ok()
|
||||
.insert_header((header::CONTENT_TYPE, "image/png"))
|
||||
.body(FAVICON_BYTES)
|
||||
}
|
||||
|
||||
#[get("/favicon.png")]
|
||||
|
||||
@@ -284,6 +284,7 @@ pub struct RigFilterState {
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum WfmDenoiseLevel {
|
||||
Off,
|
||||
Auto,
|
||||
Low,
|
||||
Medium,
|
||||
|
||||
@@ -417,8 +417,9 @@ impl StereoDenoise {
|
||||
1.0
|
||||
};
|
||||
let effective_gain = match self.level {
|
||||
WfmDenoiseLevel::Off => 1.0,
|
||||
WfmDenoiseLevel::Auto => {
|
||||
let strength = (0.3 + (1.0 - broadband_gain) * 0.7).clamp(0.3, 1.0);
|
||||
let strength = (0.45 + (1.0 - broadband_gain) * 0.55).clamp(0.45, 1.0);
|
||||
1.0 - (1.0 - broadband_gain) * strength
|
||||
}
|
||||
WfmDenoiseLevel::Low => 1.0 - (1.0 - broadband_gain) * 0.35,
|
||||
@@ -1063,6 +1064,22 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_denoise_off_is_bypass() {
|
||||
let mut off = StereoDenoise::new(48_000.0);
|
||||
off.level = WfmDenoiseLevel::Off;
|
||||
|
||||
for &(sum, diff_i, diff_q) in &[
|
||||
(0.1_f32, 0.5_f32, 0.2_f32),
|
||||
(0.0_f32, -0.3_f32, 0.8_f32),
|
||||
(1.0_f32, 1.0_f32, -0.5_f32),
|
||||
(-0.2_f32, 0.001_f32, 0.0_f32),
|
||||
] {
|
||||
let out = off.process(sum, diff_i, diff_q);
|
||||
assert!((out - diff_i).abs() < 0.000_001);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_denoise_per_band_selectivity() {
|
||||
use std::f32::consts::TAU;
|
||||
|
||||
Reference in New Issue
Block a user