From 0a1f282c63c83654a128d9d291c7bd7dd703d4d2 Mon Sep 17 00:00:00 2001 From: Givou Date: Mon, 2 Nov 2026 00:13:34 +0100 Subject: [PATCH] Edit existing link groups: add or remove channels, dissolve below two A channel added in front of the group first gets the group's settings, so the DSP (which copies from the first channel) keeps them. The group name moves along. Co-Authored-By: Claude Opus 5.5 --- README.md | 4 +-- server.py | 1 + static/app.js | 87 ++++++++++++++++++++++++++++++++++++++---------- static/i18n.js | 12 +++++++ static/style.css | 5 +++ 5 files changed, 90 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 73f57f9..1d37d1a 100644 --- a/README.md +++ b/README.md @@ -35,8 +35,8 @@ Control both devices at the same time from your phone, tablet or computer – ov sub/top crossover; **EQ Bypass** switches all PEQ bands off at once * **Inputs** – noise gate, 31-band GEQ with **GEQ Bypass** · **Outputs** – compressor, limiter, input routing with mix levels * **Routing matrix**, recall and store presets -* **Channel settings** tab – link channels into groups (the DSP mirrors changes within the group) and give each group a - name – the mixer shows it as a bracket in the group's colour above its strips –, set a **max level** +* **Channel settings** tab – link channels into groups (the DSP mirrors changes within the group) edit existing groups (add or + remove channels), give each group a name – the mixer shows it as a bracket in the group's colour above its strips –, set a **max level** per channel (software lock: the fader can't go higher; if the DSP itself is turned up, it can only be pulled down until it snaps into the limit again) and pick channel colours * **Preset files** – export the current DSP state to a file and import it again. An import only changes the active diff --git a/server.py b/server.py index bc95d35..ff4ab47 100644 --- a/server.py +++ b/server.py @@ -861,6 +861,7 @@ class App: if action == "link": kind = "in" if body.get("kind") == "in" else "out" groups = [[int(i) for i in g] for g in body.get("groups") or [] if isinstance(g, list)] + await dev.flush() # e.g. settings copied to a new first channel of a group must arrive before the link await dev.set_links(kind, groups) return {"ok": True} if action == "refresh": diff --git a/static/app.js b/static/app.js index 4ccf583..79f5049 100644 --- a/static/app.js +++ b/static/app.js @@ -58,7 +58,7 @@ const S = { devices: {}, order: [], cur: store.get("dsp.cur"), view: store.get("dsp.view") || "mixer", settings: false, sel: { kind: "in", idx: 0 }, band: 0, busy: false, dirty: false, - routeOpen: null, es: null, linkSel: { in: [], out: [] }, + routeOpen: null, es: null, linkSel: { in: [], out: [] }, linkEdit: { in: null, out: null }, lim: { amps: [], assign: {}, ref: {} }, demo: { enabled: false, model: "408" }, muteAll: false, @@ -1371,9 +1371,11 @@ function viewRouting(d) { async function saveLinks(d, kind, groups, msg) { S.linkBusy = true; render(); - try { await api("POST", `/api/devices/${d.id}/link`, { kind, groups }); toast(msg); } + let ok = false; + try { await api("POST", `/api/devices/${d.id}/link`, { kind, groups }); toast(msg); ok = true; } catch (e) { toast(t("Error: ") + e.message); } - S.linkBusy = false; S.linkSel[kind] = []; render(); + S.linkBusy = false; S.linkSel[kind] = []; S.linkEdit[kind] = null; render(); + return ok; } function linkNameInput(d, kind, g) { @@ -1394,11 +1396,15 @@ function linkNameInput(d, kind, g) { function linkCard(d, kind) { const list = chans(d, kind), linked = linkedGroups(d, kind); - const sel = S.linkSel[kind] = S.linkSel[kind].filter(i => i < list.length && !linkInfo(d, kind, i)); + // editing an existing group: its members start selected, channels of other groups stay locked + let edit = S.linkEdit[kind]; + if (edit && !linked.some(g => linkKey(kind, g) === linkKey(kind, edit))) edit = S.linkEdit[kind] = null; // changed meanwhile + const free = i => !linkInfo(d, kind, i) || (edit && edit.includes(i)); + const sel = S.linkSel[kind] = S.linkSel[kind].filter(i => i < list.length && free(i)); const btns = list.map((ch, i) => { - const l = linkInfo(d, kind, i), on = sel.includes(i); - return h("button", { class: "lkch" + (on ? " sel" : "") + (l ? " taken" : ""), style: l ? `--lc:${custColor(d, kind, i) || l.color}` : "", "aria-pressed": String(on), - title: l ? t("Already linked – unlink the group first") : "", disabled: S.linkBusy || !!l, onclick: () => { S.linkSel[kind] = on ? sel.filter(j => j !== i) : [...sel, i].sort((a, b) => a - b); render(); } }, + const l = linkInfo(d, kind, i), on = sel.includes(i), locked = !free(i); + return h("button", { class: "lkch" + (on ? " sel" : "") + (locked ? " taken" : ""), style: l ? `--lc:${custColor(d, kind, i) || l.color}` : "", "aria-pressed": String(on), + title: locked ? t("Already linked – unlink the group first") : "", disabled: S.linkBusy || locked, onclick: () => { S.linkSel[kind] = on ? sel.filter(j => j !== i) : [...sel, i].sort((a, b) => a - b); render(); } }, h("b", {}, chLabel(kind, i)), h("small", {}, ch.name || "\u00a0"), h("span", { class: "lkmark" }, l ? svgIcon(ICON.link) : null)); }); @@ -1410,20 +1416,67 @@ function linkCard(d, kind) { const rest = linked.map(g => g.filter(i => !sel.includes(i))).filter(g => g.length > 1); saveLinks(d, kind, [...rest, sel], t("{names} linked", { names })); }; - const unlink = g => saveLinks(d, kind, linked.filter(x => x !== g), t("{names} unlinked", { names: g.map(i => chLabel(kind, i)).join(" + ") })); - return h("div", { class: "card" }, h("h3", {}, kind === "in" ? t("Inputs") : t("Outputs")), + const label = g => g.map(i => chLabel(kind, i)).join(" + "); + const unlink = async g => { + const names = label(g); + if (!await askConfirm(t("Unlink group"), t("Unlink {names}? Every channel keeps its current settings.", { names }), t("Unlink"), true)) return; + if (await saveLinks(d, kind, linked.filter(x => linkKey(kind, x) !== linkKey(kind, g)), t("{names} unlinked", { names }))) moveLinkName(d, kind, g, null); + }; + const startEdit = g => { S.linkEdit[kind] = g.slice(); S.linkSel[kind] = g.slice(); render(); }; + const cancelEdit = () => { S.linkEdit[kind] = null; S.linkSel[kind] = []; render(); }; + const saveEdit = async () => { + const next = sel.slice(), added = next.filter(i => !edit.includes(i)), removed = edit.filter(i => !next.includes(i)); + if (!added.length && !removed.length) return cancelEdit(); + const others = linked.filter(g => linkKey(kind, g) !== linkKey(kind, edit)); + if (next.length < 2) return unlink(edit); // one channel alone is no group + const lines = [ + added.length ? t(added.length > 1 ? "{names} join the group and take over its settings (names{routing} stay)." + : "{names} joins the group and takes over its settings (name{routing} stays).", { names: label(added), routing: kind === "out" ? t(" and routing") : "" }) : null, + removed.length ? t(removed.length > 1 ? "{names} leave the group and keep their current settings." + : "{names} leaves the group and keeps its current settings.", { names: label(removed) }) : null]; + if (!await askConfirm(t("Change group"), lines.filter(Boolean).join(" "), t("Save"))) return; + // the DSP copies the first channel's settings to the others – a new first channel gets the group's settings beforehand + if (next[0] !== edit[0] && !edit.includes(next[0])) { + try { + await api("POST", "/api/copy", { device: d.id, kind, idx: edit[0], groups: ["level", "filters", "eq", "dynamics"], + targets: [{ device: d.id, idx: next[0] }] }); + } catch (e) { toast(t("Error: ") + trMsg(e.message)); return; } + } + if (await saveLinks(d, kind, [...others, next], t("Group changed: {names}", { names: label(next) }))) moveLinkName(d, kind, edit, next); + }; + const editing = !!edit; + return h("div", { class: "card" + (editing ? " lkediting" : "") }, h("h3", {}, kind === "in" ? t("Inputs") : t("Outputs")), h("div", { class: "lkgrid" }, btns), - h("div", { class: "row lkactions" }, - h("span", { class: "grow info" }, sel.length < 2 ? t("Tap at least two channels") : t("{n} channels selected", { n: sel.length })), - h("button", { class: "on", disabled: sel.length < 2 || S.linkBusy, onclick: link }, t("Link"))), - linked.length ? h("div", { class: "lkgroups" }, linked.map((g, n) => - h("div", { class: "lkgroup", style: `--lc:${custColor(d, kind, g[0]) || LINK_COLORS[n % LINK_COLORS.length]}` }, - h("div", { class: "row" }, svgIcon(ICON.link), h("span", { class: "grow lkmembers" }, g.map(i => chLabel(kind, i)).join(" + ")), - h("button", { class: "small", disabled: S.linkBusy, onclick: () => unlink(g) }, t("Unlink"))), - linkNameInput(d, kind, g)))) + editing + ? h("div", { class: "row lkactions" }, + h("span", { class: "grow info" }, sel.length < 2 ? t("Fewer than two channels – the group will be dissolved") + : t("Edit {names}: tap channels to add or remove them", { names: label(edit) })), + h("button", { disabled: S.linkBusy, onclick: cancelEdit }, t("Cancel")), + h("button", { class: sel.length < 2 ? "danger-on" : "on", disabled: S.linkBusy, onclick: saveEdit }, sel.length < 2 ? t("Dissolve group") : t("Save"))) + : h("div", { class: "row lkactions" }, + h("span", { class: "grow info" }, sel.length < 2 ? t("Tap at least two channels") : t("{n} channels selected", { n: sel.length })), + h("button", { class: "on", disabled: sel.length < 2 || S.linkBusy, onclick: link }, t("Link"))), + linked.length ? h("div", { class: "lkgroups" }, linked.map((g, n) => { + const mine = editing && linkKey(kind, g) === linkKey(kind, edit); + return h("div", { class: "lkgroup" + (mine ? " editing" : editing ? " dim" : ""), style: `--lc:${custColor(d, kind, g[0]) || LINK_COLORS[n % LINK_COLORS.length]}` }, + h("div", { class: "row" }, svgIcon(ICON.link), h("span", { class: "grow lkmembers" }, label(g)), + h("button", { class: "small", disabled: S.linkBusy || editing, onclick: () => startEdit(g) }, t("Edit")), + h("button", { class: "small", disabled: S.linkBusy || editing, onclick: () => unlink(g) }, t("Unlink"))), + linkNameInput(d, kind, g)); + })) : h("p", { class: "info" }, t("No channels linked."))); } +// a group's name follows it when its members change (to = null: the group is gone) +async function moveLinkName(d, kind, from, to) { + const names = { ...(dev().linknames || {}) }, name = names[linkKey(kind, from)]; + if (!name) return; + delete names[linkKey(kind, from)]; + if (to) names[linkKey(kind, to)] = name; + try { await api("POST", `/api/devices/${d.id}/linknames`, { linknames: names }); } + catch (e) { toast(t("Error: ") + trMsg(e.message)); } +} + // channel colours of the current DSP: one row per channel or link group function colorCard(d) { const row = (kind, g) => { diff --git a/static/i18n.js b/static/i18n.js index bea41f0..56f2f08 100644 --- a/static/i18n.js +++ b/static/i18n.js @@ -504,6 +504,18 @@ const DE = { "Group name": "Gruppenname", "Group name saved": "Gruppenname gespeichert", "Group name removed": "Gruppenname entfernt", + "Unlink group": "Gruppe trennen", + "Unlink {names}? Every channel keeps its current settings.": "{names} trennen? Jeder Kanal behält seine aktuellen Einstellungen.", + "{names} join the group and take over its settings (names{routing} stay).": "{names} kommen in die Gruppe und übernehmen ihre Einstellungen – außer Namen{routing}.", + " and routing": " und Routing", + "{names} leave the group and keep their current settings.": "{names} verlassen die Gruppe und behalten ihre aktuellen Einstellungen.", + "Change group": "Gruppe ändern", + "Group changed: {names}": "Gruppe geändert: {names}", + "Fewer than two channels – the group will be dissolved": "Weniger als zwei Kanäle – die Gruppe wird aufgelöst", + "Edit {names}: tap channels to add or remove them": "{names} bearbeiten: Kanäle antippen zum Hinzufügen oder Entfernen", + "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.", }; const DE_PATTERNS = [ diff --git a/static/style.css b/static/style.css index e2039ba..35dce5b 100644 --- a/static/style.css +++ b/static/style.css @@ -739,3 +739,8 @@ input[type=range].haslim::-moz-range-track { .fader .limbelow { position: absolute; left: var(--tx); width: 10px; margin-left: -5px; pointer-events: none; z-index: 0; bottom: calc(12px + var(--f) * (100% - 24px)); height: calc(max(0, var(--v, 0) - var(--f)) * (100% - 24px)); background: var(--limgrey), #0b0d10; border-radius: 2px; } +/* ---- editing a link group */ +.lkediting .lkgrid { outline: 1px dashed var(--accent); outline-offset: 6px; border-radius: 10px; } +.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; }