DJ Brake: warn a few dB before the real limiter
The page moves its limit down by a chosen margin. The limiter itself does not change and the page never reveals the setting. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d6be627f32
commit
910cf3fc17
6 files changed
+39
-9
No files matched your search
@@ -58,7 +58,8 @@ 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, hint}` 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. `dj_margin` moves its limit
|
||||
down on purpose, so the page must never reveal it. 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
|
||||
|
||||
@@ -35,7 +35,8 @@ 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). Needs no PIN and shows
|
||||
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
|
||||
nothing else
|
||||
* **Mixer** – faders, mute and live meters for all inputs and outputs, limiter LED on every output (status read
|
||||
from the DSP)
|
||||
|
||||
@@ -215,6 +215,11 @@ def rew_send_curve(body: dict):
|
||||
DJ_HOLD = 0.8 # s the light of /djbrake stays on after a limiter acted, so short hits are seen
|
||||
|
||||
|
||||
def clean_dj_margin(value) -> int:
|
||||
"""dB the page puts its limit below the real one, 0-12."""
|
||||
return int(max(0, min(12, value))) if type(value) in (int, float) else 0
|
||||
|
||||
|
||||
def clean_dj_ignore(data) -> dict:
|
||||
"""Outputs the DJ Brake does not watch, per device id. Everything else is watched, so new DSPs count by default."""
|
||||
if not isinstance(data, dict):
|
||||
@@ -306,6 +311,7 @@ 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_margin = 0 # the page warns this many dB before the real limiter, and never says so
|
||||
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
|
||||
@@ -361,6 +367,7 @@ 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_margin = clean_dj_margin(cfg.get("dj_margin"))
|
||||
self.dj_hint = bool(cfg.get("dj_hint", True))
|
||||
self.dj_hint_en = bool(cfg.get("dj_hint_en", True))
|
||||
if "logo" in cfg:
|
||||
@@ -379,7 +386,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}
|
||||
"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}
|
||||
|
||||
async def restore_config(self, doc: dict, session: str):
|
||||
if not isinstance(doc, dict) or doc.get("format") != CONFIG_FORMAT:
|
||||
@@ -437,7 +444,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, "dj_hint": self.dj_hint, "dj_hint_en": self.dj_hint_en,
|
||||
"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,
|
||||
"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:
|
||||
@@ -907,7 +914,9 @@ class App:
|
||||
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"]) - 20 * math.log10(level))
|
||||
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()
|
||||
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
|
||||
|
||||
@@ -941,12 +950,15 @@ class App:
|
||||
self.djbrake = bool(body["enabled"])
|
||||
if "ignore" in body:
|
||||
self.dj_ignore = clean_dj_ignore(body["ignore"])
|
||||
if "margin" in body:
|
||||
self.dj_margin = clean_dj_margin(body["margin"])
|
||||
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, "hint": self.dj_hint, "hint_en": self.dj_hint_en}
|
||||
ans = {"enabled": self.djbrake, "ignore": self.dj_ignore, "hint": self.dj_hint, "hint_en": self.dj_hint_en,
|
||||
"margin": self.dj_margin}
|
||||
self.broadcast({"type": "djbrake", **ans})
|
||||
return ans
|
||||
if path == "/api/dashboard" and method == "PUT":
|
||||
@@ -1327,7 +1339,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, "dj_hint": self.dj_hint, "dj_hint_en": self.dj_hint_en}
|
||||
"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}
|
||||
writer.write(f"data: {json.dumps(hello)}\n\n".encode())
|
||||
await writer.drain()
|
||||
while True:
|
||||
|
||||
+15
-2
@@ -2385,10 +2385,23 @@ 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 ? djMarginOption() : 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 djMarginOption() {
|
||||
const val = h("b", {}, `${S.djMargin} dB`);
|
||||
const input = h("input", { type: "range", min: 0, max: 12, step: 1, value: S.djMargin, "aria-label": t("Warn earlier"),
|
||||
oninput: () => { val.textContent = `${input.value} dB`; },
|
||||
onchange: async () => {
|
||||
try { S.djMargin = (await api("PUT", "/api/djbrake", { margin: +input.value })).margin; }
|
||||
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.")));
|
||||
}
|
||||
|
||||
function djHintOptions() {
|
||||
const save = async (key, on) => {
|
||||
try {
|
||||
@@ -2670,7 +2683,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.djHint = ev.dj_hint !== false; S.djHintEn = ev.dj_hint_en !== false;
|
||||
S.djbrake = !!ev.djbrake; S.djIgnore = ev.dj_ignore || {}; S.djHint = ev.dj_hint !== false; S.djHintEn = ev.dj_hint_en !== false; S.djMargin = ev.dj_margin || 0;
|
||||
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]));
|
||||
@@ -2706,7 +2719,7 @@ function connectEvents() {
|
||||
case "dashboard":
|
||||
dashRemote(ev.data); break;
|
||||
case "djbrake":
|
||||
S.djbrake = ev.enabled; S.djIgnore = ev.ignore; S.djHint = ev.hint; S.djHintEn = ev.hint_en; if (S.settings && !S.busy) render(); break;
|
||||
S.djbrake = ev.enabled; S.djIgnore = ev.ignore; S.djHint = ev.hint; S.djHintEn = ev.hint_en; S.djMargin = ev.margin; if (S.settings && !S.busy) render(); break;
|
||||
case "logo":
|
||||
S.logo = ev.data; showLogo(); if (S.settings) render(); break;
|
||||
case "muteall":
|
||||
|
||||
@@ -683,6 +683,8 @@ const DE = {
|
||||
"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",
|
||||
"Warn earlier": "Früher warnen",
|
||||
"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.": "Die Seite tut so, als käme der Limiter um diesen Wert früher, damit der DJ unter dem echten bleibt. Der Limiter selbst ändert sich nicht, und die Seite zeigt diese Einstellung nicht.",
|
||||
};
|
||||
|
||||
const DE_PATTERNS = [
|
||||
|
||||
@@ -993,3 +993,4 @@ body.dashonly .dlink { cursor: default; }
|
||||
.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; }
|
||||
.djlim input[type=range] { width: 100%; margin: 8px 0 4px; }
|
||||
Reference in new issue
Block a user