Fix overlay toggling, rework phase view, lock the app during the audio test

- overlay chips read the stored selection on every click (second click hides again)
- phase view: points keep their gain position and can be dragged in both
  directions, phase wraps are drawn as vertical lines like the original software,
  selected band shows Q / frequency / gain next to its point
- audio test: other tabs, settings and device switching are locked until the
  analog input is back; the server only accepts the test controls meanwhile
- test fader value has a fixed width and normal weight (meters no longer shift)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
GivouandClaude Opus 5.5 committed 2026-11-01 22:01:44 +01:00
1 parent ae9a20fdf8
commit 96640c5bff
5 files changed
+51 -16

No files matched your search

+41 -12
View File
@@ -522,8 +522,15 @@ function renderTabs() {
h("span", { class: "dot " + d.status }), h("span", { class: "dn" }, d.name),
testOn(d) ? h("small", { class: "test-badge" }, "TEST") : d.demo ? h("small", { class: "demo-badge" }, "DEMO") : model ? h("small", {}, model) : null);
}));
const testLock = testOn(dev());
document.body.classList.toggle("testlock", testLock);
$("#btn-settings").classList.toggle("on", S.settings);
document.querySelectorAll("#viewtabs button").forEach(b => b.classList.toggle("active", !S.settings && b.dataset.view === S.view));
$("#btn-settings").disabled = testLock;
document.querySelectorAll("#viewtabs button").forEach(b => {
b.classList.toggle("active", !S.settings && b.dataset.view === S.view);
b.disabled = testLock && b.dataset.view !== "test";
});
if (testLock) tabs.querySelectorAll(".devtab:not(.active)").forEach(b => (b.disabled = true));
}
const STATUS_TEXT = { disconnected: t("Disconnected"), connecting: t("Connecting…"), loading: t("Loading configuration…"),
@@ -870,7 +877,11 @@ function drawCurve(canvas, ch, selBand, opts = canvas.curveOpts ? canvas.curveOp
const hh = hf(fAt(x));
if (phase) {
const deg = cdeg(hh);
if (last !== null && Math.abs(deg - last) > 180) segs.push([]);
if (last !== null && Math.abs(deg - last) > 180) { // wrapped: run to the edge, continue from the other one
const down = deg > last; // falling phase passes −180° and comes back at +180°
segs[segs.length - 1].push([x, py(down ? -180 : 180)]);
segs.push([[x, py(-180)], [x, py(180)]], [[x, py(down ? 180 : -180)]]); // the jump itself, then on
}
last = deg;
segs[segs.length - 1].push([x, py(deg)]);
} else segs[0].push([x, clamp(dy(cdb(hh)), 0, H)]);
@@ -897,12 +908,21 @@ function drawCurve(canvas, ch, selBand, opts = canvas.curveOpts ? canvas.curveOp
stroke(segs, "#38bdf8", 2);
const off = !!ch.peq_bypass;
ch.peq.forEach((b, i) => {
const x = fx(freqHz(b.freq)), y = phase || !hasGain(b.type) ? dy(0) : dy(eqDb(b.gain));
const x = fx(freqHz(b.freq)), y = hasGain(b.type) ? dy(eqDb(b.gain)) : dy(0);
g.beginPath(); g.arc(x, y, i === selBand ? 10 : 7, 0, 2 * Math.PI);
g.fillStyle = b.bypass || off ? "#2a333d" : i === selBand ? "#f59e0b" : "#38bdf8cc"; g.fill();
g.fillStyle = b.bypass || off ? "#6b7682" : "#0b0c0f"; g.font = "bold 10px system-ui"; g.textAlign = "center"; g.textBaseline = "middle";
g.fillText(i + 1, x, y + 0.5); g.textAlign = "start"; g.textBaseline = "alphabetic";
});
if (sb && !off) { // values of the selected band next to its point, as in the original software
const x = fx(freqHz(sb.freq)), y = hasGain(sb.type) ? dy(eqDb(sb.gain)) : dy(0);
const lines = [hasQ(sb.type) ? `Q ${Q_TABLE[sb.q]}` : PEQ_TYPES[sb.type], fmtHz(freqHz(sb.freq)), hasGain(sb.type) ? `${sign(eqDb(sb.gain))} dB` : ""].filter(Boolean);
g.font = "11px system-ui"; g.fillStyle = "#fbbf24";
const right = x > W - 90, tx = right ? x - 14 : x + 14;
g.textAlign = right ? "end" : "start";
lines.forEach((l, i) => g.fillText(l, tx, clamp(y + 18 + i * 13, 12, H - 30 + i * 13)));
g.textAlign = "start";
}
if (off) { // master bypass: written across the curve
g.font = "bold 34px system-ui"; g.textAlign = "center"; g.textBaseline = "middle"; g.fillStyle = "#ef444499";
g.fillText("BYPASS", W / 2, H / 3); g.textAlign = "start"; g.textBaseline = "alphabetic";
@@ -920,10 +940,16 @@ function overlayChips(d, kind, idx, onChange) {
return h("div", { class: "chips overlay" }, h("span", { class: "sub" }, t("Overlay")),
all.map(([k, i]) => {
const key = `${k}${i}`, on = sel.has(key);
return h("button", { class: "chip ov" + (on ? " on" : ""), style: `--oc:${chColor(k, i)}`, "aria-pressed": String(on),
title: chTitle(d, k, i),
onclick: () => { on ? sel.delete(key) : sel.add(key); store.set(overlayKey(d), [...sel].join(",")); onChange(); } },
h("i", {}), chLabel(k, i));
const btn = h("button", { class: "chip ov" + (on ? " on" : ""), style: `--oc:${chColor(k, i)}`, "aria-pressed": String(on),
title: chTitle(d, k, i), "data-view-ok": "",
onclick: () => { // always from the stored set: the chip may be older than the last change
const cur = overlaySet(d), now = !cur.has(key);
now ? cur.add(key) : cur.delete(key);
store.set(overlayKey(d), [...cur].join(","));
btn.classList.toggle("on", now); btn.setAttribute("aria-pressed", String(now));
onChange();
} }, h("i", {}), chLabel(k, i));
return btn;
}));
}
function overlaysFor(d, kind, idx) {
@@ -969,7 +995,7 @@ function peqCard(d, kind, idx) {
let best = -1, bd = 1600;
c.peq.forEach((b, i) => {
const dx = geo.fx(freqHz(b.freq)) - (e.clientX - r.left);
const dyy = geo.dy(hasGain(b.type) && !geo.phase ? eqDb(b.gain) : 0) - (e.clientY - r.top);
const dyy = geo.dy(hasGain(b.type) ? eqDb(b.gain) : 0) - (e.clientY - r.top);
if (dx * dx + dyy * dyy < bd) { bd = dx * dx + dyy * dyy; best = i; }
});
if (best < 0) return;
@@ -983,7 +1009,7 @@ function peqCard(d, kind, idx) {
const x = clamp(e.clientX - r.left, 0, geo.W);
const f = hzFreq(20 * Math.pow(1000, x / geo.W));
if (f !== b.freq) setParam(kind, idx, `peq.${S.band}.freq`, f);
if (hasGain(b.type) && !geo.phase) { // the phase view only moves the frequency
if (hasGain(b.type)) {
const db = (geo.H / 2 - (e.clientY - r.top)) / (geo.H / 2 - 10) * 15;
let g = clamp(Math.round(db * 10 + 120), 0, 240);
g = detent(g, 120, 300, geo.H - 20, 8);
@@ -1554,7 +1580,8 @@ function viewTest(d) {
? t("Saving and recalling presets is blocked during the test. Stopping it switches the noise off first and then puts every fader back where it was.")
: t("Choose a test signal above to start.")));
return [
on ? h("div", { class: "testbanner" }, t("Audio test running – the DSP plays {signal} instead of its inputs.", { signal: TEST_SRC()[test.source][1] })) : null,
on ? h("div", { class: "testbanner" }, t("Audio test running – the DSP plays {signal} instead of its inputs.", { signal: TEST_SRC()[test.source][1] }),
h("small", {}, t("The rest of the app is locked until the analog input is selected again."))) : null,
h("div", { class: "cards testcards" }, signalCard, faderCard),
];
}
@@ -1757,6 +1784,7 @@ function render() {
if (S.busy) { S.dirty = true; return; }
if ($("#app").hidden) return;
if (!S.devices[S.cur]) S.cur = S.order[0] || null;
if (testOn(S.devices[S.cur])) { S.view = "test"; S.settings = false; } // stays in the audio test until the analog input is back
// keep focus on a text field (e.g. while typing a device name) – re-rendering would steal it
const ae = document.activeElement;
if (ae && main.contains(ae) && ae.matches("input[type=text], input[type=number], input[type=password]")) { S.dirty = true; return; }
@@ -1792,9 +1820,10 @@ main.addEventListener("focusout", () => setTimeout(() => {
}, 0));
document.querySelectorAll("#viewtabs button").forEach(b => b.addEventListener("click", () => {
if (testOn(dev()) && b.dataset.view !== "test") return;
S.view = b.dataset.view; S.settings = false; store.set("dsp.view", S.view); render(); window.scrollTo(0, 0);
}));
$("#btn-settings").addEventListener("click", () => { S.settings = !S.settings; render(); window.scrollTo(0, 0); });
$("#btn-settings").addEventListener("click", () => { if (testOn(dev())) return; S.settings = !S.settings; render(); window.scrollTo(0, 0); });
// header / status bar heights -> CSS vars (sticky channel bar, fader height that fits the screen)
new ResizeObserver(() => {
@@ -1876,7 +1905,7 @@ function connectEvents() {
if (!S.devices[ev.device]) S.order.push(ev.device);
const was = testOn(S.devices[ev.device]);
S.devices[ev.device] = ev.data;
if (!was && testOn(ev.data) && ev.device === S.cur && !S.settings) S.view = "test"; // e.g. DSP found playing noise
if (!was && testOn(ev.data) && ev.device === S.cur) { S.view = "test"; S.settings = false; } // e.g. DSP found playing noise
render(); break;
}
case "test": {