From f043e1a26159b6b92766ff11dbdb775d70d6fc8f Mon Sep 17 00:00:00 2001 From: Givou Date: Mon, 2 Nov 2026 18:23:35 +0100 Subject: [PATCH] Lock option: only show dashboard while locked; Sound Lab only in the desktop apps Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 4 ++-- README.md | 2 +- server.py | 18 ++++++++++++++++-- static/app.js | 27 ++++++++++++++++++++++++--- static/dashboard.js | 2 +- static/docs.js | 4 ++-- static/i18n.js | 6 ++++-- static/index.html | 2 +- static/rew.js | 5 ++--- static/style.css | 7 +++++-- 10 files changed, 58 insertions(+), 19 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index ba7cef9..cee3aed 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -17,7 +17,7 @@ pi_writer.py → pi_image.py (cloud-init SD card, installs server.py as a system backups. Config is one JSON file (`config.json`, gitignored) – `load()` / `apply_config()` / `save()`. * **Auth** – 4-digit PIN, PBKDF2 hash in `config.json`, session cookie `dspsess` (30 days), lockout after 5 failures. The desktop app logs in via `/app-login?t=`; app sessions live in memory only, skip the PIN and may - toggle remote access (`/api/remote`) and the lock (`/api/lock`, server answers 423 while locked). Remote clients + toggle remote access (`/api/remote`) and the lock (`/api/lock`, server answers 423 while locked; with `lock_dash` the window shows only the dashboard). Remote clients always need the PIN. * **`dsp/device.py`** – one `Device` per DSP: connect (TCP or `usbhid.open_stream`), handshake, config dump (50-byte chunks), command queue (one request in flight), meter polling (also keepalive), auto-reconnect. @@ -56,7 +56,7 @@ pi_writer.py → pi_image.py (cloud-init SD card, installs server.py as a system * **Read-only switch** (`S.guard`, `viewOnly()` in `app.js`) – web UI on phones and touch devices starts read-only, reusing the swallowing of the app lock. A safety catch per browser tab only: not stored, the server doesn't know it. Mute all stays. * **Sound Lab / REW** (`static/rew.js`, handbooks in `static/docs.js`, `rew_call` in `server.py`) – the server talks to REW's API on `127.0.0.1:4735`, which only answers on - REW's own computer; filter files work with the app on a Pi. Not offered on phones. Only checked against a fake server built from its OpenAPI spec. + REW's own computer; so Sound Lab is only in the desktop apps (`S.isApp`, the server refuses `/api/rew/` otherwise). Only checked against a fake server built from its OpenAPI spec. * **Network search** – `App.scan_network` probes the local /24 networks on TCP 9761 (handshake + device info), skipping DSPs this app is connected to. * **Copy settings / mute all** – `App.copy_settings` (`POST /api/copy`, groups level/filters/eq/dynamics/routing) and diff --git a/README.md b/README.md index b9275b9..ac9fd05 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Control both devices at the same time from your phone, tablet or computer – ov clickable EQ bands and overlays, channel, limiter, routing, delay, FIR, notes), move them by the title, resize them by the arrows, choose their DSP. It only looks and never changes a DSP; the layout is stored in the config * **Read-only switch** – on phones and tablets the web UI starts read-only; a small switch at the top allows changes -* **Sound Lab** – together with REW (Room EQ Wizard): take the filters of a measurement or a REW filter file onto a channel, +* **Sound Lab** (Windows and macOS apps) – together with REW (Room EQ Wizard): take the filters of a measurement or a REW filter file onto a channel, compare before applying, send a channel's curve or filters back to REW. Handbook with real cases here and in SoundField * **Mixer** – faders, mute and live meters for all inputs and outputs, limiter LED on every output (status read from the DSP) diff --git a/server.py b/server.py index 4bbbe9f..3a0c087 100644 --- a/server.py +++ b/server.py @@ -301,6 +301,7 @@ class App: self.remote_writers: set[asyncio.StreamWriter] = set() self.remote_error = "" self.locked = False # desktop app window read-only until unlocked with the PIN + self.lock_dash = False # while locked the app window shows nothing but the dashboard self.lang = "" # UI language chosen in the desktop app ("" = not chosen yet, English) # demo mode: the real DSPs are disconnected and a simulated one runs inside the server self.demo = {"enabled": False, "model": "408"} @@ -319,6 +320,7 @@ class App: now = time.time() self.sessions = {k: v for k, v in cfg.get("sessions", {}).items() if v > now} self.locked = bool(cfg.get("locked")) + self.lock_dash = bool(cfg.get("lock_dash")) self.lang = cfg.get("lang") if cfg.get("lang") in ("en", "de") else "" m = cfg.get("mute_all") or {} self.mute_all = {"active": bool(m.get("active")), "restore": { @@ -411,7 +413,7 @@ class App: def save(self): sessions = {k: v for k, v in self.sessions.items() if k not in self.app_sessions} cfg = {"devices": [d.config() for d in self.real_devices()], "auth": self.auth, - "sessions": sessions, "limiter": self.limiter, "remote": self.remote, "locked": self.locked, + "sessions": sessions, "limiter": self.limiter, "remote": self.remote, "locked": self.locked, "lock_dash": self.lock_dash, "soundfield": self.soundfield, "logo": self.logo, "dashboard": self.dashboard, "mute_all": {"active": self.mute_all["active"], "restore": {k: v for k, v in self.mute_all["restore"].items() if k != "demo"}}} @@ -1105,7 +1107,7 @@ class App: is_app = session in self.app_sessions if path == "/api/auth": await self.respond_json(writer, 200, {"authenticated": bool(session), "app": is_app, - "locked": is_app and self.locked, + "locked": is_app and self.locked, "lock_dash": is_app and self.lock_dash, "lang": self.lang if is_app else ""}) return if path == "/api/login" and method == "POST": @@ -1130,6 +1132,18 @@ class App: self.save() await self.respond_json(writer, 200, {"lang": self.lang}) return + if path.startswith("/api/rew/") and not is_app: # REW runs next to the desktop app + await self.respond_json(writer, 403, {"error": "desktop app only"}) + return + if path == "/api/lock-dash" and method == "POST": + if not is_app: + await self.respond_json(writer, 403, {"error": "desktop app only"}) + else: + self.lock_dash = bool(data.get("enabled")) + self.save() + self.broadcast({"type": "lockdash", "enabled": self.lock_dash}) + await self.respond_json(writer, 200, {"enabled": self.lock_dash}) + return if path in ("/api/lock", "/api/unlock") and method == "POST": if not is_app: await self.respond_json(writer, 403, {"error": "desktop app only"}) diff --git a/static/app.js b/static/app.js index b2fc618..5168327 100644 --- a/static/app.js +++ b/static/app.js @@ -626,6 +626,7 @@ function renderTabs() { $("#btn-settings").disabled = testLock; document.querySelectorAll("#viewtabs button").forEach(b => { if (b.dataset.view === "fir") b.hidden = !(dev() && dev().fir); + if (b.dataset.view === "lab") b.hidden = !S.isApp; b.classList.toggle("active", !S.settings && b.dataset.view === S.view); b.disabled = testLock && b.dataset.view !== "test"; }); @@ -1359,7 +1360,7 @@ function peqCard(d, kind, idx) { const card = h("div", { class: "card wide" + (ch.peq_bypass ? " eq-off" : "") }, h("h3", {}, h("span", { class: "grow" }, t("Parametric EQ")), modeSeg, d.fir ? null : toggleBtn("EQ Bypass", kind, idx, "peq_bypass", "small bypass", v => { card.classList.toggle("eq-off", v); renderBand(); redraw(); }), - h("button", { class: "small rewbtn", "data-view-ok": "", title: t("Open this channel in Sound Lab (REW)"), onclick: () => openLab(kind, idx) }, "REW"), + S.isApp ? h("button", { class: "small", "data-view-ok": "", title: t("Open this channel in Sound Lab (REW)"), onclick: () => openLab(kind, idx) }, "REW") : null, h("button", { class: "small", onclick: async () => { if (!await askConfirm(t("Reset EQ"), t("Set all PEQ bands of this channel to 0 dB and clear bypass?"), t("All flat"))) return; chans(dev(), kind)[idx].peq.forEach((bb, i) => { @@ -2232,6 +2233,16 @@ function backupCard() { } // Desktop app only: let phones/tablets on the LAN use this PC as server (they need the PIN) +function lockOptionCard() { + const box = h("input", { type: "checkbox", checked: !!S.lockDash, onchange: async () => { + try { S.lockDash = (await api("POST", "/api/lock-dash", { enabled: box.checked })).enabled; } + catch (e) { box.checked = !!S.lockDash; toast(t("Error: ") + trMsg(e.message)); } + } }); + return h("div", { class: "card" }, h("h3", {}, t("Lock")), + h("label", { class: "chk" }, box, t("Only show dashboard while locked")), + h("p", { class: "info" }, t("With the lock on, this window then shows just your dashboard, until it is unlocked with the PIN."))); +} + function remoteCard() { const r = S.remote || { enabled: false, port: 8080, urls: [] }; const port = h("input", { type: "number", min: 1, max: 65535, value: r.port, class: "short", "aria-label": "Port" }); @@ -2397,7 +2408,7 @@ function viewSettings() { ["devices", t("Devices"), t("Several DSPs can be connected at the same time – pick one at the top. A DSP accepts only one connection: close the Thomann editor first."), "wide", [...S.order.filter(id => !S.devices[id].demo).map(id => deviceForm(S.devices[id])), scanCard(), addDeviceCard()]], ["access", S.isApp ? t("Remote access") : t("Security"), S.isApp ? t("Let phones and tablets in your network control this computer – they log in with the PIN.") : t("Who may use this web interface."), - "wide", [S.isApp ? remoteCard() : null, pinCard()]], + "wide", [S.isApp ? remoteCard() : null, S.isApp ? lockOptionCard() : null, pinCard()]], ["backup", t("Backup"), t("Save and restore the settings of this app."), "wide", [backupCard()]], ]; const nav = h("nav", { class: "setnav", "aria-label": t("Settings") }, sections.map(([id, title]) => @@ -2429,6 +2440,11 @@ function render() { if (S.busy) { S.dirty = true; return; } if ($("#app").hidden) return; if (!S.devices[S.cur]) S.cur = S.order[0] || null; + // locked with "only show dashboard": back to where it was after unlocking + if (dashOnly() && !testOn(S.devices[S.cur])) { + if (S.view !== "dash" || S.settings) { S.beforeLock = S.beforeLock || { view: S.view, settings: S.settings }; S.view = "dash"; S.settings = false; } + } else if (S.beforeLock) { S.view = S.beforeLock.view; S.settings = S.beforeLock.settings; S.beforeLock = null; } + document.body.classList.toggle("dashonly", dashOnly() && !testOn(S.devices[S.cur])); 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; @@ -2457,7 +2473,7 @@ function render() { : d.status === "locked" ? h("div", {}, h("p", {}, t("This DSP is locked with a code.")), h("button", { class: "on", onclick: () => unlockDialog(d) }, t("Enter code"))) : S.demo.enabled && !d.demo ? t("Disconnected while demo mode is on") : t("Not connected.")); - else content = ({ mixer: viewMixer, channel: viewChannel, routing: viewRouting, link: viewLink, fir: d.fir ? viewFir : viewMixer, lab: window.innerWidth < 760 ? viewMixer : viewLab, limiter: viewLimiter, test: viewTest }[S.view] || viewMixer)(d); + else content = ({ mixer: viewMixer, channel: viewChannel, routing: viewRouting, link: viewLink, fir: d.fir ? viewFir : viewMixer, lab: S.isApp ? viewLab : viewMixer, limiter: viewLimiter, test: viewTest }[S.view] || viewMixer)(d); main.replaceChildren(...[content].flat().filter(Boolean)); main.querySelectorAll(H_SCROLL).forEach((e, i) => { if (xs[i]) e.scrollLeft = xs[i]; }); window.scrollTo(0, y); @@ -2501,6 +2517,7 @@ new ResizeObserver(() => document.documentElement.style.setProperty("--sb", $("# // Phones and tablets on the web UI start read-only, so nothing changes by touching it by accident. // Only a safety catch in this browser tab: it is not stored and the server knows nothing about it. const viewOnly = () => !!S.locked || !!S.guard; +const dashOnly = () => !!S.locked && !!S.lockDash; function showGuard() { const b = $("#btn-guard"), used = !S.isApp && S.guardUsed; b.hidden = !used; @@ -2640,6 +2657,9 @@ function connectEvents() { case "lock": if (S.isApp) { S.locked = ev.locked; showLock(); render(); } break; + case "lockdash": + if (S.isApp) { S.lockDash = ev.enabled; render(); } + break; case "meters": updateMeters(ev); break; case "limiter": @@ -2729,6 +2749,7 @@ async function startApp() { if (store.get("dsp.lang") === a.lang) return location.reload(); } S.locked = !!a.locked; + S.lockDash = !!a.lock_dash; S.guardUsed = !S.isApp && matchMedia("(max-width: 759px), (pointer: coarse)").matches; S.guard = S.guardUsed; showGuard(); diff --git a/static/dashboard.js b/static/dashboard.js index cef05fc..898cc2b 100644 --- a/static/dashboard.js +++ b/static/dashboard.js @@ -91,7 +91,7 @@ const DASH_MODULES = { const list = dashDevs(); if (!list.length) return offline(); return h("div", { class: "dlist" }, list.map(d => h("button", { class: "drow dlink", "data-view-ok": "", title: t("Open in the mixer"), - onclick: () => { S.cur = d.id; S.view = "mixer"; store.set("dsp.view", "mixer"); render(); window.scrollTo(0, 0); } }, + onclick: () => { if (dashOnly()) return; S.cur = d.id; S.view = "mixer"; store.set("dsp.view", "mixer"); render(); window.scrollTo(0, 0); } }, h("span", { class: "dot " + d.status }), h("span", { class: "grow dname" }, h("b", {}, d.name), h("small", {}, [MODEL_LABEL[d.detected_model || d.model] || "", d.state ? d.state.preset_name : (STATUS_TEXT[d.status] || d.status)].filter(Boolean).join(" · "))), d.state && dashChannels(d).some(([k, i]) => chans(d, k)[i].mute) ? h("span", { class: "dtag mute" }, "MUTE") : null))); diff --git a/static/docs.js b/static/docs.js index 5967999..b8fd044 100644 --- a/static/docs.js +++ b/static/docs.js @@ -10,7 +10,7 @@ const DOC_LAB = () => ({ t("Install REW on the computer running this app and connect a measuring microphone."), t("In REW: Preferences → API → start the API, and tick that it starts with REW."), t("Open Sound Lab and press “Check”. The dot turns green and shows the REW version."), - ], p: t("REW's API only answers on its own computer. With the app on a Raspberry Pi, use the filter file instead.") }, + ], p: t("REW's API only answers on its own computer, so Sound Lab is part of the Windows and macOS apps only.") }, { h: t("Example: correcting a top in a hall"), steps: [ t("Export a preset first (File… → Export), so you can go back."), t("Mute everything except the speaker you are measuring and set a low level. Put the microphone at ear height in the audience area."), @@ -29,7 +29,7 @@ const DOC_LAB = () => ({ t("In REW's EQ window change the filters and watch the predicted result. Nothing changes on the DSP."), t("If you like it, press “Take filters” in Sound Lab, check and apply."), ] }, - { h: t("Without a connection (app on a Raspberry Pi)"), steps: [ + { h: t("Without the API"), steps: [ t("In REW's EQ window: File → Export → Filter settings as text."), t("In Sound Lab press “Load REW filter file…”, check and apply."), ] }, diff --git a/static/i18n.js b/static/i18n.js index eac02d8..5e92b73 100644 --- a/static/i18n.js +++ b/static/i18n.js @@ -630,7 +630,7 @@ const DE = { "Install REW on the computer running this app and connect a measuring microphone.": "REW auf dem Computer installieren, auf dem diese App läuft, und ein Messmikrofon anschließen.", "In REW: Preferences → API → start the API, and tick that it starts with REW.": "In REW: Preferences → API → die API starten und anhaken, dass sie mit REW startet.", "Open Sound Lab and press “Check”. The dot turns green and shows the REW version.": "Das Sound Lab öffnen und „Prüfen“ drücken. Der Punkt wird grün und zeigt die REW-Version.", - "REW's API only answers on its own computer. With the app on a Raspberry Pi, use the filter file instead.": "Die API von REW antwortet nur auf dem eigenen Computer. Mit der App auf einem Raspberry Pi nimmst du stattdessen die Filterdatei.", + "REW's API only answers on its own computer, so Sound Lab is part of the Windows and macOS apps only.": "Die API von REW antwortet nur auf dem eigenen Computer, darum gibt es das Sound Lab nur in den Apps für Windows und macOS.", "Example: correcting a top in a hall": "Beispiel: ein Top in einer Halle korrigieren", "Export a preset first (File… → Export), so you can go back.": "Zuerst ein Preset exportieren (Datei… → Export), damit du zurück kannst.", "Mute everything except the speaker you are measuring and set a low level. Put the microphone at ear height in the audience area.": "Alles außer dem gemessenen Lautsprecher stummschalten und einen niedrigen Pegel einstellen. Das Mikrofon auf Ohrhöhe in den Publikumsbereich stellen.", @@ -647,7 +647,7 @@ const DE = { "Choose a measurement and press “Send filters to the chosen measurement”. This replaces the filters of that measurement in REW.": "Eine Messung wählen und „Filter an die gewählte Messung senden“ drücken. Das ersetzt die Filter dieser Messung in REW.", "In REW's EQ window change the filters and watch the predicted result. Nothing changes on the DSP.": "Im EQ-Fenster von REW die Filter ändern und die Vorhersage beobachten. Am DSP ändert sich dabei nichts.", "If you like it, press “Take filters” in Sound Lab, check and apply.": "Wenn es passt, im Sound Lab „Filter holen“ drücken, prüfen und übernehmen.", - "Without a connection (app on a Raspberry Pi)": "Ohne Verbindung (App auf einem Raspberry Pi)", + "Without the API": "Ohne die API", "In REW's EQ window: File → Export → Filter settings as text.": "Im EQ-Fenster von REW: File → Export → Filter settings as text.", "In Sound Lab press “Load REW filter file…”, check and apply.": "Im Sound Lab „REW-Filterdatei laden…“ drücken, prüfen und übernehmen.", "SoundField is a top view of the room for planning before you set up: where speakers go, how evenly the room is covered, and which delays they need. It calculates a free field without reflections, so it is a planning aid, not a measurement.": "SoundField ist eine Draufsicht auf den Raum zum Planen vor dem Aufbau: wo die Lautsprecher hinkommen, wie gleichmäßig der Raum abgedeckt ist und welche Delays sie brauchen. Es rechnet im Freifeld ohne Reflexionen, ist also eine Planungshilfe und keine Messung.", @@ -672,6 +672,8 @@ const DE = { "Select a speaker and tick which DSP outputs feed it.": "Einen Lautsprecher wählen und anhaken, welche DSP-Ausgänge ihn speisen.", "In the “Delays” table press “Apply” for one speaker, or “Apply all”. The column “Now on DSP” shows what is set.": "In der Tabelle „Delays“ für einen Lautsprecher „Übernehmen“ drücken, oder „Alle übernehmen“. Die Spalte „Jetzt im DSP“ zeigt, was gesetzt ist.", "Check the result by ear or with a measurement: temperature, reflections and real speakers differ from the model.": "Das Ergebnis mit dem Ohr oder per Messung prüfen: Temperatur, Reflexionen und echte Lautsprecher weichen vom Modell ab.", + "Only show dashboard while locked": "Während der Sperre nur das Dashboard zeigen", + "With the lock on, this window then shows just your dashboard, until it is unlocked with the PIN.": "Bei aktiver Sperre zeigt dieses Fenster dann nur dein Dashboard, bis es mit der PIN entsperrt wird.", }; const DE_PATTERNS = [ diff --git a/static/index.html b/static/index.html index 07e79da..a5fa999 100644 --- a/static/index.html +++ b/static/index.html @@ -42,7 +42,7 @@ - + diff --git a/static/rew.js b/static/rew.js index d0b5ea4..b27cf2e 100644 --- a/static/rew.js +++ b/static/rew.js @@ -1,9 +1,8 @@ "use strict"; // Sound Lab: working together with REW (Room EQ Wizard). Take filters from a measurement or a filter file, compare them -// with the channel before applying, send a channel's EQ back. REW's API only answers on the computer it runs on, so the -// server of this app talks to it (see rew_call); a filter file also works with the app on a Raspberry Pi. -// Not offered on phones (style.css). +// with the channel before applying, send a channel's EQ back. Desktop apps only: REW's API only answers on the computer +// it runs on, so the server inside the app talks to it (see rew_call). const REW_IN = { PK: 0, PEAK: 0, LS: 1, LSC: 1, LSQ: 1, HS: 2, HSC: 2, HSQ: 2, HP1: 3, HP: 4, HPQ: 4, LP1: 5, LP: 6, LPQ: 6, AP: 8 }; const REW_OUT = ["PK", "LS", "HS", "HP1", "HP", "LP1", "LP", "AP", "AP"]; diff --git a/static/style.css b/static/style.css index 061da42..2b4aba6 100644 --- a/static/style.css +++ b/static/style.css @@ -939,5 +939,8 @@ canvas.labcurve { display: block; width: 100%; height: 240px; background: var(-- .docbody p { margin: 5px 0 0; color: var(--dim); } .docbody ol { margin: 0; padding-left: 20px; } .docbody li { margin: 3px 0; } -/* Sound Lab is for the computer next to REW, not for phones */ -@media (max-width: 759px) { #viewtabs button[data-view=lab], .rewbtn { display: none; } } +/* ---- locked with "only show dashboard" */ +body.dashonly #viewtabs, body.dashonly #devtabs, body.dashonly #btn-settings, body.dashonly #statusbar { display: none; } +body.dashonly #main { margin-left: 0; } +body.dashonly #btn-muteall { margin-left: auto; } +body.dashonly .dlink { cursor: default; }