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:
1 parent
ae9a20fdf8
commit
96640c5bff
5 files changed
+51
-16
No files matched your search
@@ -34,8 +34,8 @@ pi_writer.py → pi_image.py (cloud-init SD card, installs server.py as a system
|
|||||||
* **Audio test** – `App.audio_test` / `set_test_level` / `check_audio_test` in `server.py`: entering saves the output
|
* **Audio test** – `App.audio_test` / `set_test_level` / `check_audio_test` in `server.py`: entering saves the output
|
||||||
gains (`Device.test_saved`, persisted in `config.json` so an interrupted test is undone on the next connect),
|
gains (`Device.test_saved`, persisted in `config.json` so an interrupted test is undone on the next connect),
|
||||||
lowers every output to −50 dB, flushes the queue and only then starts the generator (`0x39`); leaving switches the
|
lowers every output to −50 dB, flushes the queue and only then starts the generator (`0x39`); leaving switches the
|
||||||
generator off first, then restores the gains. While `Device.test_active`, preset store/recall/import/export are
|
generator off first, then restores the gains. While `Device.test_active` the server only accepts the test
|
||||||
refused. The state field is `state["test"] = {source, freq}`.
|
controls (generator, test fader, output mutes) and the UI stays locked in the audio test tab. The state field is `state["test"] = {source, freq}`.
|
||||||
* **`dsp/preset.py`** – preset files (`dsp-control-preset` JSON with state + raw image), validation, and the minimal
|
* **`dsp/preset.py`** – preset files (`dsp-control-preset` JSON with state + raw image), validation, and the minimal
|
||||||
command sequence for an import. Undo backups go to `backups/` next to `config.json` (last 20 per device).
|
command sequence for an import. Undo backups go to `backups/` next to `config.json` (last 20 per device).
|
||||||
* **`dsp/usbhid.py`** – HID via ctypes only: Windows `hid.dll`/SetupAPI, macOS IOKit, Linux `/dev/hidraw*`.
|
* **`dsp/usbhid.py`** – HID via ctypes only: Windows `hid.dll`/SetupAPI, macOS IOKit, Linux `/dev/hidraw*`.
|
||||||
|
|||||||
@@ -523,7 +523,9 @@ class App:
|
|||||||
action = "/".join(g for g in m.groups()[1:] if g)
|
action = "/".join(g for g in m.groups()[1:] if g)
|
||||||
if dev.demo and (method in ("DELETE", "PUT") or action in ("unlock", "lockcode")):
|
if dev.demo and (method in ("DELETE", "PUT") or action in ("unlock", "lockcode")):
|
||||||
raise RuntimeError("Not available for the demo device")
|
raise RuntimeError("Not available for the demo device")
|
||||||
if dev.test_active and action in ("preset/recall", "preset/store", "export", "import", "undo"):
|
# during the audio test only the test controls work: generator, test fader, output mutes
|
||||||
|
if dev.test_active and (action in ("preset/recall", "preset/store", "export", "import", "undo", "link")
|
||||||
|
or action == "set" and body.get("param") != "mute"):
|
||||||
raise RuntimeError("Audio test is on – switch it off first")
|
raise RuntimeError("Audio test is on – switch it off first")
|
||||||
if self.demo["enabled"] and not dev.demo and action == "connect":
|
if self.demo["enabled"] and not dev.demo and action == "connect":
|
||||||
raise RuntimeError("Demo mode is on – switch it off to connect the real DSPs")
|
raise RuntimeError("Demo mode is on – switch it off to connect the real DSPs")
|
||||||
|
|||||||
+41
-12
@@ -522,8 +522,15 @@ function renderTabs() {
|
|||||||
h("span", { class: "dot " + d.status }), h("span", { class: "dn" }, d.name),
|
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);
|
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);
|
$("#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…"),
|
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));
|
const hh = hf(fAt(x));
|
||||||
if (phase) {
|
if (phase) {
|
||||||
const deg = cdeg(hh);
|
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;
|
last = deg;
|
||||||
segs[segs.length - 1].push([x, py(deg)]);
|
segs[segs.length - 1].push([x, py(deg)]);
|
||||||
} else segs[0].push([x, clamp(dy(cdb(hh)), 0, H)]);
|
} 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);
|
stroke(segs, "#38bdf8", 2);
|
||||||
const off = !!ch.peq_bypass;
|
const off = !!ch.peq_bypass;
|
||||||
ch.peq.forEach((b, i) => {
|
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.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 ? "#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.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";
|
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
|
if (off) { // master bypass: written across the curve
|
||||||
g.font = "bold 34px system-ui"; g.textAlign = "center"; g.textBaseline = "middle"; g.fillStyle = "#ef444499";
|
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";
|
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")),
|
return h("div", { class: "chips overlay" }, h("span", { class: "sub" }, t("Overlay")),
|
||||||
all.map(([k, i]) => {
|
all.map(([k, i]) => {
|
||||||
const key = `${k}${i}`, on = sel.has(key);
|
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),
|
const btn = h("button", { class: "chip ov" + (on ? " on" : ""), style: `--oc:${chColor(k, i)}`, "aria-pressed": String(on),
|
||||||
title: chTitle(d, k, i),
|
title: chTitle(d, k, i), "data-view-ok": "",
|
||||||
onclick: () => { on ? sel.delete(key) : sel.add(key); store.set(overlayKey(d), [...sel].join(",")); onChange(); } },
|
onclick: () => { // always from the stored set: the chip may be older than the last change
|
||||||
h("i", {}), chLabel(k, i));
|
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) {
|
function overlaysFor(d, kind, idx) {
|
||||||
@@ -969,7 +995,7 @@ function peqCard(d, kind, idx) {
|
|||||||
let best = -1, bd = 1600;
|
let best = -1, bd = 1600;
|
||||||
c.peq.forEach((b, i) => {
|
c.peq.forEach((b, i) => {
|
||||||
const dx = geo.fx(freqHz(b.freq)) - (e.clientX - r.left);
|
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 (dx * dx + dyy * dyy < bd) { bd = dx * dx + dyy * dyy; best = i; }
|
||||||
});
|
});
|
||||||
if (best < 0) return;
|
if (best < 0) return;
|
||||||
@@ -983,7 +1009,7 @@ function peqCard(d, kind, idx) {
|
|||||||
const x = clamp(e.clientX - r.left, 0, geo.W);
|
const x = clamp(e.clientX - r.left, 0, geo.W);
|
||||||
const f = hzFreq(20 * Math.pow(1000, x / 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 (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;
|
const db = (geo.H / 2 - (e.clientY - r.top)) / (geo.H / 2 - 10) * 15;
|
||||||
let g = clamp(Math.round(db * 10 + 120), 0, 240);
|
let g = clamp(Math.round(db * 10 + 120), 0, 240);
|
||||||
g = detent(g, 120, 300, geo.H - 20, 8);
|
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("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.")));
|
: t("Choose a test signal above to start.")));
|
||||||
return [
|
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),
|
h("div", { class: "cards testcards" }, signalCard, faderCard),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@@ -1757,6 +1784,7 @@ function render() {
|
|||||||
if (S.busy) { S.dirty = true; return; }
|
if (S.busy) { S.dirty = true; return; }
|
||||||
if ($("#app").hidden) return;
|
if ($("#app").hidden) return;
|
||||||
if (!S.devices[S.cur]) S.cur = S.order[0] || null;
|
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
|
// keep focus on a text field (e.g. while typing a device name) – re-rendering would steal it
|
||||||
const ae = document.activeElement;
|
const ae = document.activeElement;
|
||||||
if (ae && main.contains(ae) && ae.matches("input[type=text], input[type=number], input[type=password]")) { S.dirty = true; return; }
|
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));
|
}, 0));
|
||||||
|
|
||||||
document.querySelectorAll("#viewtabs button").forEach(b => b.addEventListener("click", () => {
|
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);
|
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)
|
// header / status bar heights -> CSS vars (sticky channel bar, fader height that fits the screen)
|
||||||
new ResizeObserver(() => {
|
new ResizeObserver(() => {
|
||||||
@@ -1876,7 +1905,7 @@ function connectEvents() {
|
|||||||
if (!S.devices[ev.device]) S.order.push(ev.device);
|
if (!S.devices[ev.device]) S.order.push(ev.device);
|
||||||
const was = testOn(S.devices[ev.device]);
|
const was = testOn(S.devices[ev.device]);
|
||||||
S.devices[ev.device] = ev.data;
|
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;
|
render(); break;
|
||||||
}
|
}
|
||||||
case "test": {
|
case "test": {
|
||||||
|
|||||||
@@ -343,6 +343,7 @@ const DE = {
|
|||||||
// curve
|
// curve
|
||||||
"Overlay": "Einblenden",
|
"Overlay": "Einblenden",
|
||||||
"Phase": "Phase",
|
"Phase": "Phase",
|
||||||
|
"The rest of the app is locked until the analog input is selected again.": "Der Rest der App ist gesperrt, bis wieder der Analog-Eingang gewählt ist.",
|
||||||
};
|
};
|
||||||
|
|
||||||
const DE_PATTERNS = [
|
const DE_PATTERNS = [
|
||||||
|
|||||||
+4
-1
@@ -481,7 +481,8 @@ input.code { width: 7.5em; text-align: center; font-family: ui-monospace, Menlo,
|
|||||||
.testbody { display: flex; gap: 18px; align-items: flex-start; min-width: 0; }
|
.testbody { display: flex; gap: 18px; align-items: flex-start; min-width: 0; }
|
||||||
.tf { display: flex; flex-direction: column; align-items: center; gap: 8px; }
|
.tf { display: flex; flex-direction: column; align-items: center; gap: 8px; }
|
||||||
.tf .fader { height: 300px; }
|
.tf .fader { height: 300px; }
|
||||||
.testval { white-space: nowrap; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
|
.testval { white-space: nowrap; width: 6.5em; text-align: center; font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; }
|
||||||
|
.tf { flex: none; width: 6.5em; }
|
||||||
.tmeters { display: flex; gap: 6px; overflow-x: auto; min-width: 0; padding-bottom: 4px; }
|
.tmeters { display: flex; gap: 6px; overflow-x: auto; min-width: 0; padding-bottom: 4px; }
|
||||||
.tmeter { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: none; }
|
.tmeter { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: none; }
|
||||||
.tmeter .led { height: 300px; }
|
.tmeter .led { height: 300px; }
|
||||||
@@ -506,3 +507,5 @@ button.chip.ov.on i { background: var(--oc); }
|
|||||||
.geq.bypassed > * { opacity: .35; }
|
.geq.bypassed > * { opacity: .35; }
|
||||||
.geq.bypassed::after { content: "BYPASS"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
|
.geq.bypassed::after { content: "BYPASS"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
|
||||||
font: 700 34px system-ui; color: #ef444499; pointer-events: none; }
|
font: 700 34px system-ui; color: #ef444499; pointer-events: none; }
|
||||||
|
body.testlock #viewtabs button:disabled, body.testlock #btn-settings:disabled, body.testlock .devtab:disabled { opacity: .35; cursor: not-allowed; }
|
||||||
|
.testbanner small { display: block; font-weight: 400; margin-top: 2px; color: var(--dim); }
|
||||||
Reference in new issue
Block a user