Looks per preset, steadier DJ Brake, no zoom on phones, simple dashboard on touch

Colours and link group names now belong to the preset (by name, the DSP has no
IDs) and travel in preset files. DJ Brake: limiters are left out instead of
chosen; a slowly falling peak mark, an average bar, a warning before the limit,
and it learns from real hits where the limiter sits on the meter. Pinch and
double tap zoom are off. On touchscreens the dashboard only offers widget settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
GivouandClaude Opus 5.5 committed 2026-11-02 21:09:16 +01:00
1 parent 99613327f8
commit cf35a1faa1
11 files changed
+232 -48

No files matched your search

+5 -3
View File
@@ -59,9 +59,11 @@ pi_writer.py → pi_image.py (cloud-init SD card, installs server.py as a system
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.
Pictures of the handbooks: `static/docimg/<name>.<lang>.jpg`, one per language, only ever from this app itself.
* **DJ Brake** (`static/djbrake.html`, `App.dj_stream`) – the only page without a login, off by default. It may only ever learn
`{on, ready, room, hint}` from `/djbrake/state`: never add device data or controls there. `dj_margin` moves its limit
`{on, ready, room, avg, hint}` from `/djbrake/state`: never add device data or controls there. `dj_margin` moves its limit
down on purpose, so the page must never reveal it. On its own on purpose, without `app.js`.
Its settings sit in the access section; in the apps it needs remote access, since the app itself only listens on 127.0.0.1.
* **Preset looks** – `Device.looks` keeps `colors`/`linknames` per preset name; `sync_look` swaps them whenever a read of the DSP
shows another name (the DSP has no preset IDs: same name = same look). Preset files carry them as `look`.
* **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
@@ -139,8 +141,8 @@ Not verified yet – ask for a log (`python server.py -v`) from real hardware be
only; whether the generator is pre or post input gain is unknown (the app therefore only lowers the outputs)
* Device lock (`0x2C` byte 5, `0x2D`, `0x2F`, `0x11`) – implemented from the control software's behaviour and
tested against the simulator only; no command to remove a lock is known
* DJ Brake distance to the limiter: output meter dB minus threshold dB, assumes both share one reference (only the
light, from the limiter-active bits, is certain)
* DJ Brake distance to the limiter: output meter dB minus threshold dB, corrected by what real limiter hits show (`dj_cal`);
only the light, from the limiter-active bits, is certain
* Limiter calculator reference level (assumes limiter 0 dB = 0 dBu at the output; adjustable per device)
* Pi Writer: raw write to a real SD card and first boot on a real Pi (only tested with an image file)
+4 -2
View File
@@ -35,9 +35,11 @@ Control both devices at the same time from your phone, tablet or computer – ov
* **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
* **DJ Brake** – optional page `/djbrake` for a tablet at the DJ booth: a big red light while a limiter is working and a horizontal
bar with the distance to the limiter. You choose which limiters count (a monitor can be left out) and can make it
warn a few dB before the real limiter. Needs no PIN and shows
bar with the distance to the limiter. You can leave out limiters (a monitor, say) and make it warn a few dB before
the real limiter. The bar shows the average of the last seconds, a mark the recent peaks, and the page learns from real limiter
hits where the limiter sits on the meter. Needs no PIN and shows
nothing else
* **Preset looks** – colours and link group names belong to the preset (by its name) and also travel in preset files
* **Mixer** – faders, mute and live meters for all inputs and outputs, limiter LED on every output (status read
from the DSP)
* **Channel** – name, gain, delay, polarity, high/low pass, 8/9-band PEQ with a draggable curve; the curve shows
+33 -3
View File
@@ -22,7 +22,8 @@ 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):
colors: dict | None = None, maxgain: dict | None = None, linknames: dict | None = None,
looks: dict | None = None, look_name: str = ""):
self.id = dev_id
self.name = name
self.host = host
@@ -39,6 +40,11 @@ class Device:
self.demo = False # in-process simulator of the demo mode, never saved
self.colors: dict[str, str] = colors or {} # channel colours chosen in the app, e.g. {"in0": "#38bdf8"}
self.linknames: dict[str, str] = linknames or {} # names of link groups, e.g. {"out:0,1": "Tops"}
# colours and group names per preset. The DSP has no IDs for presets, only slots and names, and only the name
# is in its memory image, so that is the key. colors/linknames above always are those of look_name.
self.looks: dict[str, dict] = looks or {}
self.look_name = look_name
self.look_dirty = False
self.maxgain: dict[str, int] = maxgain or {} # software limit of the gain fader per channel (raw), e.g. {"out0": 260}
# audio test: output gains from before the test (restored when it ends) and the test fader level
self.test_saved: list[int] | None = test_saved if isinstance(test_saved, list) else None
@@ -75,11 +81,13 @@ 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}
"colors": self.colors, "maxgain": self.maxgain, "linknames": self.linknames,
"looks": self.looks, "look_name": self.look_name}
def snapshot(self) -> dict:
cfg = self.config()
cfg["lock_code"] = bool(self.lock_code) # clients only learn whether a code is remembered
del cfg["looks"], cfg["look_name"]
cfg["test_level"] = self.test_level
return {**cfg, "demo": self.demo, "status": self.status, "error": self.error, "info": self.info,
"detected_model": self.model_name or None,
@@ -245,6 +253,24 @@ class Device:
self.state = state
self._emit_state()
def remember_look(self):
"""Keeps the current colours and group names with the loaded preset."""
self.looks[self.look_name] = {"colors": dict(self.colors), "linknames": dict(self.linknames)}
while len(self.looks) > 64:
del self.looks[next(k for k in self.looks if k != self.look_name)]
self.look_dirty = True
def sync_look(self):
"""After reading the DSP: another preset brings its own look. One not seen yet starts with the current one."""
name = (self.state or {}).get("preset_name", "").strip()
if self.state is None or (name == self.look_name and name in self.looks):
return
look = self.looks.get(name)
if look:
self.colors, self.linknames = dict(look["colors"]), dict(look["linknames"])
self.look_name = name
self.remember_look()
async def recall_preset(self, index: int):
await self._request(P.CMD_PRESET_RECALL, bytes([index + 1]), timeout=2.0)
await asyncio.sleep(0.3)
@@ -259,6 +285,8 @@ class Device:
self.presets[index] = name
if self.state:
self.state["preset_name"] = name
self.look_name = name.strip() # also when overwriting: what is stored now is what we see now
self.remember_look()
self._emit_state()
@property
@@ -268,7 +296,8 @@ class Device:
async def export_preset(self) -> dict:
"""The DSP's current state, read fresh from the device."""
await self.refresh()
return preset.export_doc(self.model_name, self.info, self.state, self.raw)
return {**preset.export_doc(self.model_name, self.info, self.state, self.raw),
"look": {"colors": self.colors, "linknames": self.linknames}}
async def import_preset(self, state: dict) -> list[str]:
"""Put the DSP into `state` (working state only). Returns the paths that did not take."""
@@ -440,6 +469,7 @@ class Device:
if self.model.fir and self.state: # where this model keeps the test signal in its memory is not known
state["test"] = self.state.get("test", state["test"])
self.state = state
self.sync_look()
async def _read_config(self) -> dict:
model = self.model
+78 -16
View File
@@ -212,7 +212,10 @@ def rew_send_curve(body: dict):
"magnitude": rew_floats(mag), "phase": rew_floats(phase)})
DJ_HOLD = 0.8 # s the light of /djbrake stays on after a limiter acted, so short hits are seen
DJ_HOLD = 1.5 # s the light of /djbrake stays on after a limiter acted, so it doesn't flicker with the music
DJ_PEAK_HOLD = 1.5 # s the peak marker stays, then it falls ...
DJ_PEAK_FALL = 3.0 # ... this many dB/s: the display follows the music, not every single beat
DJ_AVG_TAU = 3.0 # s time constant of the average level
def clean_dj_margin(value) -> int:
@@ -271,6 +274,15 @@ def clean_linknames(v) -> dict:
return out
def clean_looks(v) -> dict:
"""Colours and group names per preset name: {"Party": {"colors": {...}, "linknames": {...}}}."""
out = {}
for k, look in list(v.items() if isinstance(v, dict) else [])[:64]:
if isinstance(look, dict):
out[str(k)[:14]] = {"colors": clean_colors(look.get("colors")), "linknames": clean_linknames(look.get("linknames"))}
return out
def clean_maxgain(v) -> dict:
"""Software gain limits per channel: {"in0": raw 0..399} (400 = +12 dB would be no limit)."""
out = {}
@@ -316,6 +328,10 @@ class App:
self.dj_hint_en = True # that text always in English, else in the language of the browser
self.dj_hit = 0.0 # when a limiter was last seen acting
self.dj_rooms: dict = {} # device id -> dB left to the nearest watched limiter, False = nothing watched
self.dj_avgs: dict = {} # the same for the average level
self.dj_env: dict = {} # "device:output" -> peak and average of the level
self.dj_cal: dict = {} # "device:output" -> dB the limiter sits below its threshold on the meter, learned from hits
self.dj_cal_saved = 0.0
self.dj_streams = 0
self.logo = ""
# desktop app: its own window logs in with a one-time token, other devices need the PIN
@@ -368,6 +384,8 @@ class App:
self.djbrake = bool(cfg.get("djbrake"))
self.dj_ignore = clean_dj_ignore(cfg.get("dj_ignore"))
self.dj_margin = clean_dj_margin(cfg.get("dj_margin"))
self.dj_cal = {str(k)[:80]: float(v) for k, v in (cfg.get("dj_cal") if isinstance(cfg.get("dj_cal"), dict) else {}).items()
if type(v) in (int, float)}
self.dj_hint = bool(cfg.get("dj_hint", True))
self.dj_hint_en = bool(cfg.get("dj_hint_en", True))
if "logo" in cfg:
@@ -386,7 +404,7 @@ class App:
return {"format": CONFIG_FORMAT, "version": 1, "exported": time.strftime("%Y-%m-%dT%H:%M:%S"),
"devices": [d.config() for d in self.real_devices()], "auth": self.auth,
"limiter": self.limiter, "remote": self.remote, "soundfield": self.soundfield, "logo": self.logo,
"dashboard": self.dashboard, "djbrake": self.djbrake, "dj_ignore": self.dj_ignore, "dj_hint": self.dj_hint, "dj_hint_en": self.dj_hint_en, "dj_margin": self.dj_margin}
"dashboard": self.dashboard, "djbrake": self.djbrake, "dj_ignore": self.dj_ignore, "dj_hint": self.dj_hint, "dj_hint_en": self.dj_hint_en, "dj_margin": self.dj_margin, "dj_cal": self.dj_cal}
async def restore_config(self, doc: dict, session: str):
if not isinstance(doc, dict) or doc.get("format") != CONFIG_FORMAT:
@@ -428,8 +446,17 @@ class App:
for old in self.undo_files(dev.id)[MAX_UNDO:]:
old.unlink(missing_ok=True)
diffs = await dev.import_preset(state)
self.take_look(dev, body.get("doc"))
return {"ok": not diffs, "differences": diffs[:20], "name": state.get("preset_name", "")}
def take_look(self, dev: Device, doc):
"""Colours and group names that came with a preset file (older files have none)."""
look = doc.get("look") if isinstance(doc, dict) else None
if isinstance(look, dict):
dev.colors, dev.linknames = clean_colors(look.get("colors")), clean_linknames(look.get("linknames"))
dev.remember_look()
self.broadcast({"type": "device", "device": dev.id, "data": dev.snapshot()})
async def undo_import(self, dev: Device) -> dict:
files = self.undo_files(dev.id)
if not files:
@@ -437,6 +464,7 @@ class App:
doc = json.loads(files[0].read_text(encoding="utf-8"))
state = preset.read_file(dev.model_name, dev.model, dev.state, doc=doc)
diffs = await dev.import_preset(state)
self.take_look(dev, doc)
files[0].unlink()
return {"ok": not diffs, "differences": diffs[:20]}
@@ -460,7 +488,8 @@ 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")))
maxgain=clean_maxgain(d.get("maxgain")), linknames=clean_linknames(d.get("linknames")),
looks=clean_looks(d.get("looks")), look_name=str(d.get("look_name") or "")[:14])
dev.on_online = self.device_online
self.devices[dev_id] = dev
if dev.autoconnect:
@@ -900,29 +929,56 @@ class App:
# ------------------------------------------------------------ events
def dj_note(self, ev: dict):
def dj_track(self, key: str, level: float, limit: bool, threshold: int, now: float) -> tuple:
"""One meter reading of a watched output: (dB left by the peak, dB left by the average, warn now)."""
e = self.dj_env.setdefault(key, {"peak": -120.0, "until": 0.0, "pow": 0.0, "t": now})
dt = min(now - e["t"], 1.0)
e["t"] = now
db = 20 * math.log10(level) if level > 0 else -120.0
if db >= e["peak"]:
e["peak"], e["until"] = db, now + DJ_PEAK_HOLD
elif now > e["until"]:
e["peak"] = max(db, e["peak"] - DJ_PEAK_FALL * dt)
e["pow"] += (level * level - e["pow"]) * (1 - math.exp(-dt / DJ_AVG_TAU))
thr = P.threshold_to_db(threshold)
if limit and e["peak"] > -70: # the limiter acts: this is where it really sits on the meter
seen = max(-6.0, min(30.0, thr - e["peak"]))
self.dj_cal[key] = seen if key not in self.dj_cal else self.dj_cal[key] + (seen - self.dj_cal[key]) * (1 - math.exp(-dt))
top = thr - self.dj_cal.get(key, 0.0) - self.dj_margin
left = 0.0 if limit else max(0.0, top - e["peak"]) if e["peak"] > -70 else None
mean = max(0.0, top - 10 * math.log10(e["pow"])) if e["pow"] > 1e-7 else None
return left, mean, limit or bool(self.dj_margin and db >= top)
def dj_note(self, ev: dict, now: float | None = None):
"""Keeps the state of the /djbrake page. A muted output is not watched: nobody hears it."""
dev = self.devices.get(ev["device"])
if not dev or not dev.state:
return
room, ignore = False, self.dj_ignore.get(dev.id, ())
now = time.monotonic() if now is None else now
room, avg, ignore = False, None, self.dj_ignore.get(dev.id, ())
for i, (level, limit) in enumerate(zip(ev["out"], ev["limit"])):
ch = dev.state["outputs"][i]
ch, key = dev.state["outputs"][i], f"{dev.id}:{i}"
if i in ignore or ch["mute"]:
self.dj_env.pop(key, None)
continue
if limit:
self.dj_hit = time.monotonic()
left = 0.0 if limit else None
if not limit and level > 0:
left = max(0.0, P.threshold_to_db(ch["limit"]["threshold"]) - self.dj_margin - 20 * math.log10(level))
if self.dj_margin and left == 0:
self.dj_hit = time.monotonic()
left, mean, warn = self.dj_track(key, level, limit, ch["limit"]["threshold"], now)
if warn:
self.dj_hit = now
room = left if room is False or room is None else room if left is None else min(room, left)
self.dj_rooms[dev.id] = room
avg = mean if avg is None else avg if mean is None else min(avg, mean)
self.dj_rooms[dev.id], self.dj_avgs[dev.id] = room, avg
if self.dj_cal and now - self.dj_cal_saved > 60: # an SD card is not for writing with every beat
self.dj_cal_saved = now
self.save()
def broadcast(self, ev: dict):
if ev["type"] == "meters":
self.dj_note(ev)
elif ev["type"] == "device":
dev = self.devices.get(ev["device"])
if dev and dev.look_dirty:
dev.look_dirty = False
self.save()
msg = json.dumps(ev, separators=(",", ":"))
for q in list(self.clients):
if ev["type"] == "meters" and q.qsize() > 50:
@@ -950,6 +1006,8 @@ class App:
self.djbrake = bool(body["enabled"])
if "ignore" in body:
self.dj_ignore = clean_dj_ignore(body["ignore"])
if body.get("relearn"):
self.dj_cal = {}
if "margin" in body:
self.dj_margin = clean_dj_margin(body["margin"])
if "hint" in body:
@@ -1097,11 +1155,13 @@ class App:
return {"ok": True}
if action == "colors": # display only, stays in the app (the DSP doesn't know colours)
dev.colors = clean_colors(body.get("colors"))
dev.remember_look()
self.save()
self.broadcast({"type": "device", "device": dev.id, "data": dev.snapshot()})
return {"ok": True, "colors": dev.colors}
if action == "linknames": # display only, like the colours
dev.linknames = clean_linknames(body.get("linknames"))
dev.remember_look()
self.save()
self.broadcast({"type": "device", "device": dev.id, "data": dev.snapshot()})
return {"ok": True, "linknames": dev.linknames}
@@ -1313,11 +1373,13 @@ class App:
try:
while self.djbrake:
now = time.monotonic()
rooms = [self.dj_rooms.get(d.id, False) for d in self.devices.values() if d.status == "online"]
rooms = [r for r in rooms if r is not False]
online = [d.id for d in self.devices.values() if d.status == "online"]
rooms = [r for r in (self.dj_rooms.get(i, False) for i in online) if r is not False]
known = [r for r in rooms if r is not None]
avgs = [r for r in (self.dj_avgs.get(i) for i in online) if r is not None]
state = {"on": now - self.dj_hit < DJ_HOLD, "ready": bool(rooms),
"room": round(min(known) * 2) / 2 if known else None,
"avg": round(min(avgs)) if avgs else None,
"hint": ("en" if self.dj_hint_en else "auto") if self.dj_hint else None}
if state != last:
writer.write(f"data: {json.dumps(state)}\n\n".encode())
+11 -4
View File
@@ -1678,6 +1678,7 @@ function colorCard(d) {
g.length > 1 ? h("span", { class: "lnk" }, svgIcon(ICON.link)) : null);
};
return h("div", { class: "card wide colorbox" }, h("h3", {}, t("Channel colours")),
h("p", { class: "info" }, t("Colours and group names belong to the loaded preset (by its name) and come back when you load it.")),
h("p", { class: "info" }, t("Shown on the mixer strips and in the channel view. Linked channels share one colour; every colour can only be used once per DSP.")),
h("div", { class: "colgrid" },
h("div", {}, h("div", { class: "sub" }, t("Inputs")), chanGroups(d, "in").map(g => row("in", g))),
@@ -2401,7 +2402,12 @@ function djMarginOption() {
catch (e) { toast(t("Error: ") + trMsg(e.message)); render(); }
} });
return h("div", { class: "djlim" }, h("div", { class: "row" }, h("b", { class: "grow" }, t("Warn earlier")), val), input,
h("p", { class: "info" }, t("The page acts as if the limiter came this much earlier, so the DJ stays below the real one. The limiter itself does not change and the page does not show this setting.")));
h("p", { class: "info" }, t("The page acts as if the limiter came this much earlier, so the DJ stays below the real one. The limiter itself does not change and the page does not show this setting.")),
h("p", { class: "info" }, t("With every real limiter hit the page learns where the limiter sits on the meter, so the distance gets more accurate.")),
h("button", { class: "small", onclick: async () => {
try { await api("PUT", "/api/djbrake", { relearn: true }); toast(t("Learned limiter levels forgotten")); }
catch (e) { toast(t("Error: ") + trMsg(e.message)); }
} }, t("Forget learned levels")));
}
function djHintOptions() {
@@ -2426,11 +2432,12 @@ function djLimiters() {
try { S.djIgnore = (await api("PUT", "/api/djbrake", { ignore })).ignore; render(); }
catch (e) { toast(t("Error: ") + trMsg(e.message)); }
};
return h("div", { class: "djlim" }, h("b", {}, t("Limiters that count")),
return h("div", { class: "djlim" }, h("b", {}, t("Leave out these limiters")),
h("p", { class: "info" }, t("All others count. Muted outputs never count.")),
devs.length ? devs.map(d => h("div", { class: "djdev" }, devs.length > 1 ? h("small", {}, d.name) : null,
h("div", { class: "djchs" }, chans(d, "out").map((c, i) => {
const on = !(S.djIgnore[d.id] || []).includes(i);
return h("button", { class: "djch" + (on ? " on" : ""), "aria-pressed": String(on), onclick: () => toggle(d.id, i) },
const out = (S.djIgnore[d.id] || []).includes(i);
return h("button", { class: "djch" + (out ? " out" : ""), "aria-pressed": String(out), onclick: () => toggle(d.id, i) },
chLabel("out", i), c.name ? h("small", {}, c.name) : null);
})))) : h("p", { class: "info" }, t("Connect a DSP to choose.")));
}
+8 -6
View File
@@ -10,6 +10,8 @@ const DASH_DEFAULT = () => [
].map((m, i) => ({ id: `m${i}`, cfg: {}, ...m }));
let dashEdit = false, dashTimer = 0, dashSaveTimer = 0;
// dragging modules around is no good on a touchscreen: there only their settings can be changed
const dashTouch = () => matchMedia("(pointer: coarse)").matches;
const dashBrowse = new Map(); // module id -> { kind, idx, band }
const dashMods = () => S.dash || (S.dash = DASH_DEFAULT());
@@ -377,15 +379,15 @@ function dashModule(m) {
const controls = dashEdit ? (() => {
return h("div", { class: "dctl" },
h("button", { class: "small", "aria-label": t("Module settings"), title: t("Module settings"), onclick: () => dashSettings(m) }, "⚙"),
h("button", { class: "small danger", "aria-label": t("Remove"), title: t("Remove"), onclick: () => {
dashTouch() ? null : h("button", { class: "small danger", "aria-label": t("Remove"), title: t("Remove"), onclick: () => {
dashMods().splice(dashMods().indexOf(m), 1); dashSave(); render();
} }, "×"));
})() : null;
const head = h("h3", { title: dashEdit ? t("Drag to move") : null }, svgIcon(def.icon), h("span", { class: "grow dtitle" }, m.cfg.title || def.title()),
const head = h("h3", { title: dashEdit && !dashTouch() ? t("Drag to move") : null }, svgIcon(def.icon), h("span", { class: "grow dtitle" }, m.cfg.title || def.title()),
d && dashDevs().length > 1 ? h("small", { class: "ddev" }, d.name) : null, controls);
const el = h("section", { class: `card dmod dt-${m.type}`, style: dashSizeStyle(m.w, dashHeight(m, d)) },
head, h("div", { class: "dbody" }, body));
if (dashEdit) {
if (dashEdit && !dashTouch()) {
head.addEventListener("pointerdown", e => { if (!e.target.closest("button")) dashDrag(e, { mod: m }, head); });
const handle = (axes, cls, arrow, label) => {
const g = h("span", { class: "dgrab " + cls, title: label }, arrow);
@@ -403,9 +405,9 @@ function viewDash() {
const mods = dashMods();
return [
h("div", { class: "dhead" }, h("h2", {}, "Dashboard"),
viewOnly() ? null : h("button", { class: dashEdit ? "on" : "", onclick: () => { dashEdit = !dashEdit; render(); } }, dashEdit ? t("Done") : t("Customise"))),
dashEdit ? dashPalette() : null,
mods.length ? h("div", { class: "dash" + (dashEdit ? " editing" : "") }, mods.map(dashModule))
viewOnly() ? null : h("button", { class: dashEdit ? "on" : "", onclick: () => { dashEdit = !dashEdit; render(); } }, dashEdit ? t("Done") : dashTouch() ? t("Widget settings") : t("Customise"))),
dashEdit && !dashTouch() ? dashPalette() : null,
mods.length ? h("div", { class: "dash" + (dashEdit && !dashTouch() ? " editing" : "") }, mods.map(dashModule))
: h("div", { class: "dash" + (dashEdit ? " editing" : "") }, h("div", { class: "dmod dblank", style: dashSizeStyle(12, 4) }, t("Nothing here yet – press “Customise” and add modules."))),
];
}
+25 -10
View File
@@ -2,12 +2,13 @@
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">
<meta name="theme-color" content="#000000">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>DJ Brake</title>
<style>
html { touch-action: manipulation; }
html, body { height: 100%; margin: 0; background: #050608; color: #fff; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; overflow: hidden; }
body { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4vmin; text-align: center; -webkit-user-select: none; user-select: none; }
@@ -30,6 +31,7 @@
#track { position: relative; height: 3.6vmin; border-radius: 1.8vmin; overflow: hidden; box-shadow: 0 0 0 1px #ffffff1c;
background: linear-gradient(90deg, #17a34a 0%, #22c55e 55%, #eab308 78%, #f97316 90%, #ef2b24 100%); }
#cover { position: absolute; top: 0; right: 0; bottom: 0; width: 100%; background: #12151a; }
#peak { position: absolute; top: 0; bottom: 0; left: 0; width: .7vmin; margin-left: -.35vmin; border-radius: .35vmin; background: #fff; box-shadow: 0 0 1vmin #0009; opacity: 0; transition: left .5s ease-out, opacity .3s; }
#ticks { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 calc(20% - 2px), #050608b0 calc(20% - 2px) 20%); }
#scale { position: relative; height: 3vmin; margin-top: 1vmin; font-size: 2.3vmin; color: #6b7280; font-variant-numeric: tabular-nums; }
#scale span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
@@ -41,6 +43,12 @@
#hint { position: relative; max-width: 88vw; font-size: 2.8vmin; color: #6b7280; transition: color .5s; }
body.on #hint { color: #ffc9c4; transition: color .09s; }
/* nearly there: warned in time, without the alarm */
body.near #word { color: #f59e0b; }
body.near #sub { color: #fbbf24; }
#glass { transition: box-shadow .5s; }
body.near #glass { box-shadow: inset 0 0 0 1px #f59e0b99, 0 0 5vmin #f59e0b33; }
/* while it lasts: slow breathing, one ring on each new hit, no hard flashing */
body.on #halo { animation: breathe 2.2s ease-in-out infinite; }
body.on #ring { animation: ripple .9s cubic-bezier(.2, .6, .3, 1); }
@@ -59,7 +67,7 @@
<div id="word">—</div>
</div>
<div id="gauge">
<div id="track"><div id="cover"></div><div id="ticks"></div></div>
<div id="track"><div id="cover"></div><div id="ticks"></div><div id="peak"></div></div>
<div id="scale"><span style="left:0">−30</span><span style="left:20%">−24</span><span style="left:40%">−18</span><span style="left:60%">−12</span><span style="left:80%">−6</span><span style="left:100%">0 dB</span></div>
</div>
<div id="sub"></div>
@@ -70,9 +78,9 @@
(function () {
var de = /^de/i.test(navigator.language || "");
var text = de
? { on: "LIMITER", more: "Mehr Gas bringt nichts", lost: "Keine Verbindung", none: "Kein Limiter überwacht", quiet: "Kein Signal", left: " dB bis zum Limiter" }
: { on: "LIMITER", more: "More gain won't help", lost: "No connection", none: "No limiter being watched", quiet: "No signal", left: " dB to the limiter" };
var word = document.getElementById("word"), sub = document.getElementById("sub"), cover = document.getElementById("cover");
? { on: "LIMITER", more: "Mehr Gas bringt nichts", lost: "Keine Verbindung", none: "Kein Limiter überwacht", quiet: "Kein Signal", left: " dB bis zum Limiter", close: "KNAPP" }
: { on: "LIMITER", more: "More gain won't help", lost: "No connection", none: "No limiter being watched", quiet: "No signal", left: " dB to the limiter", close: "CLOSE" };
var word = document.getElementById("word"), sub = document.getElementById("sub"), cover = document.getElementById("cover"), peak = document.getElementById("peak");
var hint = document.getElementById("hint");
var notes = { en: "The limiter is a safety net, not the target. Stay below it.", de: "Der Limiter ist die Sicherung, nicht das Ziel. Bleib darunter." };
var RANGE = 30, gap = 100, state = null, closest = null;
@@ -86,8 +94,14 @@
gap = next;
}
function show(on, main, small) {
document.body.className = on ? "on" : "";
// the white mark: the recent peaks, falling slowly. The bar: the average of the last seconds
function mark(room) {
peak.style.opacity = room == null ? 0 : 1;
if (room != null) peak.style.left = 100 - Math.min(100, room / RANGE * 100) + "%";
}
function show(on, main, small, near) {
document.body.className = on ? "on" : near ? "near" : "";
word.textContent = main;
sub.textContent = small;
}
@@ -96,7 +110,7 @@
var s = state;
if (!s) return;
if (s.on) show(true, text.on, text.more);
else if (s.ready) show(false, "OK", closest == null ? text.quiet : closest.toFixed(1) + text.left);
else if (s.ready) show(false, closest != null && closest <= 3 ? text.close : "OK", closest == null ? text.quiet : closest.toFixed(1) + text.left, closest != null && closest <= 3);
else show(false, "—", text.none);
closest = s.room;
}
@@ -105,12 +119,13 @@
es.onmessage = function (e) {
var s = JSON.parse(e.data), was = state && state.on;
state = s;
bar(s.on ? 0 : s.room);
bar(s.avg);
mark(s.on ? 0 : s.room);
hint.textContent = !s.hint ? "" : s.hint === "auto" && de ? notes.de : notes.en;
if (s.room != null && (closest == null || s.room < closest)) closest = s.room;
if (s.on !== was || !s.ready) draw();
};
es.onerror = function () { state = null; bar(null); show(false, "—", text.lost); };
es.onerror = function () { state = null; bar(null); mark(null); show(false, "—", text.lost); };
// the number shows the closest value of the last moment: a figure jumping ten times a second can't be read
setInterval(draw, 500);
+7 -1
View File
@@ -678,7 +678,6 @@ const DE = {
"Address copied": "Adresse kopiert",
"Only reachable while remote access is on.": "Nur erreichbar, solange der Fernzugriff an ist.",
"Anyone in your network can open it without a PIN. It shows only the light and the distance to the limiter and changes nothing.": "Jeder in deinem Netzwerk kann sie ohne PIN öffnen. Sie zeigt nur das Licht und den Abstand zum Limiter und ändert nichts.",
"Limiters that count": "Diese Limiter zählen",
"Connect a DSP to choose.": "Verbinde einen DSP, um auszuwählen.",
"Show a short note that the limiter is not the goal": "Kurzen Hinweis anzeigen, dass der Limiter nicht das Ziel ist",
"Note always in English": "Hinweis immer auf Englisch",
@@ -701,6 +700,13 @@ const DE = {
"“Sub”: where the subs add up and where they cancel at the chosen frequency.": "„Sub“: wo sich die Subs bei der gewählten Frequenz addieren und wo sie sich auslöschen.",
"“Timing”: marked areas mean a delay arrives before the mains or more than 30 ms late.": "„Timing“: Markierte Flächen bedeuten, dass ein Delay vor den Mains oder mehr als 30 ms zu spät ankommt.",
"The “Delays” table: distance and delay per speaker, next to what is set on the DSP now.": "Die Tabelle „Delays“: Abstand und Delay pro Lautsprecher, daneben der aktuelle Wert auf dem DSP.",
"Leave out these limiters": "Diese Limiter ausnehmen",
"All others count. Muted outputs never count.": "Alle anderen zählen. Stummgeschaltete Ausgänge zählen nie.",
"With every real limiter hit the page learns where the limiter sits on the meter, so the distance gets more accurate.": "Bei jedem echten Limiter-Treffer lernt die Seite, wo der Limiter auf dem Meter sitzt. So wird der Abstand genauer.",
"Learned limiter levels forgotten": "Gelernte Limiter-Pegel vergessen",
"Forget learned levels": "Gelernte Pegel vergessen",
"Colours and group names belong to the loaded preset (by its name) and come back when you load it.": "Farben und Gruppennamen gehören zum geladenen Preset (über seinen Namen) und kommen beim Laden wieder.",
"Widget settings": "Widget-Einstellungen",
};
const DE_PATTERNS = [
+6 -1
View File
@@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">
<meta name="theme-color" content="#0b0c0f">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
@@ -12,6 +12,11 @@
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='6' fill='%23111418'/%3E%3Cpath d='M7 22V10M13 22V6M19 22V14M25 22V9' stroke='%2338bdf8' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E">
</head>
<body>
<script>
// no zoom on phones and tablets: it breaks the faders. Safari ignores the viewport tag for this
["gesturestart", "gesturechange", "gestureend"].forEach(function (t) { document.addEventListener(t, function (e) { e.preventDefault(); }); });
document.addEventListener("touchmove", function (e) { if (e.touches.length > 1) e.preventDefault(); }, { passive: false });
</script>
<div id="splash" aria-hidden="true">
<svg viewBox="0 0 32 32" width="72" height="72"><path d="M7 22V10"/><path d="M13 22V6"/><path d="M19 22V14"/><path d="M25 22V9"/></svg>
<b>DSP Control</b><small>VK-Audio</small>
+5 -2
View File
@@ -1006,9 +1006,10 @@ body.dashonly .dlink { cursor: default; }
.djdev { margin-top: 8px; }
.djdev > small { display: block; margin-bottom: 4px; color: var(--dim); }
.djchs { display: flex; flex-wrap: wrap; gap: 6px; }
.djch { display: flex; flex-direction: column; align-items: center; min-width: 58px; padding: 5px 8px; line-height: 1.2; opacity: .55; }
.djch { display: flex; flex-direction: column; align-items: center; min-width: 58px; padding: 5px 8px; line-height: 1.2; }
.djch small { font-size: 10px; color: var(--dim); }
.djch.on { opacity: 1; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.djch.out { border-color: var(--warn); color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); text-decoration: line-through; }
.djch.out small { color: inherit; }
.djlim label.chk { display: flex; align-items: flex-start; gap: 8px; margin-top: 8px; }
.djlim label.chk input { flex: none; margin: 3px 0 0; }
.djlim input[type=range] { width: 100%; margin: 8px 0 4px; }
@@ -1042,3 +1043,5 @@ label.chk input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent
}
@media (max-width: 600px) { .cards .card > h3 { flex-wrap: wrap; row-gap: 6px; height: auto; } .cards .card > h3 > * { min-width: 0; } }
.docui { padding: 0 4px; }
html { touch-action: pan-x pan-y; }
.djlim > button.small { margin-top: 8px; }
+50
View File
@@ -206,6 +206,56 @@ def test_fir_model():
assert st["outputs"][0]["fir"]["type"] == 1 and st["outputs"][0]["fir"]["name"] == "ABC"
def test_dj_brake_follows_music():
import server, tempfile
from types import SimpleNamespace
with tempfile.TemporaryDirectory() as d:
app = server.App(Path(d) / "c.json")
thr0 = 180 # threshold 0 dB
dev = SimpleNamespace(id="x", demo=True, state={"outputs": [{"mute": False, "limit": {"threshold": thr0}}]}, status="online")
app.devices["x"] = dev
lv = lambda db: 10 ** (db / 20)
note = lambda db, t, limit=False: app.dj_note({"device": "x", "out": [lv(db)], "limit": [limit]}, now=t)
# the peak stays while the music dips, then falls slowly
note(-10, 100.0)
note(-30, 100.5)
assert abs(app.dj_rooms["x"] - 10) < 0.01
note(-30, 102.5)
assert 10 < app.dj_rooms["x"] < 14
# the limiter acts at -12 on the meter although the threshold says 0: learned, and the distance is true afterwards
note(-12, 110.0, True)
assert abs(app.dj_cal["x:0"] - 12) < 3 and app.dj_rooms["x"] == 0
assert app.dj_hit == 110.0
for i in range(30):
note(-30, 120.0 + i)
note(-20, 150.0)
assert 6 < app.dj_rooms["x"] < 10
# a left out output neither warns nor counts
app.dj_ignore = {"x": [0]}
note(-1, 160.0, True)
assert app.dj_hit == 110.0 and app.dj_rooms["x"] is False
def test_looks_follow_presets():
from dsp.device import Device
d = Device("x", "x", "127.0.0.1")
d.state = {"preset_name": "A"}
d.colors, d.linknames = {"out0": "#111111"}, {"out:0,1": "Tops"}
d.sync_look()
d.state = {"preset_name": "B"} # not seen yet: starts with what is there, then goes its own way
d.sync_look()
assert d.colors == {"out0": "#111111"}
d.colors, d.linknames = {"out0": "#222222"}, {"out:0,1": "Subs"}
d.remember_look()
d.state = {"preset_name": "A"}
d.sync_look()
assert d.colors == {"out0": "#111111"} and d.linknames == {"out:0,1": "Tops"}
d.state = {"preset_name": "B"}
d.sync_look()
assert d.colors == {"out0": "#222222"} and d.linknames == {"out:0,1": "Subs"}
assert "looks" not in d.snapshot()
if __name__ == "__main__":
for name, fn in list(globals().items()):
if name.startswith("test_"):