DJ Brake only shows the limiter acting; presets without a look start empty
The distance to the limiter, its bar, the warn-earlier slider and the learning are gone: the page follows the DSP's limiter bits, with one second hold. Left out limiters stay. A preset without colours and group names of its own no longer inherits the ones from the preset before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
63b3c17fb7
commit
4a6eb2f513
9 files changed
+110
-304
No files matched your search
@@ -58,12 +58,12 @@ 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
|
* **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.
|
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.
|
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
|
* **DJ Brake** (`static/djbrake.html`, `App.dj_note`, `App.dj_state`) – the only page without a login, off by default. It may only ever
|
||||||
`{on, ready, room, avg, hint}` from `/djbrake/state`: never add device data or controls there. `dj_margin` moves its limit
|
learn `{on, ready, hint}` from `/djbrake/state`: never add device data or controls there. On its own on purpose, without `app.js`.
|
||||||
down on purpose, so the page must never reveal it. On its own on purpose, without `app.js`.
|
It only follows the DSP's limiter bits. A distance to the limiter was tried and dropped: see the measurement in `PROTOCOL.md`.
|
||||||
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.
|
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
|
* **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`.
|
shows another name (the DSP has no preset IDs: same name = same look), a preset without a look starts empty. Preset files carry them as `look`.
|
||||||
* **Reset** (`App.reset_config`, `POST /api/reset`, app window only, never remote) – stops all devices before anything else and sends them nothing, then defaults from
|
* **Reset** (`App.reset_config`, `POST /api/reset`, app window only, never remote) – stops all devices before anything else and sends them nothing, then defaults from
|
||||||
a fresh `App`. Refused during an audio test or mute all, because the DSP would stay changed. Keeps `config.before-reset.json`.
|
a fresh `App`. Refused during an audio test or mute all, because the DSP would stay changed. Keeps `config.before-reset.json`.
|
||||||
* **Network search** – `App.scan_network` probes the local /24 networks on TCP 9761 (handshake + device info),
|
* **Network search** – `App.scan_network` probes the local /24 networks on TCP 9761 (handshake + device info),
|
||||||
@@ -145,9 +145,6 @@ 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)
|
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
|
* 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
|
tested against the simulator only; no command to remove a lock is known
|
||||||
* DJ Brake distance to the limiter: threshold minus output meter minus an offset: `DJ_METER_OFFSET` (measured once with
|
|
||||||
`tools/dsp_measure.py`, DSP 204 only, one output and one piece of music, see `PROTOCOL.md`), then what real hits show (`dj_cal`). Other
|
|
||||||
models start at 0 until measured. 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)
|
* 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)
|
* Pi Writer: raw write to a real SD card and first boot on a real Pi (only tested with an image file)
|
||||||
|
|
||||||
|
|||||||
@@ -34,11 +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
|
* **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,
|
* **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
|
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
|
* **DJ Brake** – optional page `/djbrake` for a tablet at the DJ booth: a big red light when a limiter acts, on for one more second
|
||||||
bar with the distance to the limiter. You can leave out limiters (a monitor, say) and make it warn a few dB before
|
afterwards. You can leave out limiters (a monitor, say). Needs no PIN and shows nothing else
|
||||||
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
|
* **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
|
* **Mixer** – faders, mute and live meters for all inputs and outputs, limiter LED on every output (status read
|
||||||
from the DSP)
|
from the DSP)
|
||||||
|
|||||||
+20
-5
@@ -45,6 +45,8 @@ class Device:
|
|||||||
self.looks: dict[str, dict] = looks or {}
|
self.looks: dict[str, dict] = looks or {}
|
||||||
self.look_name = look_name
|
self.look_name = look_name
|
||||||
self.look_dirty = False
|
self.look_dirty = False
|
||||||
|
self.recalled = "" # the preset last loaded through the app, as listed by the DSP ...
|
||||||
|
self.recalled_image = None # ... and the name its memory image showed right after
|
||||||
self.maxgain: dict[str, int] = maxgain or {} # software limit of the gain fader per channel (raw), e.g. {"out0": 260}
|
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
|
# 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
|
self.test_saved: list[int] | None = test_saved if isinstance(test_saved, list) else None
|
||||||
@@ -261,12 +263,23 @@ class Device:
|
|||||||
self.look_dirty = True
|
self.look_dirty = True
|
||||||
|
|
||||||
def sync_look(self):
|
def sync_look(self):
|
||||||
"""After reading the DSP: another preset brings its own look. One not seen yet starts with the current one."""
|
"""After reading the DSP: another preset brings its own look, one that has none starts without.
|
||||||
name = (self.state or {}).get("preset_name", "").strip()
|
Only the very first preset ever seen keeps what is there: those are the settings from before looks existed."""
|
||||||
if self.state is None or (name == self.look_name and name in self.looks):
|
if self.state is None:
|
||||||
return
|
return
|
||||||
look = self.looks.get(name)
|
name = self.state.get("preset_name", "").strip()
|
||||||
if look:
|
# that the memory image shows the new name after loading a preset is not verified on hardware: trust the list
|
||||||
|
if self.recalled:
|
||||||
|
if self.recalled_image is None:
|
||||||
|
self.recalled_image = name
|
||||||
|
if name == self.recalled_image:
|
||||||
|
name = self.recalled
|
||||||
|
else:
|
||||||
|
self.recalled = ""
|
||||||
|
if name == self.look_name and name in self.looks:
|
||||||
|
return
|
||||||
|
if self.looks:
|
||||||
|
look = self.looks.get(name, {"colors": {}, "linknames": {}})
|
||||||
self.colors, self.linknames = dict(look["colors"]), dict(look["linknames"])
|
self.colors, self.linknames = dict(look["colors"]), dict(look["linknames"])
|
||||||
self.look_name = name
|
self.look_name = name
|
||||||
self.remember_look()
|
self.remember_look()
|
||||||
@@ -274,6 +287,7 @@ class Device:
|
|||||||
async def recall_preset(self, index: int):
|
async def recall_preset(self, index: int):
|
||||||
await self._request(P.CMD_PRESET_RECALL, bytes([index + 1]), timeout=2.0)
|
await self._request(P.CMD_PRESET_RECALL, bytes([index + 1]), timeout=2.0)
|
||||||
await asyncio.sleep(0.3)
|
await asyncio.sleep(0.3)
|
||||||
|
self.recalled, self.recalled_image = (self.presets[index].strip() if index < len(self.presets) else ""), None
|
||||||
await self._load_config()
|
await self._load_config()
|
||||||
self._emit_state()
|
self._emit_state()
|
||||||
|
|
||||||
@@ -286,6 +300,7 @@ class Device:
|
|||||||
if self.state:
|
if self.state:
|
||||||
self.state["preset_name"] = name
|
self.state["preset_name"] = name
|
||||||
self.look_name = name.strip() # also when overwriting: what is stored now is what we see now
|
self.look_name = name.strip() # also when overwriting: what is stored now is what we see now
|
||||||
|
self.recalled = ""
|
||||||
self.remember_look()
|
self.remember_look()
|
||||||
self._emit_state()
|
self._emit_state()
|
||||||
|
|
||||||
|
|||||||
@@ -213,20 +213,7 @@ def rew_send_curve(body: dict):
|
|||||||
"magnitude": rew_floats(mag), "phase": rew_floats(phase)})
|
"magnitude": rew_floats(mag), "phase": rew_floats(phase)})
|
||||||
|
|
||||||
|
|
||||||
DJ_HOLD = 1.5 # s the light of /djbrake stays on after a limiter acted, so it doesn't flicker with the music
|
DJ_HOLD = 1.0 # s the light of /djbrake stays on after a limiter acted
|
||||||
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
|
|
||||||
# dB between the limiter threshold and the output meter when a limiter starts, until real hits say otherwise. Measured with
|
|
||||||
# tools/dsp_measure.py: one DSP 204 (V0104P), one output, one piece of music: 25.1 to 27.7 in five rounds, with and without
|
|
||||||
# -6 dB gain. It holds a share of the music's peaks the meter doesn't catch, so other music can differ by a few dB.
|
|
||||||
DJ_METER_OFFSET = {"204": 26.0}
|
|
||||||
DJ_LEARN_QUIET = 6.0 # s after a jump of a threshold the limiter flag teaches nothing: it was seen on for 4 s at +20 dB
|
|
||||||
|
|
||||||
|
|
||||||
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:
|
def clean_dj_ignore(data) -> dict:
|
||||||
@@ -329,15 +316,10 @@ class App:
|
|||||||
self.dashboard: dict | None = None
|
self.dashboard: dict | None = None
|
||||||
self.djbrake = False # page /djbrake for the DJ: without PIN, shows only whether a limiter acts
|
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_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 = 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_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_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_ready: dict = {} # device id -> has it an output that is 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 id -> dB the limiters sit below their threshold on the meter, learned from hits
|
|
||||||
self.dj_cal_saved = 0.0
|
|
||||||
self.dj_streams = 0
|
self.dj_streams = 0
|
||||||
self.logo = ""
|
self.logo = ""
|
||||||
# desktop app: its own window logs in with a one-time token, other devices need the PIN
|
# desktop app: its own window logs in with a one-time token, other devices need the PIN
|
||||||
@@ -389,9 +371,6 @@ class App:
|
|||||||
self.dashboard = clean_dashboard(cfg.get("dashboard"))
|
self.dashboard = clean_dashboard(cfg.get("dashboard"))
|
||||||
self.djbrake = bool(cfg.get("djbrake"))
|
self.djbrake = bool(cfg.get("djbrake"))
|
||||||
self.dj_ignore = clean_dj_ignore(cfg.get("dj_ignore"))
|
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)[:64]: 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) and ":" not in str(k)}
|
|
||||||
self.dj_hint = bool(cfg.get("dj_hint", True))
|
self.dj_hint = bool(cfg.get("dj_hint", True))
|
||||||
self.dj_hint_en = bool(cfg.get("dj_hint_en", True))
|
self.dj_hint_en = bool(cfg.get("dj_hint_en", True))
|
||||||
if "logo" in cfg:
|
if "logo" in cfg:
|
||||||
@@ -410,7 +389,7 @@ class App:
|
|||||||
return {"format": CONFIG_FORMAT, "version": 1, "exported": time.strftime("%Y-%m-%dT%H:%M:%S"),
|
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,
|
"devices": [d.config() for d in self.real_devices()], "auth": self.auth,
|
||||||
"limiter": self.limiter, "remote": self.remote, "soundfield": self.soundfield, "logo": self.logo,
|
"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, "dj_cal": self.dj_cal}
|
"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 reset_config(self):
|
async def reset_config(self):
|
||||||
"""Back to a fresh app. Only the app: the DSPs get disconnected first and receive nothing."""
|
"""Back to a fresh app. Only the app: the DSPs get disconnected first and receive nothing."""
|
||||||
@@ -506,7 +485,7 @@ class App:
|
|||||||
sessions = {k: v for k, v in self.sessions.items() if k not in self.app_sessions}
|
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,
|
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,
|
"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, "dj_margin": self.dj_margin, "dj_cal": self.dj_cal,
|
"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"],
|
"mute_all": {"active": self.mute_all["active"],
|
||||||
"restore": {k: v for k, v in self.mute_all["restore"].items() if k != "demo"}}}
|
"restore": {k: v for k, v in self.mute_all["restore"].items() if k != "demo"}}}
|
||||||
if self.lang:
|
if self.lang:
|
||||||
@@ -963,64 +942,25 @@ class App:
|
|||||||
|
|
||||||
# ------------------------------------------------------------ events
|
# ------------------------------------------------------------ events
|
||||||
|
|
||||||
def dj_offset(self, dev) -> float:
|
|
||||||
"""Learned from this DSP's hits, else what was measured on this model. The simulator has no such offset."""
|
|
||||||
if dev.id in self.dj_cal:
|
|
||||||
return self.dj_cal[dev.id]
|
|
||||||
real = "SIM" not in getattr(dev, "info", "") and not getattr(dev, "demo", False)
|
|
||||||
return DJ_METER_OFFSET.get(getattr(dev, "model_name", ""), 0.0) if real else 0.0
|
|
||||||
|
|
||||||
def dj_track(self, dev, 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)
|
|
||||||
# the moment a limiter starts is where it really sits on the meter. Later the level is what the limiter
|
|
||||||
# left of it. One DSP has one meter, so this counts for all its outputs
|
|
||||||
# only a limiter that starts by itself counts: not after a threshold jumped, up or down, and not
|
|
||||||
# while it flickers on and off in the middle of limiting
|
|
||||||
if thr > e.get("thr", thr) or thr < e.get("thr", thr) - 2:
|
|
||||||
e["jumped"] = now
|
|
||||||
e["thr"] = thr
|
|
||||||
if limit and now - e.get("last_on", -1e9) > 3 and now - e.get("jumped", -1e9) > DJ_LEARN_QUIET and e["peak"] > -70:
|
|
||||||
seen = max(-6.0, min(40.0, thr - e["peak"]))
|
|
||||||
known = self.dj_offset(dev)
|
|
||||||
self.dj_cal[dev.id] = (known * 3 + seen) / 4 if known or dev.id in self.dj_cal else seen
|
|
||||||
if limit:
|
|
||||||
e["last_on"] = now
|
|
||||||
top = thr - self.dj_offset(dev) - 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):
|
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."""
|
"""Keeps the state of the /djbrake page. A muted output is not watched: nobody hears it."""
|
||||||
dev = self.devices.get(ev["device"])
|
dev = self.devices.get(ev["device"])
|
||||||
if not dev or not dev.state:
|
if not dev or not dev.state:
|
||||||
return
|
return
|
||||||
now = time.monotonic() if now is None else now
|
now = time.monotonic() if now is None else now
|
||||||
room, avg, ignore = False, None, self.dj_ignore.get(dev.id, ())
|
watched, ignore = False, self.dj_ignore.get(dev.id, ())
|
||||||
for i, (level, limit) in enumerate(zip(ev["out"], ev["limit"])):
|
for i, limit in enumerate(ev["limit"]):
|
||||||
ch, key = dev.state["outputs"][i], f"{dev.id}:{i}"
|
if i not in ignore and not dev.state["outputs"][i]["mute"]:
|
||||||
if i in ignore or ch["mute"]:
|
watched = True
|
||||||
self.dj_env.pop(key, None)
|
if limit:
|
||||||
continue
|
self.dj_hit = now
|
||||||
left, mean, warn = self.dj_track(dev, key, level, limit, ch["limit"]["threshold"], now)
|
self.dj_ready[dev.id] = watched
|
||||||
if warn:
|
|
||||||
self.dj_hit = now
|
def dj_state(self, now: float) -> dict:
|
||||||
room = left if room is False or room is None else room if left is None else min(room, left)
|
"""All /djbrake may know, without a login. Nothing else leaves here."""
|
||||||
avg = mean if avg is None else avg if mean is None else min(avg, mean)
|
return {"on": now - self.dj_hit < DJ_HOLD,
|
||||||
self.dj_rooms[dev.id], self.dj_avgs[dev.id] = room, avg
|
"ready": any(self.dj_ready.get(d.id) for d in self.devices.values() if d.status == "online"),
|
||||||
if self.dj_cal and now - self.dj_cal_saved > 60: # an SD card is not for writing with every beat
|
"hint": ("en" if self.dj_hint_en else "auto") if self.dj_hint else None}
|
||||||
self.dj_cal_saved = now
|
|
||||||
self.save()
|
|
||||||
|
|
||||||
def broadcast(self, ev: dict):
|
def broadcast(self, ev: dict):
|
||||||
if ev["type"] == "meters":
|
if ev["type"] == "meters":
|
||||||
@@ -1057,17 +997,12 @@ class App:
|
|||||||
self.djbrake = bool(body["enabled"])
|
self.djbrake = bool(body["enabled"])
|
||||||
if "ignore" in body:
|
if "ignore" in body:
|
||||||
self.dj_ignore = clean_dj_ignore(body["ignore"])
|
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:
|
if "hint" in body:
|
||||||
self.dj_hint = bool(body["hint"])
|
self.dj_hint = bool(body["hint"])
|
||||||
if "hint_en" in body:
|
if "hint_en" in body:
|
||||||
self.dj_hint_en = bool(body["hint_en"])
|
self.dj_hint_en = bool(body["hint_en"])
|
||||||
self.save()
|
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})
|
self.broadcast({"type": "djbrake", **ans})
|
||||||
return ans
|
return ans
|
||||||
if path == "/api/dashboard" and method == "PUT":
|
if path == "/api/dashboard" and method == "PUT":
|
||||||
@@ -1423,7 +1358,6 @@ class App:
|
|||||||
await self.respond(writer, 200, f.read_bytes(), ctype)
|
await self.respond(writer, 200, f.read_bytes(), ctype)
|
||||||
|
|
||||||
async def dj_stream(self, writer):
|
async def dj_stream(self, writer):
|
||||||
"""All /djbrake may know, without a login: is a limiter acting and how far away is it. Nothing else leaves here."""
|
|
||||||
if not self.djbrake or self.dj_streams >= 20:
|
if not self.djbrake or self.dj_streams >= 20:
|
||||||
await self.respond(writer, 404, b"not found", "text/plain")
|
await self.respond(writer, 404, b"not found", "text/plain")
|
||||||
return
|
return
|
||||||
@@ -1434,14 +1368,7 @@ class App:
|
|||||||
try:
|
try:
|
||||||
while self.djbrake:
|
while self.djbrake:
|
||||||
now = time.monotonic()
|
now = time.monotonic()
|
||||||
online = [d.id for d in self.devices.values() if d.status == "online"]
|
state = self.dj_state(now)
|
||||||
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:
|
if state != last:
|
||||||
writer.write(f"data: {json.dumps(state)}\n\n".encode())
|
writer.write(f"data: {json.dumps(state)}\n\n".encode())
|
||||||
last, idle = state, 0.0
|
last, idle = state, 0.0
|
||||||
@@ -1462,7 +1389,7 @@ class App:
|
|||||||
try:
|
try:
|
||||||
hello = {"type": "hello", "devices": [d.snapshot() for d in self.devices.values()], "limiter": self.limiter,
|
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,
|
"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, "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}
|
||||||
writer.write(f"data: {json.dumps(hello)}\n\n".encode())
|
writer.write(f"data: {json.dumps(hello)}\n\n".encode())
|
||||||
await writer.drain()
|
await writer.drain()
|
||||||
while True:
|
while True:
|
||||||
|
|||||||
+3
-21
@@ -2422,26 +2422,8 @@ function djBrakeCard() {
|
|||||||
try { await navigator.clipboard.writeText(url); toast(t("Address copied")); } catch { toast(url); }
|
try { await navigator.clipboard.writeText(url); toast(t("Address copied")); } catch { toast(url); }
|
||||||
} }, t("Copy")))) : null,
|
} }, t("Copy")))) : null,
|
||||||
S.djbrake && reachable ? djLimiters() : null,
|
S.djbrake && reachable ? djLimiters() : null,
|
||||||
S.djbrake && reachable ? djMarginOption() : null,
|
|
||||||
S.djbrake && reachable ? djHintOptions() : null,
|
S.djbrake && reachable ? djHintOptions() : null,
|
||||||
S.djbrake && reachable ? 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);
|
S.djbrake && reachable ? h("p", { class: "info" }, t("Anyone in your network can open it without a PIN. It shows only the light 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.")),
|
|
||||||
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() {
|
function djHintOptions() {
|
||||||
@@ -2726,7 +2708,7 @@ function connectEvents() {
|
|||||||
if (ev.muteall) { S.muteAll = ev.muteall.active; showMuteAll(); }
|
if (ev.muteall) { S.muteAll = ev.muteall.active; showMuteAll(); }
|
||||||
if (ev.soundfield) S.sf = ev.soundfield;
|
if (ev.soundfield) S.sf = ev.soundfield;
|
||||||
if ("dashboard" in ev) S.dash = ev.dashboard && ev.dashboard.modules;
|
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.djMargin = ev.dj_margin || 0;
|
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 ("logo" in ev) { S.logo = ev.logo; showLogo(); }
|
||||||
if (S.demo.enabled && S.devices.demo && !S.devices[S.cur]?.demo) S.cur = "demo";
|
if (S.demo.enabled && S.devices.demo && !S.devices[S.cur]?.demo) S.cur = "demo";
|
||||||
S.order.forEach(id => maybeAskUnlock(S.devices[id]));
|
S.order.forEach(id => maybeAskUnlock(S.devices[id]));
|
||||||
@@ -2764,7 +2746,7 @@ function connectEvents() {
|
|||||||
case "reset":
|
case "reset":
|
||||||
appWasReset(); break;
|
appWasReset(); break;
|
||||||
case "djbrake":
|
case "djbrake":
|
||||||
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;
|
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":
|
case "logo":
|
||||||
S.logo = ev.data; showLogo(); if (S.settings) render(); break;
|
S.logo = ev.data; showLogo(); if (S.settings) render(); break;
|
||||||
case "muteall":
|
case "muteall":
|
||||||
|
|||||||
+18
-70
@@ -10,45 +10,26 @@
|
|||||||
<style>
|
<style>
|
||||||
html { touch-action: manipulation; }
|
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; }
|
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; }
|
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 */
|
/* on at once, off quickly: the server already holds it for a second after the limiter */
|
||||||
#wash, #halo, #core { transition: opacity .7s ease-out; opacity: 0; }
|
#wash, #halo, #core { transition: opacity .25s ease-out; opacity: 0; }
|
||||||
body.on #wash, body.on #halo, body.on #core { transition: opacity .09s ease-out; opacity: 1; }
|
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%); }
|
#wash { position: fixed; inset: 0; background: radial-gradient(circle at 50% 46%, #6e0a0a 0%, #2a0505 42%, #050608 78%); }
|
||||||
#lamp { position: relative; width: 52vmin; height: 52vmin; display: grid; place-items: center; }
|
#lamp { position: relative; width: 64vmin; height: 64vmin; display: grid; place-items: center; }
|
||||||
#halo, #core, #glass, #ring { position: absolute; inset: 0; border-radius: 50%; }
|
#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; }
|
#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; }
|
#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); }
|
#halo { inset: -7vmin; background: radial-gradient(circle, #ff2a1f 44%, #ff2a1f00 70%); filter: blur(3vmin); }
|
||||||
#ring { border: .5vmin solid #ff5a4c; opacity: 0; pointer-events: none; }
|
#ring { border: .5vmin solid #ff5a4c; opacity: 0; pointer-events: none; }
|
||||||
#word { position: relative; font-size: 8.6vmin; font-weight: 800; letter-spacing: .03em; line-height: 1; color: #4b5260; transition: color .5s; }
|
#word { position: relative; font-size: 10.5vmin; font-weight: 800; letter-spacing: .03em; line-height: 1; color: #4b5260; transition: color .25s; }
|
||||||
#sub { position: relative; min-height: 1.3em; font-size: 4.4vmin; font-weight: 500; color: #8b93a1; transition: color .5s; font-variant-numeric: tabular-nums; }
|
#sub { position: relative; min-height: 1.3em; font-size: 4.4vmin; font-weight: 500; color: #8b93a1; transition: color .25s; }
|
||||||
|
#hint { position: relative; max-width: 88vw; font-size: 2.8vmin; color: #6b7280; transition: color .25s; }
|
||||||
/* distance to the limiter: the colours belong to the scale, the dark cover shows what is still left */
|
|
||||||
#gauge { position: relative; width: min(88vw, 130vmin); }
|
|
||||||
#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; }
|
|
||||||
#scale span:first-child { transform: none; }
|
|
||||||
#scale span:last-child { transform: translateX(-100%); }
|
|
||||||
body.on #scale { color: #ffc9c4; }
|
|
||||||
body.on #word { color: #fff; transition: color .09s; }
|
body.on #word { color: #fff; transition: color .09s; }
|
||||||
body.on #sub { color: #ffd9d4; 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; }
|
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 */
|
/* 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 #halo { animation: breathe 2.2s ease-in-out infinite; }
|
||||||
body.on #ring { animation: ripple .9s cubic-bezier(.2, .6, .3, 1); }
|
body.on #ring { animation: ripple .9s cubic-bezier(.2, .6, .3, 1); }
|
||||||
@@ -66,68 +47,35 @@
|
|||||||
<div id="core"></div>
|
<div id="core"></div>
|
||||||
<div id="word">—</div>
|
<div id="word">—</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="gauge">
|
|
||||||
<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>
|
<div id="sub"></div>
|
||||||
<div id="hint"></div>
|
<div id="hint"></div>
|
||||||
<script>
|
<script>
|
||||||
// Red light for the DJ: comes on while a limiter of a connected DSP is working.
|
// Red light for the DJ: comes on when a limiter of a connected DSP acts.
|
||||||
// On its own on purpose: this page needs no PIN and gets nothing but this one state from the server.
|
// On its own on purpose: this page needs no PIN and gets nothing but this one state from the server.
|
||||||
(function () {
|
(function () {
|
||||||
var de = /^de/i.test(navigator.language || "");
|
var de = /^de/i.test(navigator.language || "");
|
||||||
var text = de
|
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", close: "KNAPP" }
|
? { on: "LIMITER", more: "Mehr Gas bringt nichts", lost: "Keine Verbindung", none: "Kein Limiter überwacht" }
|
||||||
: { 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" };
|
: { on: "LIMITER", more: "More gain won't help", lost: "No connection", none: "No limiter being watched" };
|
||||||
var word = document.getElementById("word"), sub = document.getElementById("sub"), cover = document.getElementById("cover"), peak = document.getElementById("peak");
|
var word = document.getElementById("word"), sub = document.getElementById("sub"), hint = document.getElementById("hint");
|
||||||
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 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";
|
document.documentElement.lang = de ? "de" : "en";
|
||||||
|
|
||||||
// rises at once, falls slowly, like a level meter
|
function show(on, main, small) {
|
||||||
function bar(room) {
|
document.body.className = on ? "on" : "";
|
||||||
var next = room == null ? 100 : Math.min(100, room / RANGE * 100);
|
|
||||||
cover.style.transition = "width " + (next < gap ? ".08s" : ".6s") + " ease-out";
|
|
||||||
cover.style.width = next + "%";
|
|
||||||
gap = next;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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;
|
word.textContent = main;
|
||||||
sub.textContent = small;
|
sub.textContent = small;
|
||||||
}
|
}
|
||||||
|
|
||||||
function draw() {
|
|
||||||
var s = state;
|
|
||||||
if (!s) return;
|
|
||||||
if (s.on) show(true, text.on, text.more);
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
var es = new EventSource("/djbrake/state");
|
var es = new EventSource("/djbrake/state");
|
||||||
es.onmessage = function (e) {
|
es.onmessage = function (e) {
|
||||||
var s = JSON.parse(e.data), was = state && state.on;
|
var s = JSON.parse(e.data);
|
||||||
state = s;
|
|
||||||
bar(s.avg);
|
|
||||||
mark(s.on ? 0 : s.room);
|
|
||||||
hint.textContent = !s.hint ? "" : s.hint === "auto" && de ? notes.de : notes.en;
|
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) show(true, text.on, text.more);
|
||||||
if (s.on !== was || !s.ready) draw();
|
else if (s.ready) show(false, "OK", "");
|
||||||
|
else show(false, "—", text.none);
|
||||||
};
|
};
|
||||||
es.onerror = function () { state = null; bar(null); mark(null); show(false, "—", text.lost); };
|
es.onerror = function () { 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);
|
|
||||||
|
|
||||||
// keep the screen on where the browser allows it
|
// keep the screen on where the browser allows it
|
||||||
function awake() { if (navigator.wakeLock) navigator.wakeLock.request("screen").catch(function () {}); }
|
function awake() { if (navigator.wakeLock) navigator.wakeLock.request("screen").catch(function () {}); }
|
||||||
|
|||||||
+1
-6
@@ -677,12 +677,9 @@ const DE = {
|
|||||||
"Share the page /djbrake": "Seite /djbrake freigeben",
|
"Share the page /djbrake": "Seite /djbrake freigeben",
|
||||||
"Address copied": "Adresse kopiert",
|
"Address copied": "Adresse kopiert",
|
||||||
"Only reachable while remote access is on.": "Nur erreichbar, solange der Fernzugriff an ist.",
|
"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.",
|
|
||||||
"Connect a DSP to choose.": "Verbinde einen DSP, um auszuwä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",
|
"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",
|
"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.",
|
|
||||||
"Overview": "Überblick",
|
"Overview": "Überblick",
|
||||||
"Correcting": "Korrigieren",
|
"Correcting": "Korrigieren",
|
||||||
"Comparing": "Vergleichen",
|
"Comparing": "Vergleichen",
|
||||||
@@ -702,9 +699,6 @@ const DE = {
|
|||||||
"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.",
|
"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",
|
"Leave out these limiters": "Diese Limiter ausnehmen",
|
||||||
"All others count. Muted outputs never count.": "Alle anderen zählen. Stummgeschaltete Ausgänge zählen nie.",
|
"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.",
|
"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",
|
"Widget settings": "Widget-Einstellungen",
|
||||||
"Reset all app settings…": "Alle App-Einstellungen zurücksetzen…",
|
"Reset all app settings…": "Alle App-Einstellungen zurücksetzen…",
|
||||||
@@ -727,6 +721,7 @@ const DE = {
|
|||||||
"All settings in the DSPs": "Alle Einstellungen in den DSPs",
|
"All settings in the DSPs": "Alle Einstellungen in den DSPs",
|
||||||
"Presets in the DSPs": "Presets in den DSPs",
|
"Presets in the DSPs": "Presets in den DSPs",
|
||||||
"A copy of the old app settings": "Eine Kopie der alten App-Einstellungen",
|
"A copy of the old app settings": "Eine Kopie der alten App-Einstellungen",
|
||||||
|
"Anyone in your network can open it without a PIN. It shows only the light and changes nothing.": "Jeder in deinem Netzwerk kann sie ohne PIN öffnen. Sie zeigt nur das Licht und ändert nichts.",
|
||||||
};
|
};
|
||||||
|
|
||||||
const DE_PATTERNS = [
|
const DE_PATTERNS = [
|
||||||
|
|||||||
@@ -1012,7 +1012,6 @@ body.dashonly .dlink { cursor: default; }
|
|||||||
.djch.out small { color: inherit; }
|
.djch.out small { color: inherit; }
|
||||||
.djlim label.chk { display: flex; align-items: flex-start; gap: 8px; margin-top: 8px; }
|
.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 label.chk input { flex: none; margin: 3px 0 0; }
|
||||||
.djlim input[type=range] { width: 100%; margin: 8px 0 4px; }
|
|
||||||
.row.djurl button.small { flex: 0 0 auto; width: auto; padding-inline: 14px; }
|
.row.djurl button.small { flex: 0 0 auto; width: auto; padding-inline: 14px; }
|
||||||
.row.djurl code { flex: 1 1 auto; }
|
.row.djurl code { flex: 1 1 auto; }
|
||||||
/* ---- UI pass: controls of one kind line up and have one size */
|
/* ---- UI pass: controls of one kind line up and have one size */
|
||||||
@@ -1044,7 +1043,6 @@ 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; } }
|
@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; }
|
.docui { padding: 0 4px; }
|
||||||
html { touch-action: pan-x pan-y; }
|
html { touch-action: pan-x pan-y; }
|
||||||
.djlim > button.small { margin-top: 8px; }
|
|
||||||
.dialog:has(> .resetbody) { width: min(520px, 100%); padding: 22px; }
|
.dialog:has(> .resetbody) { width: min(520px, 100%); padding: 22px; }
|
||||||
.dialog:has(> .resetbody) > h2 { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 19px; }
|
.dialog:has(> .resetbody) > h2 { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 19px; }
|
||||||
.dialog:has(> .resetbody) > h2::before { content: "!"; flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-size: 19px; font-weight: 800;
|
.dialog:has(> .resetbody) > h2::before { content: "!"; flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-size: 19px; font-weight: 800;
|
||||||
|
|||||||
+42
-95
@@ -206,103 +206,35 @@ def test_fir_model():
|
|||||||
assert st["outputs"][0]["fir"]["type"] == 1 and st["outputs"][0]["fir"]["name"] == "ABC"
|
assert st["outputs"][0]["fir"]["type"] == 1 and st["outputs"][0]["fir"]["name"] == "ABC"
|
||||||
|
|
||||||
|
|
||||||
def test_dj_brake_follows_music():
|
def test_dj_brake_light():
|
||||||
import server, tempfile
|
import server, tempfile
|
||||||
from types import SimpleNamespace
|
from types import SimpleNamespace
|
||||||
with tempfile.TemporaryDirectory() as d:
|
with tempfile.TemporaryDirectory() as d:
|
||||||
app = server.App(Path(d) / "c.json")
|
app = server.App(Path(d) / "c.json")
|
||||||
thr0 = 180 # threshold 0 dB
|
out = {"mute": False}
|
||||||
dev = SimpleNamespace(id="x", demo=True, state={"outputs": [{"mute": False, "limit": {"threshold": thr0}}]}, status="online")
|
app.devices["x"] = SimpleNamespace(id="x", demo=True, state={"outputs": [out, {"mute": False}]}, status="online")
|
||||||
app.devices["x"] = dev
|
note = lambda t, *limit: app.dj_note({"device": "x", "out": [0.1, 0.1], "limit": list(limit)}, now=t)
|
||||||
lv = lambda db: 10 ** (db / 20)
|
note(10.0, False, False)
|
||||||
note = lambda db, t, limit=False: app.dj_note({"device": "x", "out": [lv(db)], "limit": [limit]}, now=t)
|
assert app.dj_state(10.0)["ready"] and not app.dj_state(10.0)["on"]
|
||||||
# the peak stays while the music dips, then falls slowly
|
# on with the limiter, and one more second afterwards
|
||||||
note(-10, 100.0)
|
note(100.0, True, False)
|
||||||
note(-30, 100.5)
|
assert app.dj_state(100.0)["on"] and app.dj_state(100.9)["on"] and not app.dj_state(101.1)["on"]
|
||||||
assert abs(app.dj_rooms["x"] - 10) < 0.01
|
# a limiter left out doesn't count, the others do
|
||||||
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"] - 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]}
|
app.dj_ignore = {"x": [0]}
|
||||||
note(-1, 160.0, True)
|
note(200.0, True, False)
|
||||||
assert app.dj_hit == 110.0 and app.dj_rooms["x"] is False
|
assert not app.dj_state(200.0)["on"]
|
||||||
# what was learned survives a restart
|
note(210.0, False, True)
|
||||||
app.save()
|
assert app.dj_state(210.0)["on"]
|
||||||
again = server.App(Path(d) / "c.json")
|
# neither does a muted output, and with nothing left to watch the page says so
|
||||||
again.load()
|
app.dj_ignore = {}
|
||||||
assert abs(again.dj_cal["x"] - app.dj_cal["x"]) < 0.01
|
out["mute"] = True
|
||||||
|
note(300.0, True, False)
|
||||||
|
assert not app.dj_state(300.0)["on"] and app.dj_state(300.0)["ready"]
|
||||||
def test_dj_brake_one_hit_counts_for_the_whole_dsp():
|
|
||||||
import server, tempfile
|
|
||||||
from types import SimpleNamespace
|
|
||||||
with tempfile.TemporaryDirectory() as d:
|
|
||||||
app = server.App(Path(d) / "c.json")
|
|
||||||
out = {"mute": False, "limit": {"threshold": 180}}
|
|
||||||
app.devices["x"] = SimpleNamespace(id="x", demo=True, state={"outputs": [dict(out), dict(out)]}, status="online")
|
|
||||||
lv = lambda db: 10 ** (db / 20)
|
|
||||||
app.dj_ignore = {"x": [1]}
|
app.dj_ignore = {"x": [1]}
|
||||||
app.dj_note({"device": "x", "out": [lv(-12), lv(-40)], "limit": [True, False]}, now=100.0)
|
note(310.0, True, True)
|
||||||
assert app.dj_cal == {"x": 12.0}
|
assert not app.dj_state(310.0)["on"] and not app.dj_state(310.0)["ready"]
|
||||||
# the level the limiter leaves over while it keeps acting teaches nothing
|
# only these three things leave here
|
||||||
app.dj_note({"device": "x", "out": [lv(-20), lv(-40)], "limit": [True, False]}, now=100.2)
|
assert set(app.dj_state(1.0)) == {"on", "ready", "hint"}
|
||||||
assert app.dj_cal == {"x": 12.0}
|
|
||||||
# another output of this DSP has never limited, its distance is true anyway
|
|
||||||
app.dj_ignore = {"x": [0]}
|
|
||||||
app.dj_note({"device": "x", "out": [lv(-40), lv(-18)], "limit": [False, False]}, now=101.0)
|
|
||||||
assert abs(app.dj_rooms["x"] - 6) < 0.01
|
|
||||||
|
|
||||||
|
|
||||||
def test_dj_brake_measured_offset():
|
|
||||||
import server, tempfile
|
|
||||||
from types import SimpleNamespace
|
|
||||||
lv = lambda db: 10 ** (db / 20)
|
|
||||||
with tempfile.TemporaryDirectory() as d:
|
|
||||||
app = server.App(Path(d) / "c.json")
|
|
||||||
app.save = lambda: None
|
|
||||||
out = {"mute": False, "limit": {"threshold": 220}} # +20 dB
|
|
||||||
dev = SimpleNamespace(id="x", demo=False, model_name="204", info="DSP204 V0104P", state={"outputs": [out]}, status="online")
|
|
||||||
app.devices["x"] = dev
|
|
||||||
note = lambda db, t, limit=False: app.dj_note({"device": "x", "out": [lv(db)], "limit": [limit]}, now=t)
|
|
||||||
# measured: at +20 dB and a meter of -25 the limiter is about 19 dB away, before any hit
|
|
||||||
note(-25, 100.0)
|
|
||||||
assert app.dj_cal == {} and abs(app.dj_rooms["x"] - 19) < 0.01
|
|
||||||
# the flag right after raising the threshold teaches nothing: seen on real hardware
|
|
||||||
out["limit"]["threshold"] = 184
|
|
||||||
note(-25, 110.0)
|
|
||||||
out["limit"]["threshold"] = 220
|
|
||||||
note(-25, 111.0, True)
|
|
||||||
assert app.dj_cal == {}
|
|
||||||
note(-25, 111.2)
|
|
||||||
# a real hit moves the offset, it doesn't replace it
|
|
||||||
out["limit"]["threshold"] = 180
|
|
||||||
note(-20, 130.0)
|
|
||||||
note(-20, 130.2, True)
|
|
||||||
assert app.dj_cal == {} # that threshold has only just jumped
|
|
||||||
note(-20, 140.0)
|
|
||||||
note(-20, 140.2, True)
|
|
||||||
assert abs(app.dj_cal["x"] - 24.5) < 0.01
|
|
||||||
# it flickers: nothing new. And a jump of the threshold down teaches nothing either
|
|
||||||
note(-30, 140.4)
|
|
||||||
note(-30, 140.6, True)
|
|
||||||
assert abs(app.dj_cal["x"] - 24.5) < 0.01
|
|
||||||
out["limit"]["threshold"] = 160
|
|
||||||
note(-30, 150.0)
|
|
||||||
note(-30, 150.2, True)
|
|
||||||
assert abs(app.dj_cal["x"] - 24.5) < 0.01
|
|
||||||
with tempfile.TemporaryDirectory() as d:
|
|
||||||
app = server.App(Path(d) / "c.json")
|
|
||||||
for dev in (SimpleNamespace(id="s", demo=False, model_name="204", info="DSP204 V010 SIM"), SimpleNamespace(id="d", demo=True, model_name="204", info=""),
|
|
||||||
SimpleNamespace(id="o", demo=False, model_name="408", info="DSP408 V0104P")):
|
|
||||||
assert app.dj_offset(dev) == 0.0
|
|
||||||
|
|
||||||
|
|
||||||
def test_reset_config():
|
def test_reset_config():
|
||||||
@@ -312,7 +244,7 @@ def test_reset_config():
|
|||||||
app = server.App(path)
|
app = server.App(path)
|
||||||
app.load()
|
app.load()
|
||||||
app.set_pin("9999", save=False)
|
app.set_pin("9999", save=False)
|
||||||
app.djbrake, app.lang, app.dj_cal = True, "de", {"x:0": 5.0}
|
app.djbrake, app.lang, app.dj_ignore = True, "de", {"x": [0]}
|
||||||
app.dashboard = {"modules": []}
|
app.dashboard = {"modules": []}
|
||||||
app.app_token = "t"
|
app.app_token = "t"
|
||||||
app.app_sessions, app.sessions = {"a"}, {"a": 9e12, "b": 9e12}
|
app.app_sessions, app.sessions = {"a"}, {"a": 9e12, "b": 9e12}
|
||||||
@@ -326,7 +258,7 @@ def test_reset_config():
|
|||||||
app.mute_all["active"] = False
|
app.mute_all["active"] = False
|
||||||
app.remote["enabled"] = False
|
app.remote["enabled"] = False
|
||||||
asyncio.run(app.reset_config())
|
asyncio.run(app.reset_config())
|
||||||
assert not app.djbrake and app.lang == "" and app.dashboard is None and app.dj_cal == {} and app.check_pin("1234")
|
assert not app.djbrake and app.lang == "" and app.dashboard is None and app.dj_ignore == {} and app.check_pin("1234")
|
||||||
assert app.app_token == "t" and app.app_sessions == {"a"} and set(app.sessions) == {"a"}
|
assert app.app_token == "t" and app.app_sessions == {"a"} and set(app.sessions) == {"a"}
|
||||||
assert json.loads(path.with_name("config.before-reset.json").read_text())["djbrake"] is True
|
assert json.loads(path.with_name("config.before-reset.json").read_text())["djbrake"] is True
|
||||||
|
|
||||||
@@ -337,9 +269,9 @@ def test_looks_follow_presets():
|
|||||||
d.state = {"preset_name": "A"}
|
d.state = {"preset_name": "A"}
|
||||||
d.colors, d.linknames = {"out0": "#111111"}, {"out:0,1": "Tops"}
|
d.colors, d.linknames = {"out0": "#111111"}, {"out:0,1": "Tops"}
|
||||||
d.sync_look()
|
d.sync_look()
|
||||||
d.state = {"preset_name": "B"} # not seen yet: starts with what is there, then goes its own way
|
d.state = {"preset_name": "B"} # has no look of its own: starts without
|
||||||
d.sync_look()
|
d.sync_look()
|
||||||
assert d.colors == {"out0": "#111111"}
|
assert d.colors == {} and d.linknames == {}
|
||||||
d.colors, d.linknames = {"out0": "#222222"}, {"out:0,1": "Subs"}
|
d.colors, d.linknames = {"out0": "#222222"}, {"out:0,1": "Subs"}
|
||||||
d.remember_look()
|
d.remember_look()
|
||||||
d.state = {"preset_name": "A"}
|
d.state = {"preset_name": "A"}
|
||||||
@@ -349,6 +281,21 @@ def test_looks_follow_presets():
|
|||||||
d.sync_look()
|
d.sync_look()
|
||||||
assert d.colors == {"out0": "#222222"} and d.linknames == {"out:0,1": "Subs"}
|
assert d.colors == {"out0": "#222222"} and d.linknames == {"out:0,1": "Subs"}
|
||||||
assert "looks" not in d.snapshot()
|
assert "looks" not in d.snapshot()
|
||||||
|
# the first preset ever seen keeps what is there
|
||||||
|
e = Device("y", "y", "127.0.0.1", colors={"in0": "#333333"})
|
||||||
|
e.state = {"preset_name": "First"}
|
||||||
|
e.sync_look()
|
||||||
|
assert e.colors == {"in0": "#333333"} and "First" in e.looks
|
||||||
|
# a DSP whose memory image keeps the old name after loading a preset: the listed name counts
|
||||||
|
e.state = {"preset_name": "First"}
|
||||||
|
e.recalled, e.recalled_image = "Other", None
|
||||||
|
e.sync_look()
|
||||||
|
assert e.look_name == "Other" and e.colors == {}
|
||||||
|
e.sync_look()
|
||||||
|
assert e.look_name == "Other"
|
||||||
|
e.state = {"preset_name": "Third"} # loaded on the device itself
|
||||||
|
e.sync_look()
|
||||||
|
assert e.look_name == "Third" and e.recalled == ""
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
Reference in new issue
Block a user