DJ Brake page without login; routing level text follows the slider live

Optional page /djbrake (off by default) with a red light while a limiter works.
It needs no PIN and only ever gets {on, ready} from /djbrake/state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
GivouandClaude Opus 5.5 committed 2026-11-02 18:38:36 +01:00
1 parent 3ce0334aea
commit e56524a8cd
7 files changed
+179 -6

No files matched your search

+2
View File
@@ -57,6 +57,8 @@ pi_writer.py → pi_image.py (cloud-init SD card, installs server.py as a system
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; 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.
* **DJ Brake** (`static/djbrake.html`, `App.dj_stream`) – the only page without a login, off by default. It may only ever learn
`{on, ready}` from `/djbrake/state`: never add device data or controls there. On its own on purpose, without `app.js`.
* **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
+2
View File
@@ -34,6 +34,8 @@ Control both devices at the same time from your phone, tablet or computer – ov
* **Read-only switch** – on phones and tablets the web UI starts read-only; a small switch at the top allows changes
* **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. Needs no PIN
and shows nothing else
* **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
+49 -3
View File
@@ -212,6 +212,7 @@ 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
DASH_TYPES = ("status", "meters", "mixer", "curve", "channel", "limiter", "routing", "delays", "fir", "notes")
@@ -292,6 +293,9 @@ class App:
self.limiter: dict = clean_limiter({})
self.soundfield: dict = clean_soundfield({})
self.dashboard: dict | None = None
self.djbrake = False # page /djbrake for the DJ: without PIN, shows only whether a limiter acts
self.dj_hit = 0.0 # when a limiter was last seen acting
self.dj_streams = 0
self.logo = ""
# desktop app: its own window logs in with a one-time token, other devices need the PIN
self.app_token: str | None = None
@@ -340,6 +344,7 @@ class App:
self.soundfield = clean_soundfield(cfg.get("soundfield"))
if "dashboard" in cfg:
self.dashboard = clean_dashboard(cfg.get("dashboard"))
self.djbrake = bool(cfg.get("djbrake"))
if "logo" in cfg:
self.logo = clean_logo(cfg.get("logo"))
r = cfg.get("remote") or {}
@@ -356,7 +361,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}
"dashboard": self.dashboard, "djbrake": self.djbrake}
async def restore_config(self, doc: dict, session: str):
if not isinstance(doc, dict) or doc.get("format") != CONFIG_FORMAT:
@@ -414,7 +419,7 @@ class App:
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, "lock_dash": self.lock_dash,
"soundfield": self.soundfield, "logo": self.logo, "dashboard": self.dashboard,
"soundfield": self.soundfield, "logo": self.logo, "dashboard": self.dashboard, "djbrake": self.djbrake,
"mute_all": {"active": self.mute_all["active"],
"restore": {k: v for k, v in self.mute_all["restore"].items() if k != "demo"}}}
if self.lang:
@@ -871,6 +876,8 @@ class App:
# ------------------------------------------------------------ events
def broadcast(self, ev: dict):
if ev.get("type") == "meters" and any(ev.get("limit") or ()):
self.dj_hit = time.monotonic()
msg = json.dumps(ev, separators=(",", ":"))
for q in list(self.clients):
if ev["type"] == "meters" and q.qsize() > 50:
@@ -893,6 +900,11 @@ class App:
return {"logo": self.logo}
if path == "/api/logo":
return {"logo": self.logo}
if path == "/api/djbrake" and method == "PUT":
self.djbrake = bool(body.get("enabled"))
self.save()
self.broadcast({"type": "djbrake", "enabled": self.djbrake})
return {"enabled": self.djbrake}
if path == "/api/dashboard" and method == "PUT":
self.dashboard = clean_dashboard(body)
self.save()
@@ -1096,6 +1108,11 @@ class App:
else:
await self.respond(writer, 401, b"invalid app token", "text/plain")
return
if path == "/djbrake/state":
await self.dj_stream(writer)
return
if path in ("/djbrake", "/djbrake/"):
path = "/djbrake.html"
if path.startswith("/api/"):
try:
data = json.loads(body) if body else {}
@@ -1216,6 +1233,9 @@ class App:
async def static(self, writer, path: str):
rel = "index.html" if path in ("/", "") else path.lstrip("/")
if rel == "djbrake.html" and not self.djbrake:
await self.respond(writer, 404, b"not found", "text/plain")
return
f = (STATIC / rel).resolve()
if STATIC not in f.parents or not f.is_file():
await self.respond(writer, 404, b"not found", "text/plain")
@@ -1225,6 +1245,32 @@ class App:
ctype += "; charset=utf-8"
await self.respond(writer, 200, f.read_bytes(), ctype)
async def dj_stream(self, writer):
"""The one thing /djbrake may know, without a login: is a limiter acting. Nothing else leaves here."""
if not self.djbrake or self.dj_streams >= 20:
await self.respond(writer, 404, b"not found", "text/plain")
return
self.dj_streams += 1
writer.write(b"HTTP/1.1 200 OK\r\nContent-Type: text/event-stream\r\nCache-Control: no-cache\r\n"
b"Connection: keep-alive\r\nX-Accel-Buffering: no\r\n\r\n")
last, idle = None, 0.0
try:
while self.djbrake:
now = time.monotonic()
state = {"on": now - self.dj_hit < DJ_HOLD,
"ready": any(d.status == "online" for d in self.devices.values())}
if state != last:
writer.write(f"data: {json.dumps(state)}\n\n".encode())
last, idle = state, 0.0
elif idle > 15:
writer.write(b": ping\n\n")
idle = 0.0
await writer.drain()
await asyncio.sleep(0.1)
idle += 0.1
finally:
self.dj_streams -= 1
async def sse(self, writer):
writer.write(b"HTTP/1.1 200 OK\r\nContent-Type: text/event-stream\r\nCache-Control: no-cache\r\n"
b"Connection: keep-alive\r\nX-Accel-Buffering: no\r\n\r\n")
@@ -1233,7 +1279,7 @@ class App:
try:
hello = {"type": "hello", "devices": [d.snapshot() for d in self.devices.values()], "limiter": self.limiter,
"demo": self.demo_info(), "muteall": self.mute_all_info(), "soundfield": self.soundfield, "logo": self.logo,
"dashboard": self.dashboard}
"dashboard": self.dashboard, "djbrake": self.djbrake}
writer.write(f"data: {json.dumps(hello)}\n\n".encode())
await writer.drain()
while True:
+35 -3
View File
@@ -1506,7 +1506,8 @@ function mixList(d, o) {
const m = chans(dev(), "out")[o].matrix ^ (1 << i);
setParam("out", o, "matrix", m); render();
} }, h("span", { class: "sw" }), chTitle(d, "in", i));
return h("div", { class: "mixrow" + (on ? "" : " off") }, btn, paramSlider(t("Level"), "out", o, `mix.${i}`, "mix"));
return h("div", { class: "mixrow" + (on ? "" : " off") }, btn, paramSlider(t("Level"), "out", o, `mix.${i}`, "mix",
v => showLive(`${d.id}|out|${o}|mix.${i}`, v)));
});
}
@@ -1516,6 +1517,14 @@ function routingCard(d, o) {
// ------------------------------------------------------------------ routing view
function xpLevel(o, i, raw) {
const el = h("small");
const show = v => { const db = gainDb(v); el.textContent = db === 0 ? "0" : sign(db); el.title = `${sign(db)} dB`; };
show(raw);
onLive("out", o, `mix.${i}`, show);
return el;
}
function viewRouting(d) {
const ins = chans(d, "in"), outs = chans(d, "out");
const grid = h("div", { class: "xmatrix", style: `--n:${ins.length}` });
@@ -1540,7 +1549,7 @@ function viewRouting(d) {
const m = chans(dev(), "out")[o].matrix ^ (1 << i);
S.xpFx = `${d.id}|${o}|${i}`;
setParam("out", o, "matrix", m); render();
} }, h("span", { class: "node" }), on ? h("small", { title: `${sign(gainDb(oc.mix[i]))} dB` }, gainDb(oc.mix[i]) === 0 ? "0" : sign(gainDb(oc.mix[i]))) : null));
} }, h("span", { class: "node" }), on ? xpLevel(o, i, oc.mix[i]) : null));
});
if (open) grid.append(h("div", { class: "xpanel" }, h("div", { class: "xpanel-h" }, t("Level for {ch}", { ch: chTitle(d, "out", o) }),
h("button", { class: "small", onclick: () => openChannel("out", o) }, t("Open channel"))), mixList(d, o)));
@@ -2358,6 +2367,26 @@ function logoCard() {
}
// Language per device (stored in the browser); the desktop app also tells the server, for its own dialogs
function djBrakeCard() {
// the app's own address only works on this computer: other devices come through remote access
const r = S.remote || {};
const base = S.isApp ? (r.enabled && r.urls && r.urls[0]) || "" : location.origin;
const url = base ? `${base}/djbrake` : "";
const box = h("input", { type: "checkbox", checked: !!S.djbrake, onchange: async () => {
try { S.djbrake = (await api("PUT", "/api/djbrake", { enabled: box.checked })).enabled; render(); }
catch (e) { box.checked = !!S.djbrake; toast(t("Error: ") + trMsg(e.message)); }
} });
return h("div", { class: "card" }, h("h3", {}, "DJ Brake"),
h("p", { class: "info" }, t("A page for a tablet at the DJ booth: a big red light comes on when a limiter is working, so turning up more won't help.")),
h("label", { class: "chk" }, box, t("Share the page /djbrake")),
S.djbrake && url ? h("div", { class: "row djurl" }, h("code", {}, url),
h("button", { class: "small", "data-view-ok": "", onclick: async () => {
try { await navigator.clipboard.writeText(url); toast(t("Address copied")); } catch { toast(url); }
} }, t("Copy"))) : null,
S.djbrake && !url ? h("p", { class: "info djwarn" }, t("Switch on remote access below so other devices can reach it.")) : null,
S.djbrake ? h("p", { class: "info" }, t("Anyone in your network can open it without a PIN. It shows only the light, watches all outputs of all connected DSPs and changes nothing.")) : null);
}
function langCard() {
const set = async lang => {
if (lang === LANG) return;
@@ -2413,7 +2442,7 @@ function scanCard() {
function viewSettings() {
const sections = [
["general", t("General"), t("Language, demo mode and your logo."), "", [langCard(), demoCard(), logoCard()]],
["general", t("General"), t("Language, demo mode and your logo."), "", [langCard(), demoCard(), logoCard(), djBrakeCard()]],
["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."),
@@ -2608,6 +2637,7 @@ function connectEvents() {
if (ev.muteall) { S.muteAll = ev.muteall.active; showMuteAll(); }
if (ev.soundfield) S.sf = ev.soundfield;
if ("dashboard" in ev) S.dash = ev.dashboard && ev.dashboard.modules;
S.djbrake = !!ev.djbrake;
if ("logo" in ev) { S.logo = ev.logo; showLogo(); }
if (S.demo.enabled && S.devices.demo && !S.devices[S.cur]?.demo) S.cur = "demo";
S.order.forEach(id => maybeAskUnlock(S.devices[id]));
@@ -2642,6 +2672,8 @@ function connectEvents() {
sfOnRemote(ev.data); break;
case "dashboard":
dashRemote(ev.data); break;
case "djbrake":
S.djbrake = ev.enabled; if (S.settings) render(); break;
case "logo":
S.logo = ev.data; showLogo(); if (S.settings) render(); break;
case "muteall":
+81
View File
@@ -0,0 +1,81 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, 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, 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: 5vmin; text-align: center; -webkit-user-select: none; user-select: none; }
/* comes on fast, goes out slowly: the eye catches it and it never flickers */
#wash, #halo, #core { transition: opacity .7s ease-out; opacity: 0; }
body.on #wash, body.on #halo, body.on #core { transition: opacity .09s ease-out; opacity: 1; }
#wash { position: fixed; inset: 0; background: radial-gradient(circle at 50% 46%, #6e0a0a 0%, #2a0505 42%, #050608 78%); }
#lamp { position: relative; width: 66vmin; height: 66vmin; display: grid; place-items: center; }
#halo, #core, #glass, #ring { position: absolute; inset: 0; border-radius: 50%; }
#glass { background: radial-gradient(circle at 50% 38%, #171a20, #0b0d11 70%); box-shadow: inset 0 0 0 1px #ffffff14; }
#core { background: radial-gradient(circle at 50% 36%, #ff6a5c 0%, #f4201c 46%, #b80c0f 100%); box-shadow: inset 0 0 0 1px #ffb3a8, inset 0 -3vmin 7vmin #5e000380; }
#halo { inset: -7vmin; background: radial-gradient(circle, #ff2a1f 44%, #ff2a1f00 70%); filter: blur(3vmin); }
#ring { border: .5vmin solid #ff5a4c; opacity: 0; pointer-events: none; }
#word { position: relative; font-size: 10.5vmin; font-weight: 800; letter-spacing: .03em; line-height: 1; color: #4b5260; transition: color .5s; }
#sub { position: relative; min-height: 1.3em; font-size: 4.4vmin; font-weight: 500; color: #6b7280; transition: color .5s; }
body.on #word { color: #fff; transition: color .09s; }
body.on #sub { color: #ffd9d4; transition: color .09s; }
/* 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); }
@keyframes breathe { 50% { transform: scale(.94); filter: blur(4.5vmin); } }
@keyframes ripple { from { transform: scale(1); opacity: .75; } to { transform: scale(1.32); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { body.on #halo, body.on #ring { animation: none; } }
</style>
</head>
<body>
<div id="wash"></div>
<div id="lamp">
<div id="halo"></div>
<div id="ring"></div>
<div id="glass"></div>
<div id="core"></div>
<div id="word">—</div>
</div>
<div id="sub"></div>
<script>
// Red light for the DJ: comes on while a limiter of a connected DSP is working.
// On its own on purpose: this page needs no PIN and gets nothing but this one state from the server.
(function () {
var de = /^de/i.test(navigator.language || "");
var text = de
? { on: "LIMITER", more: "Mehr Gas bringt nichts", lost: "Keine Verbindung", none: "Kein DSP verbunden" }
: { on: "LIMITER", more: "More gain won't help", lost: "No connection", none: "No DSP connected" };
var word = document.getElementById("word"), sub = document.getElementById("sub");
document.documentElement.lang = de ? "de" : "en";
function show(on, main, small) {
document.body.className = on ? "on" : "";
word.textContent = main;
sub.textContent = small;
}
var es = new EventSource("/djbrake/state");
es.onmessage = function (e) {
var s = JSON.parse(e.data);
if (s.on) show(true, text.on, text.more);
else if (s.ready) show(false, "OK", "");
else show(false, "—", text.none);
};
es.onerror = function () { show(false, "—", text.lost); };
// keep the screen on where the browser allows it
function awake() { if (navigator.wakeLock) navigator.wakeLock.request("screen").catch(function () {}); }
awake();
document.addEventListener("visibilitychange", function () { if (!document.hidden) awake(); });
})();
</script>
</body>
</html>
+5
View File
@@ -674,6 +674,11 @@ const DE = {
"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.",
"A page for a tablet at the DJ booth: a big red light comes on when a limiter is working, so turning up more won't help.": "Eine Seite für ein Tablet am DJ-Pult: Ein großes rotes Licht geht an, wenn ein Limiter arbeitet, mehr Gas also nichts mehr bringt.",
"Share the page /djbrake": "Seite /djbrake freigeben",
"Address copied": "Adresse kopiert",
"Switch on remote access below so other devices can reach it.": "Schalte unten den Fernzugriff ein, damit andere Geräte sie erreichen.",
"Anyone in your network can open it without a PIN. It shows only the light, watches all outputs of all connected DSPs and changes nothing.": "Jeder in deinem Netzwerk kann sie ohne PIN öffnen. Sie zeigt nur das Licht, beobachtet alle Ausgänge aller verbundenen DSPs und ändert nichts.",
};
const DE_PATTERNS = [
+5
View File
@@ -979,3 +979,8 @@ body.dashonly .dlink { cursor: default; }
@keyframes xptext { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .xp.fx .node, .xp.fx .node::after, .xp.fx.on small { animation: none; } }
.lockopt { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
/* ---- DJ Brake setting */
.djurl { margin-top: 8px; align-items: center; flex-wrap: nowrap; }
.djurl code { flex: 1; min-width: 0; padding: 5px 8px; border-radius: 6px; background: var(--bg2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.djwarn { color: var(--warn); }
.djurl button { flex: none; }