DJ Brake: note that the limiter is not the goal, with its own settings
Shown by default and always in English by default; both can be switched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8919f0016c
commit
d6be627f32
6 files changed
+43
-9
No files matched your search
@@ -58,7 +58,7 @@ pi_writer.py → pi_image.py (cloud-init SD card, installs server.py as a system
|
||||
* **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, room}` from `/djbrake/state`: never add device data or controls there. On its own on purpose, without `app.js`.
|
||||
`{on, ready, room, hint}` 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
|
||||
|
||||
@@ -306,6 +306,8 @@ class App:
|
||||
self.dashboard: dict | None = None
|
||||
self.djbrake = False # page /djbrake for the DJ: without PIN, shows only whether a limiter acts
|
||||
self.dj_ignore: dict = {} # device id -> outputs not watched
|
||||
self.dj_hint = True # short text on the page: the limiter is not the goal
|
||||
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_streams = 0
|
||||
@@ -359,6 +361,8 @@ class App:
|
||||
self.dashboard = clean_dashboard(cfg.get("dashboard"))
|
||||
self.djbrake = bool(cfg.get("djbrake"))
|
||||
self.dj_ignore = clean_dj_ignore(cfg.get("dj_ignore"))
|
||||
self.dj_hint = bool(cfg.get("dj_hint", True))
|
||||
self.dj_hint_en = bool(cfg.get("dj_hint_en", True))
|
||||
if "logo" in cfg:
|
||||
self.logo = clean_logo(cfg.get("logo"))
|
||||
r = cfg.get("remote") or {}
|
||||
@@ -375,7 +379,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}
|
||||
"dashboard": self.dashboard, "djbrake": self.djbrake, "dj_ignore": self.dj_ignore, "dj_hint": self.dj_hint, "dj_hint_en": self.dj_hint_en}
|
||||
|
||||
async def restore_config(self, doc: dict, session: str):
|
||||
if not isinstance(doc, dict) or doc.get("format") != CONFIG_FORMAT:
|
||||
@@ -433,7 +437,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, "djbrake": self.djbrake, "dj_ignore": self.dj_ignore,
|
||||
"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,
|
||||
"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:
|
||||
@@ -937,8 +941,12 @@ class App:
|
||||
self.djbrake = bool(body["enabled"])
|
||||
if "ignore" in body:
|
||||
self.dj_ignore = clean_dj_ignore(body["ignore"])
|
||||
if "hint" in body:
|
||||
self.dj_hint = bool(body["hint"])
|
||||
if "hint_en" in body:
|
||||
self.dj_hint_en = bool(body["hint_en"])
|
||||
self.save()
|
||||
ans = {"enabled": self.djbrake, "ignore": self.dj_ignore}
|
||||
ans = {"enabled": self.djbrake, "ignore": self.dj_ignore, "hint": self.dj_hint, "hint_en": self.dj_hint_en}
|
||||
self.broadcast({"type": "djbrake", **ans})
|
||||
return ans
|
||||
if path == "/api/dashboard" and method == "PUT":
|
||||
@@ -1297,7 +1305,8 @@ class App:
|
||||
rooms = [r for r in rooms if r is not False]
|
||||
known = [r for r in rooms 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}
|
||||
"room": round(min(known) * 2) / 2 if known 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())
|
||||
last, idle = state, 0.0
|
||||
@@ -1318,7 +1327,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, "djbrake": self.djbrake, "dj_ignore": self.dj_ignore}
|
||||
"dashboard": self.dashboard, "djbrake": self.djbrake, "dj_ignore": self.dj_ignore, "dj_hint": self.dj_hint, "dj_hint_en": self.dj_hint_en}
|
||||
writer.write(f"data: {json.dumps(hello)}\n\n".encode())
|
||||
await writer.drain()
|
||||
while True:
|
||||
|
||||
+17
-2
@@ -2385,9 +2385,24 @@ function djBrakeCard() {
|
||||
} }, 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 ? djLimiters() : null,
|
||||
S.djbrake ? djHintOptions() : null,
|
||||
S.djbrake ? h("p", { class: "info" }, t("Anyone in your network can open it without a PIN. It shows only the light and the distance to the limiter and changes nothing.")) : null);
|
||||
}
|
||||
|
||||
function djHintOptions() {
|
||||
const save = async (key, on) => {
|
||||
try {
|
||||
const r = await api("PUT", "/api/djbrake", { [key]: on });
|
||||
S.djHint = r.hint; S.djHintEn = r.hint_en; render();
|
||||
} catch (e) { toast(t("Error: ") + trMsg(e.message)); render(); }
|
||||
};
|
||||
return h("div", { class: "djlim" },
|
||||
h("label", { class: "chk" }, h("input", { type: "checkbox", checked: S.djHint, onchange: e => save("hint", e.target.checked) }),
|
||||
t("Show a short note that the limiter is not the goal")),
|
||||
S.djHint ? h("label", { class: "chk" }, h("input", { type: "checkbox", checked: S.djHintEn, onchange: e => save("hint_en", e.target.checked) }),
|
||||
t("Note always in English")) : null);
|
||||
}
|
||||
|
||||
function djLimiters() {
|
||||
const devs = S.order.map(id => S.devices[id]).filter(d => d.state && !d.demo);
|
||||
const toggle = async (id, i) => {
|
||||
@@ -2655,7 +2670,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; S.djIgnore = ev.dj_ignore || {};
|
||||
S.djbrake = !!ev.djbrake; S.djIgnore = ev.dj_ignore || {}; S.djHint = ev.dj_hint !== false; S.djHintEn = ev.dj_hint_en !== false;
|
||||
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]));
|
||||
@@ -2691,7 +2706,7 @@ function connectEvents() {
|
||||
case "dashboard":
|
||||
dashRemote(ev.data); break;
|
||||
case "djbrake":
|
||||
S.djbrake = ev.enabled; S.djIgnore = ev.ignore; if (S.settings && !S.busy) render(); break;
|
||||
S.djbrake = ev.enabled; S.djIgnore = ev.ignore; S.djHint = ev.hint; S.djHintEn = ev.hint_en; if (S.settings && !S.busy) render(); break;
|
||||
case "logo":
|
||||
S.logo = ev.data; showLogo(); if (S.settings) render(); break;
|
||||
case "muteall":
|
||||
|
||||
+7
-1
@@ -9,7 +9,7 @@
|
||||
<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; }
|
||||
body { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4vmin; 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; }
|
||||
@@ -38,6 +38,8 @@
|
||||
body.on #scale { color: #ffc9c4; }
|
||||
body.on #word { color: #fff; transition: color .09s; }
|
||||
body.on #sub { color: #ffd9d4; transition: color .09s; }
|
||||
#hint { position: relative; max-width: 88vw; font-size: 2.8vmin; color: #6b7280; transition: color .5s; }
|
||||
body.on #hint { color: #ffc9c4; 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; }
|
||||
@@ -61,6 +63,7 @@
|
||||
<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>
|
||||
<div id="hint"></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.
|
||||
@@ -70,6 +73,8 @@
|
||||
? { 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");
|
||||
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;
|
||||
document.documentElement.lang = de ? "de" : "en";
|
||||
|
||||
@@ -101,6 +106,7 @@
|
||||
var s = JSON.parse(e.data), was = state && state.on;
|
||||
state = s;
|
||||
bar(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();
|
||||
};
|
||||
|
||||
@@ -681,6 +681,8 @@ const DE = {
|
||||
"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",
|
||||
};
|
||||
|
||||
const DE_PATTERNS = [
|
||||
|
||||
@@ -991,3 +991,5 @@ body.dashonly .dlink { cursor: default; }
|
||||
.djch { display: flex; flex-direction: column; align-items: center; min-width: 58px; padding: 5px 8px; line-height: 1.2; opacity: .55; }
|
||||
.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); }
|
||||
.djlim label.chk { display: flex; align-items: flex-start; gap: 8px; margin-top: 8px; }
|
||||
.djlim label.chk input { flex: none; margin: 3px 0 0; }
|
||||
Reference in new issue
Block a user