diff --git a/CLAUDE.md b/CLAUDE.md index ad3b38f..b5c265f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -110,9 +110,9 @@ and the DSP's own mirroring inside groups, limiter-active bit mask, preset impor Not verified yet – ask for a log (`python server.py -v`) from real hardware before changing protocol code here: * **Beta models** `206` and `408fir` – never seen on real hardware, same protocol and memory layout are only assumed - (also the USB ID). Never auto-detected (`detect_model`, a FIR device must not pass as a 408). `Device.read_only` holds - back every write (`P.READ_COMMANDS`, `BETA_READ_ACTIONS`) until the user allows changes (`beta_write`). The FIR - filters are deliberately not implemented; ask testers for a preset export (it holds the raw image) and a log first. + (also the USB ID). Never auto-detected (`detect_model`, a FIR device must not pass as a 408); the only hint is the + note in the add-device form, afterwards they work like the others. The FIR filters are deliberately not implemented; + ask testers for a preset export (it holds the raw image) and a log first. * **DSP 408 on real hardware** (layout and frames match published captures, limiter bits for Out 5–8 assumed) * USB on Windows and Linux against a real DSP (only tested against a fake HID device) * Where the PEQ bypass flag lives in the memory image; format of the set-command acknowledgement; where the number diff --git a/README.md b/README.md index f3d61e9..c61956a 100644 --- a/README.md +++ b/README.md @@ -80,9 +80,8 @@ Control both devices at the same time from your phone, tablet or computer – ov | t.racks DSP 206 (beta) | ✓ | ? | no – assumed to work like the others, testers wanted | | t.racks FIR DSP 408 (beta) | ✓ | ? | no – as above; the FIR filters themselves are not supported | -Beta models are not detected automatically: choose them by hand when adding the device. They start read-only. Compare -the shown values with the DSP; if they match, switch on changes in the note above the mixer (amplifiers off while -testing). If they don't match, please send the file from File… → Export. +Beta models are not detected automatically: choose them by hand when adding the device (amplifiers off for the first +test). If the shown values don't match the DSP, please send the file from File… → Export. The DSPs accept only **one** connection at a time – close any other control software first. diff --git a/dsp/device.py b/dsp/device.py index 22665c1..9860602 100644 --- a/dsp/device.py +++ b/dsp/device.py @@ -22,14 +22,12 @@ class Device: def __init__(self, dev_id: str, name: str, host: str, port: int = P.PORT, model: str = "auto", addr: int = 1, autoconnect: bool = True, on_event=None, transport: str = "tcp", usb: str = "", lock_code: str = "", auto_unlock: bool = False, test_saved: list | None = None, - colors: dict | None = None, maxgain: dict | None = None, linknames: dict | None = None, - beta_write: bool = False): + colors: dict | None = None, maxgain: dict | None = None, linknames: dict | None = None): self.id = dev_id self.name = name self.host = host self.port = port self.model_key = model # "auto" or a key of P.MODELS - self.beta_write = beta_write # beta models: the user has checked the shown values and allowed changes self.addr = addr self.autoconnect = autoconnect self.transport = "usb" if transport == "usb" else "tcp" @@ -77,8 +75,7 @@ class Device: "model": self.model_key, "addr": self.addr, "autoconnect": self.autoconnect, "transport": self.transport, "usb": self.usb, "lock_code": self.lock_code, "auto_unlock": self.auto_unlock, "test_saved": self.test_saved, - "colors": self.colors, "maxgain": self.maxgain, "linknames": self.linknames, - "beta_write": self.beta_write} + "colors": self.colors, "maxgain": self.maxgain, "linknames": self.linknames} def snapshot(self) -> dict: cfg = self.config() @@ -88,7 +85,6 @@ class Device: "detected_model": self.model_name or None, "n_in": self.model.n_in if self.model else 0, "n_out": self.model.n_out if self.model else 0, - "beta": bool(self.model and self.model.beta), "read_only": self.read_only, "presets": self.presets, "state": self.state} def start(self): @@ -108,17 +104,10 @@ class Device: await self._close() self._set_status("disconnected") - @property - def read_only(self) -> bool: - """A beta model only reads until the user has compared the shown values with the DSP.""" - return bool(self.model and self.model.beta and not self.beta_write) - def set_param(self, kind: str, idx: int, param: str, value): """Update local state and queue the command (coalesced per parameter).""" if not self.state or not self.model: raise RuntimeError("device not loaded") - if self.read_only: - raise RuntimeError("Beta model: changes are off") chans = self.state["inputs" if kind == "in" else "outputs"] ch = chans[idx] if param == "name": @@ -343,9 +332,6 @@ class Device: """Send one command and wait for its answer (the DSP is strictly request/response).""" if not self._writer: raise ConnectionError("not connected") - if self.read_only and cmd not in P.READ_COMMANDS: - log.warning("%s: read-only, command 0x%02x not sent", self.name, cmd) - return None async with self._lock: deadline = time.monotonic() + timeout self._writer.write(P.build_frame(cmd, payload, self.addr)) diff --git a/dsp/protocol.py b/dsp/protocol.py index d585609..fb9289b 100644 --- a/dsp/protocol.py +++ b/dsp/protocol.py @@ -251,10 +251,6 @@ class Model: MODELS = {"204": Model("DSP 204", 2, 4), "408": Model("DSP 408", 4, 8), "206": Model("DSP 206", 2, 6, beta=True), "408fir": Model("FIR DSP 408", 4, 8, beta=True)} -# what a DSP may be sent while its model is read-only (see Device.read_only): connecting and looking -READ_COMMANDS = frozenset((CMD_HANDSHAKE, CMD_LOGOUT, CMD_STATUS, CMD_DEVICE_INFO, CMD_INIT_14, CMD_INIT_22, - CMD_CONFIG_REQUEST, CMD_PRESET_NAME, CMD_PRESET_COUNT, CMD_UNLOCK, CMD_METER)) - def detect_model(info: str) -> str | None: """Beta models are never detected, and a FIR device must not pass as a plain DSP 408.""" diff --git a/server.py b/server.py index 08b3ed5..ff4ab47 100644 --- a/server.py +++ b/server.py @@ -154,11 +154,6 @@ def clean_colors(v) -> dict: return out -# what a beta model allows before changes are switched on: nothing here writes to the DSP -BETA_READ_ACTIONS = ("connect", "disconnect", "refresh", "export", "backups", "unlock", "colors", "maxgain", - "linknames", "betawrite") - - def clean_linknames(v) -> dict: """Names of link groups, keyed by kind and members: {"out:0,1": "Tops"}. A changed group loses its name.""" out = {} @@ -342,8 +337,7 @@ class App: transport="usb" if usb else "tcp", usb=str(d.get("usb") or ""), lock_code=str(d.get("lock_code") or ""), auto_unlock=bool(d.get("auto_unlock")), test_saved=clean_gains(d.get("test_saved")), colors=clean_colors(d.get("colors")), - maxgain=clean_maxgain(d.get("maxgain")), linknames=clean_linknames(d.get("linknames")), - beta_write=bool(d.get("beta_write"))) + maxgain=clean_maxgain(d.get("maxgain")), linknames=clean_linknames(d.get("linknames"))) dev.on_online = self.device_online self.devices[dev_id] = dev if dev.autoconnect: @@ -391,8 +385,6 @@ class App: return {"ok": True} async def device_online(self, dev: Device): - if dev.read_only: - return await self.check_audio_test(dev) if not self.mute_all["active"] and self.mute_all["restore"].get(dev.id): self.unmute_device(dev) # released while this DSP was offline @@ -411,7 +403,7 @@ class App: def set_mute_all(self, mute: bool) -> dict: """Mute every channel of every connected DSP; releasing unmutes only what was open before.""" - online = [d for d in self.devices.values() if d.status == "online" and d.state and not d.read_only] + online = [d for d in self.devices.values() if d.status == "online" and d.state] if mute and not self.mute_all["active"]: self.mute_all["restore"] = {} for dev in online: @@ -443,7 +435,7 @@ class App: changed = 0 for t in body.get("targets") or []: dev = self.devices.get(str(t.get("device"))) - if not dev or dev.status != "online" or not dev.state or dev.read_only: + if not dev or dev.status != "online" or not dev.state: continue if dev.test_active: raise RuntimeError("Audio test is on – switch it off first") @@ -802,8 +794,6 @@ class App: 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") - if dev.read_only and method == "POST" and action not in BETA_READ_ACTIONS: - raise RuntimeError("Beta model: changes are off") 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") if method == "DELETE" and not action: @@ -815,8 +805,6 @@ class App: if method == "PUT" and not action: was_running = dev._want_connected await dev.stop() - if body.get("model", dev.model_key) != dev.model_key: - dev.beta_write = False # another model: check the values again for k in ("name", "host", "model", "usb"): if k in body: setattr(dev, "model_key" if k == "model" else k, str(body[k])) @@ -884,11 +872,6 @@ class App: self.save() self.broadcast({"type": "device", "device": dev.id, "data": dev.snapshot()}) return {"ok": True, "colors": dev.colors} - if action == "betawrite": # beta model: the user compared the shown values with the DSP - dev.beta_write = bool(body.get("enabled")) - self.save() - self.broadcast({"type": "device", "device": dev.id, "data": dev.snapshot()}) - return {"ok": True, "read_only": dev.read_only} if action == "linknames": # display only, like the colours dev.linknames = clean_linknames(body.get("linknames")) self.save() diff --git a/static/app.js b/static/app.js index f26a985..a91849c 100644 --- a/static/app.js +++ b/static/app.js @@ -139,6 +139,7 @@ const chTitle = (d, kind, i) => { const n = chans(d, kind)[i].name; return n ? ` // group holds all members' bits, the others 0. The DSP mirrors changes within a group itself. const MODEL_LABEL = { "204": "DSP 204", "408": "DSP 408", "206": "DSP 206", "408fir": "FIR DSP 408" }; const MODEL_CH = { "204": [2, 4], "408": [4, 8], "206": [2, 6], "408fir": [4, 8] }; // inputs, outputs (before a DSP has connected) +const BETA_MODELS = ["206", "408fir"]; const LINK_COLORS = ["#f59e0b", "#22d3ee", "#a3e635", "#f472b6"]; function linkGroups(list) { const seen = new Set(), groups = []; @@ -595,7 +596,7 @@ function renderTabs() { const badge = d => { const model = d.detected_model || (d.model !== "auto" ? d.model : ""); return testOn(d) ? h("small", { class: "test-badge" }, "TEST") : d.demo ? h("small", { class: "demo-badge" }, "DEMO") - : model ? h("small", {}, (MODEL_LABEL[model] || model).replace("DSP ", "") + (d.beta ? " β" : "")) : null; + : model ? h("small", {}, (MODEL_LABEL[model] || model).replace("DSP ", "")) : null; }; const cur = S.devices[S.cur]; if (!cur) { @@ -799,8 +800,8 @@ async function presetFileDialog(d) { "active state – stored presets (U01 …) stay unchanged.", { name: q(d.state.preset_name || "—") })), last ? h("p", { class: "dlg-text" }, t("A backup is made automatically before every import. Last backup: {last}.", { last })) : null), actions: [{ label: t("Close") }, - ...(last && !viewOnly() ? [{ label: t("Undo import"), value: () => "undo" }] : []), - ...(viewOnly() ? [] : [{ label: t("Import…"), value: () => "import" }]), + ...(last && !S.locked ? [{ label: t("Undo import"), value: () => "undo" }] : []), + ...(S.locked ? [] : [{ label: t("Import…"), value: () => "import" }]), { label: t("Export"), primary: true, value: () => "export" }], }); try { @@ -1955,6 +1956,10 @@ function deviceForm(d) { addr: h("input", { type: "number", min: 1, max: 250, value: d.addr || 1, class: "short" }), usb: h("select", { "aria-label": t("USB device") }), }; + const betaNote = h("p", { class: "info betanote full", hidden: true }, + t("Beta: this model has not been tested on a real device yet. Keep the amplifiers off for the first test.")); + const showBeta = () => { betaNote.hidden = !isNew || !f.model.value || !BETA_MODELS.includes(f.model.value); }; + f.model.addEventListener("change", showBeta); let transport = d.transport || "tcp"; // USB device list (both DSP models share one USB ID, so several are told apart by port/path) const fillUsb = list => { @@ -2017,6 +2022,7 @@ function deviceForm(d) { ...netRows, usbRow, h("label", {}, t("Model"), f.model), h("label", { class: "chk" }, f.autoconnect, t("Connect automatically")), + betaNote, h("details", { class: "more full" }, h("summary", {}, t("Advanced")), h("label", { class: "inline idrow" }, t("Device ID"), f.addr), h("p", { class: "info" }, t("Only needed if the ID was changed on the DSP (e.g. several DSPs on one RS-485 cable). Default 1."))), @@ -2236,21 +2242,6 @@ function viewSettings() { // ------------------------------------------------------------------ render const H_SCROLL = ".mixer, .bands, .geq, .routing"; -// beta models (never seen on a real device): read-only until the shown values were compared with the DSP -function betaBanner(d) { - const model = MODEL_LABEL[d.detected_model] || d.detected_model; - const set = async enabled => { - if (enabled && !await askConfirm(t("Allow changes"), t("Only continue if the values shown here match the DSP (names, gains, filters, routing). If they don't, a change can send wrong values – keep the amplifiers off while testing."), t("Allow changes"), true)) return; - try { await api("POST", `/api/devices/${d.id}/betawrite`, { enabled }); } - catch (e) { toast(t("Error: ") + trMsg(e.message)); } - }; - return h("div", { class: "betabar" + (d.read_only ? " ro" : "") }, - h("div", { class: "grow" }, h("b", {}, t("{model} – Beta", { model })), " ", - d.read_only ? t("Not tested on a real device yet, so changes are off. Compare the shown values with the DSP. If they don't match, send the file from File… → Export to the developer.") - : t("Not tested on a real device yet. Changes are on – keep the amplifiers off while testing.")), - h("button", { class: "small" + (d.read_only ? " on" : ""), "data-view-ok": "", onclick: () => set(d.read_only) }, d.read_only ? t("Allow changes") : t("Turn changes off"))); -} - function render() { if (S.busy) { S.dirty = true; return; } if ($("#app").hidden) return; @@ -2271,7 +2262,6 @@ function render() { const d = dev(); const field = !S.settings && S.view === "soundfield"; // the room plan works without a connected DSP document.body.dataset.view = field ? "soundfield" : S.settings || !d ? "settings" : S.view; - document.body.classList.toggle("locked", viewOnly()); if (field) content = viewSoundField(); else if (S.settings || !d) content = viewSettings(); else if (d.status !== "online" || !d.state) @@ -2282,7 +2272,7 @@ function render() { 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, limiter: viewLimiter, test: viewTest }[S.view] || viewMixer)(d); - main.replaceChildren(...[!field && !S.settings && d && d.beta ? betaBanner(d) : null, content].flat().filter(Boolean)); + main.replaceChildren(...[content].flat().filter(Boolean)); main.querySelectorAll(H_SCROLL).forEach((e, i) => { if (xs[i]) e.scrollLeft = xs[i]; }); window.scrollTo(0, y); collectMeters(); @@ -2322,12 +2312,10 @@ new ResizeObserver(() => document.documentElement.style.setProperty("--sb", $("# // ------------------------------------------------------------------ lock (desktop app window: look, don't touch) -const viewOnly = () => !!S.locked || (!S.settings && S.view !== "soundfield" && !!(dev() && dev().read_only)); - function showLock() { const b = $("#btn-lock"); b.hidden = !S.isApp; - document.body.classList.toggle("locked", viewOnly()); + document.body.classList.toggle("locked", !!S.locked); b.classList.toggle("on", !!S.locked); b.title = S.locked ? t("Locked – click to unlock") : t("Lock (view only)"); b.setAttribute("aria-label", b.title); @@ -2359,14 +2347,14 @@ $("#btn-lock").addEventListener("click", async () => { const VIEW_OK = ".chsel, .nav, .strip-head, .xout, .band, #btn-muteall, [data-view-ok]"; for (const type of ["pointerdown", "mousedown", "click", "dblclick", "keydown", "wheel"]) { document.addEventListener(type, e => { - if (!viewOnly() || !(e.target instanceof Element)) return; + if (!S.locked || !(e.target instanceof Element)) return; const tgt = e.target; if (!tgt.closest("#main, #statusbar") || tgt.closest(VIEW_OK)) return; if (type === "wheel" && !tgt.closest(".fader, input, select")) return; // page scrolling stays if (type === "keydown" && !tgt.closest("button, input, select, textarea, .fader, [tabindex]")) return; if (type === "pointerdown" && !tgt.closest("button, input, select, textarea, .fader, canvas, a")) return; e.preventDefault(); e.stopPropagation(); - if (type === "click" && Date.now() - (S.lockToast || 0) > 1500) { S.lockToast = Date.now(); toast(S.locked ? t("Locked – unlock at the top right to make changes") : t("Beta model: changes are off")); } + if (type === "click" && Date.now() - (S.lockToast || 0) > 1500) { S.lockToast = Date.now(); toast(t("Locked – unlock at the top right to make changes")); } }, { capture: true, passive: false }); } diff --git a/static/i18n.js b/static/i18n.js index 7c7889b..500329c 100644 --- a/static/i18n.js +++ b/static/i18n.js @@ -516,13 +516,7 @@ const DE = { "Dissolve group": "Gruppe auflösen", "{names} joins the group and takes over its settings (name{routing} stays).": "{names} kommt in die Gruppe und übernimmt ihre Einstellungen – außer Name{routing}.", "{names} leaves the group and keeps its current settings.": "{names} verlässt die Gruppe und behält seine aktuellen Einstellungen.", - "Allow changes": "Änderungen erlauben", - "Turn changes off": "Änderungen ausschalten", - "Only continue if the values shown here match the DSP (names, gains, filters, routing). If they don't, a change can send wrong values – keep the amplifiers off while testing.": "Nur weitermachen, wenn die angezeigten Werte zum DSP passen (Namen, Gains, Filter, Routing). Sonst kann eine Änderung falsche Werte senden – beim Testen die Endstufen ausgeschaltet lassen.", - "{model} – Beta": "{model} – Beta", - "Not tested on a real device yet, so changes are off. Compare the shown values with the DSP. If they don't match, send the file from File… → Export to the developer.": "Noch nicht an einem echten Gerät getestet, darum sind Änderungen aus. Vergleiche die angezeigten Werte mit dem DSP. Passen sie nicht, schick die Datei aus Datei… → Export an den Entwickler.", - "Not tested on a real device yet. Changes are on – keep the amplifiers off while testing.": "Noch nicht an einem echten Gerät getestet. Änderungen sind an – beim Testen die Endstufen ausgeschaltet lassen.", - "Beta model: changes are off": "Beta-Modell: Änderungen sind aus", + "Beta: this model has not been tested on a real device yet. Keep the amplifiers off for the first test.": "Beta: Dieses Modell wurde noch nicht an einem echten Gerät getestet. Beim ersten Test die Endstufen ausgeschaltet lassen.", }; const DE_PATTERNS = [ diff --git a/static/style.css b/static/style.css index daa7495..4d19316 100644 --- a/static/style.css +++ b/static/style.css @@ -744,10 +744,6 @@ input[type=range].haslim::-moz-range-track { .lkgroup.editing { background: color-mix(in srgb, var(--lc) 14%, var(--panel2)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--lc) 45%, transparent); } .lkgroup.dim { opacity: .5; } .lkactions button + button { margin-left: 6px; } -/* ---- beta models */ -.betabar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; padding: 9px 12px; border-radius: 9px; font-size: 13px; - background: #f59e0b14; border: 1px solid #f59e0b55; } -.betabar b { color: var(--warn); } -.betabar.ro { background: #f59e0b24; border-color: #f59e0b99; } -.betabar button { flex: none; } -@media (max-width: 560px) { .betabar { flex-direction: column; align-items: stretch; } } +/* ---- note on beta models in the add-device form */ +.betanote { margin: 0; padding: 8px 10px; border-radius: 8px; color: var(--text); background: #f59e0b1f; border: 1px solid #f59e0b66; } +.betanote[hidden] { display: none; } diff --git a/tests/test_protocol.py b/tests/test_protocol.py index e95f741..0663466 100644 --- a/tests/test_protocol.py +++ b/tests/test_protocol.py @@ -171,7 +171,7 @@ def test_beta_models(): assert P.detect_model(info) is None, info for key in ("206", "408fir"): m = P.MODELS[key] - assert m.beta and not {P.CMD_GAIN, P.CMD_MUTE, P.CMD_LINK, P.CMD_PRESET_RECALL} & P.READ_COMMANDS + assert m.beta st = P.default_state(m) st["outputs"][m.n_out - 1]["gain"] = 123 back = P.parse_state(m, bytes(P.build_state_buffer(m, st)))