Compare commits

...
12 Commits
Author SHA1 Message Date
GivouandClaude Opus 5.5 43def4480c Dashboard levels: much more transparent group tiles
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 17:43:19 +01:00
GivouandClaude Opus 5.5 24674fb8c0 Dashboard levels: link groups as a soft tile behind the meters
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 17:42:06 +01:00
GivouandClaude Opus 5.5 682e734257 Dashboard levels: link groups as a coloured pill under the channel numbers
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 17:40:45 +01:00
GivouandClaude Opus 5.5 967191f2f7 Dashboard levels: group line only as wide as its meters
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 17:36:37 +01:00
GivouandClaude Opus 5.5 936d7f64a9 Dashboard levels: link groups as a thin line with a small name
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 17:34:40 +01:00
GivouandClaude Opus 5.5 b82a6b90c6 Dashboard: resize modules by mouse, overlays, link groups and colours in levels; read-only switch on phones
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 17:33:15 +01:00
GivouandClaude Opus 5.5 2ea9fa32bc Dashboard: modular read-only overview page, stored in the config; UI cleanup
Modules are added and moved by drag and drop. Cleanup: no sideways jump between
pages, mixer strips stay together with few channels, equal card heights, compact
limiter cards without an amplifier, wider test meters, scrollable bottom bar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 17:23:36 +01:00
GivouandClaude Opus 5.5 5597fae3f3 FIR DSP 408: own memory layout and FIR tab (filters, coefficient files, tap budget)
Layout and commands derived from the behaviour of its control software, tested
against the simulator only. No GEQ on this model; dynamic EQs are left untouched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 17:11:46 +01:00
GivouandClaude Opus 5.5 f7d5e22bb0 Beta models: full function once added, only a note in the add-device form
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 16:50:50 +01:00
GivouandClaude Opus 5.5 86ee492ec3 Beta models DSP 206 and FIR DSP 408 (without the FIR filters), read-only until allowed
Never tested on real hardware, so they are only selectable by hand and send no
changes until the user has compared the shown values with the DSP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 16:47:56 +01:00
GivouandClaude Opus 5.5 0a1f282c63 Edit existing link groups: add or remove channels, dissolve below two
A channel added in front of the group first gets the group's settings, so the
DSP (which copies from the first channel) keeps them. The group name moves along.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 00:13:34 +01:00
GivouandClaude Opus 5.5 4b33fc2665 Names for link groups, shown as coloured brackets above the mixer strips
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 00:05:55 +01:00
15 changed files with 1492 additions and 84 deletions

No files matched your search

+16
View File
@@ -45,6 +45,16 @@ pi_writer.py → pi_image.py (cloud-init SD card, installs server.py as a system
* **Max level** – `Device.maxgain` (raw gain per channel, app-side) and `Device.gain_cap`: every gain the server sets
(API, test fader, copy) is capped at max(limit, current value), so a DSP turned up on the device can only go down
until it is below the limit again. The client mirrors this in `gainCap` (faders, sliders, `setParam`).
* **Link group names** – `Device.linknames` (app-side, like the colours), keyed by kind and members (`"out:0,1"`), so a
changed group starts without a name. The mixer draws them as brackets in row 1 of the `.strips` grid (`linkBands`).
* **FIR tab** (`viewFir`, only `d.fir`) – outputs: `0x4B` type/window/cut-offs/taps index, the DSP calculates the filter;
the curve is the app's own windowed sinc. Files: `Device.upload_fir` (`0x5B` name, `0x4E` packets of 12 floats). The DSP
can't send coefficients back, so the curve of a file only exists in the session (`S.firCoef`).
* **Dashboard** (`static/dashboard.js`, stored as `dashboard` in `config.json`, API `/api/dashboard`, `clean_dashboard`) –
grid of 12 columns and rows of 40 px, modules in `DASH_MODULES` with `body(m, d)` and `min`/`max` `[columns, rows]`. Must stay read-only: no `setParam` or POST to a device
there, browsing (channel, band) is session state (`dashBrowse`). A new module type also goes into `DASH_TYPES` in `server.py`.
* **Read-only switch** (`S.guard`, `viewOnly()` in `app.js`) – web UI on phones and touch devices starts read-only, reusing
the swallowing of the app lock. A safety catch per browser tab only: not stored, the server doesn't know it. Mute all stays.
* **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
@@ -107,6 +117,12 @@ and the DSP's own mirroring inside groups, limiter-active bit mask, preset impor
Not verified yet – ask for a log (`python server.py -v`) from real hardware before changing protocol code here:
* **Beta models** `206` and `408fir` – never seen on real hardware. Never auto-detected (`detect_model`, a FIR device
must not pass as a 408); the only hint is the note in the add-device form, afterwards they work like the others.
`206`: same protocol and layout as the 204/408 are only assumed (no control software looked at), also the USB ID.
`408fir`: own layout and commands derived from its control software (`Model.fir`, `_parse_fir`, `_fir_command`), simulator
only. Not done: dynamic EQs (kept untouched), saving coefficients into a preset slot of the DSP (`0x5A`, format
not worked out), where it keeps the test signal (the app remembers it). Ask testers for a preset export and a log.
* **DSP 408 on real hardware** (layout and frames match published captures, limiter bits for Out 5–8 assumed)
* USB on Windows and Linux against a real DSP (only tested against a fake HID device)
* Where the PEQ bypass flag lives in the memory image; format of the set-command acknowledgement; where the number
+28
View File
@@ -186,3 +186,31 @@ Where the PEQ bypass flag is stored in the image is not known yet.
* Send: report ID `00` + one complete frame (`10 02 … 10 03 CHK`), zero-padded to the output report length.
* Receive: every input report holds exactly one frame starting at byte 0, length = `LEN + 8`, then padding.
* The frames are identical to TCP; the longest (config chunk, 50 data bytes) is 60 bytes and fits a 64-byte report.
## FIR DSP 408 (unverified)
Derived from the behaviour of its control software, not yet seen on a device. Same frames; device info starts with
`FIR408`. The memory image has 1573 bytes (32 chunks) and its own layout:
| Offset | Content |
|---|---|
| `0x010` + 138·n | Input: name 8, gate 4×u16, 3 dynamic EQs of 16 bytes, 8 PEQ bands of 6 bytes, compressor (ratio, attack, release, knee, threshold, EQ frequency as u16, 2 bytes), FIR taps u16, FIR bypass u16, gain, polarity, delay, link |
| `0x238` + 108·n | Output: name 8, matrix u16, mix 4×u16, u16, HP frequency u16, LP frequency u16, HP slope, LP slope, HP bypass, LP bypass (bytes), FIR type, window (bytes), low Hz, high Hz, taps index (u16), 9 PEQ bands, limiter (ratio, attack, release, knee, threshold), gain, polarity, delay, link |
| `0x598` | Mute masks: inputs u16, outputs u16 |
| `0x59C` | Bypassed PEQ bands, u16 bit mask per channel (inputs, then outputs) |
| `0x5B4` | FIR name per channel, 8 characters each |
No GEQ on this model, no master bypass commands. Slope index without the "bypass" entry (0 = BW -6). Changed commands:
| Cmd | Payload |
|---|---|
| `0x31` / `0x32` | `[ch][u16 freq][slope][1 = bypass]` |
| `0x30` | `[ch]` ratio, attack, release, knee, threshold, EQ frequency as u16, `[EQ type][EQ bypass]` (inputs) |
| `0x3F` | `[ch]` ratio, attack, release, knee, threshold as u16 |
| `0x4B` | `[ch][type][window][u16 low Hz][u16 high Hz][u16 taps index]`, outputs. Type: bypass, low, high, band, external. Window: rectangle, Bartlett, Hanning, Hamming, Blackman, sine, sinc, Nuttall, Kaiser, Blackman-Nuttall, Blackman-Harris. Taps = 256 + 32·index |
| `0x4E` | `[ch][packet][u16 total]` + up to 12 floats, most significant byte first |
| `0x4F` | `[ch][1 = bypass]`, inputs |
| `0x5B` | `[ch]` + 8 characters of FIR name |
At most 2048 coefficients per input, 1024 per output, 4096 over all channels.
+16 -2
View File
@@ -28,6 +28,10 @@ Control both devices at the same time from your phone, tablet or computer – ov
* **Several devices at once** – pick the DSP from the drop-down at the top (small dots show the status of the others);
the model is detected automatically
* **Dashboard** – your own overview page: drag modules onto it (DSP overview, levels, faders, frequency response with
clickable EQ bands and overlays, channel, limiter, routing, delay, FIR, notes), move them by the title, resize them by
the arrows, choose their DSP. It only looks and never changes a DSP; the layout is stored in the config
* **Read-only switch** – on phones and tablets the web UI starts read-only; a small switch at the top allows changes
* **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
@@ -35,7 +39,8 @@ Control both devices at the same time from your phone, tablet or computer – ov
sub/top crossover; **EQ Bypass** switches all PEQ bands off at once
* **Inputs** – noise gate, 31-band GEQ with **GEQ Bypass** · **Outputs** – compressor, limiter, input routing with mix levels
* **Routing matrix**, recall and store presets
* **Channel settings** tab – link channels into groups (the DSP mirrors changes within the group), set a **max level**
* **Channel settings** tab – link channels into groups (the DSP mirrors changes within the group) edit existing groups (add or
remove channels), give each group a name – the mixer shows it as a bracket in the group's colour above its strips –, set a **max level**
per channel (software lock: the fader can't go higher; if the DSP itself is turned up, it can only be pulled down until
it snaps into the limit again) and pick channel colours
* **Preset files** – export the current DSP state to a file and import it again. An import only changes the active
@@ -76,6 +81,15 @@ Control both devices at the same time from your phone, tablet or computer – ov
|--------|---------|-----|-------------------------|
| t.racks DSP 204 | ✓ | ✓ | yes (firmware V0104P, USB on macOS) |
| t.racks DSP 408 | ✓ | ✓ | not yet – frames match published captures |
| t.racks DSP 206 (beta) | ✓ | ? | no – assumed to work like the others, testers wanted |
| t.racks FIR DSP 408 (beta) | ✓ | ? | no – memory layout and FIR commands derived from the control software, simulator only |
The FIR DSP 408 gets its own **FIR** tab: low-, high- and band-pass with window and taps on the outputs, coefficients
from a txt/csv file on inputs (up to 2048) and outputs (up to 1024), a curve and the shared budget of 4096 taps. Its
dynamic EQs are not supported.
Beta models are not detected automatically: choose them by hand when adding the device (amplifiers off for the first
test). If the shown values don't match the DSP, please send the file from File… → Export.
The DSPs accept only **one** connection at a time – close any other control software first.
@@ -188,7 +202,7 @@ python tests/test_protocol.py
| `sim.py` | Simulated DSP 204/408 |
| `desktop.py` | Desktop app (Windows/macOS): server + own window (pywebview) |
| `pi_writer.py`, `pi_image.py`, `win_disk.py` | Raspberry Pi SD card writer: GUI, OS image + cloud-init, raw disk writes |
| `static/` | Web UI (`app.js`, `style.css`, `index.html`), SoundField in `static/soundfield.js`, translations in `static/i18n.js` |
| `static/` | Web UI (`app.js`, `style.css`, `index.html`), dashboard in `static/dashboard.js`, SoundField in `static/soundfield.js`, translations in `static/i18n.js` |
| `packaging/` | Build script and icons |
| `tests/` | Protocol tests |
| `PROTOCOL.md` | Protocol documentation |
+38 -4
View File
@@ -22,12 +22,12 @@ class Device:
def __init__(self, dev_id: str, name: str, host: str, port: int = P.PORT, model: str = "auto",
addr: int = 1, autoconnect: bool = True, on_event=None, transport: str = "tcp", usb: str = "",
lock_code: str = "", auto_unlock: bool = False, test_saved: list | None = None,
colors: dict | None = None, maxgain: dict | None = None):
colors: dict | None = None, maxgain: dict | None = None, linknames: dict | None = None):
self.id = dev_id
self.name = name
self.host = host
self.port = port
self.model_key = model # "auto", "204" or "408"
self.model_key = model # "auto" or a key of P.MODELS
self.addr = addr
self.autoconnect = autoconnect
self.transport = "usb" if transport == "usb" else "tcp"
@@ -38,6 +38,7 @@ class Device:
self.auto_unlock = auto_unlock
self.demo = False # in-process simulator of the demo mode, never saved
self.colors: dict[str, str] = colors or {} # channel colours chosen in the app, e.g. {"in0": "#38bdf8"}
self.linknames: dict[str, str] = linknames or {} # names of link groups, e.g. {"out:0,1": "Tops"}
self.maxgain: dict[str, int] = maxgain or {} # software limit of the gain fader per channel (raw), e.g. {"out0": 260}
# audio test: output gains from before the test (restored when it ends) and the test fader level
self.test_saved: list[int] | None = test_saved if isinstance(test_saved, list) else None
@@ -74,7 +75,7 @@ class Device:
"model": self.model_key, "addr": self.addr, "autoconnect": self.autoconnect,
"transport": self.transport, "usb": self.usb,
"lock_code": self.lock_code, "auto_unlock": self.auto_unlock, "test_saved": self.test_saved,
"colors": self.colors, "maxgain": self.maxgain}
"colors": self.colors, "maxgain": self.maxgain, "linknames": self.linknames}
def snapshot(self) -> dict:
cfg = self.config()
@@ -84,6 +85,7 @@ class Device:
"detected_model": self.model_name or None,
"n_in": self.model.n_in if self.model else 0,
"n_out": self.model.n_out if self.model else 0,
"fir": bool(self.model and self.model.fir),
"presets": self.presets, "state": self.state}
def start(self):
@@ -137,6 +139,35 @@ class Device:
await asyncio.sleep(0.3)
await self.refresh()
def fir_taps_used(self, skip: tuple[str, int] | None = None) -> int:
"""FIR taps taken by all channels together (they share P.FIR_MAX_TOTAL)."""
total = 0
for kind, key in (("in", "inputs"), ("out", "outputs")):
for i, ch in enumerate(self.state[key]):
if (kind, i) != skip:
total += P.fir_channel_taps(ch)
return total
async def upload_fir(self, kind: str, idx: int, coeffs: list[float], name: str) -> int:
"""Send FIR coefficients to a channel. Returns how many frames were not answered."""
if self.status != "online" or not self.state or not self.model.fir:
raise RuntimeError("DSP is not connected")
await self.flush()
c = self.model.channel(kind, idx)
name = P.clean_name(name)[:8]
failed = 0
if await self._request(P.CMD_FIR_NAME, bytes([c]) + name.encode("ascii").ljust(8, b" ")) is None:
failed += 1
for payload in P.fir_coef_frames(c, coeffs):
if await self._request(P.CMD_FIR_COEF, payload) is None:
failed += 1
fir = self.state["inputs" if kind == "in" else "outputs"][idx]["fir"]
fir["name"] = name
if kind == "in":
fir["taps"] = len(coeffs)
self._emit_state()
return failed
def gain_cap(self, kind: str, idx: int, value: int) -> int:
"""Software limit of a channel's gain: never above the limit - unless the DSP itself is set higher,
then only downwards (it snaps back into the limit once it is below)."""
@@ -405,7 +436,10 @@ class Device:
self._codes = None
async def _load_config(self):
self.state = await self._read_config()
state = await self._read_config()
if self.model.fir and self.state: # where this model keeps the test signal in its memory is not known
state["test"] = self.state.get("test", state["test"])
self.state = state
async def _read_config(self) -> dict:
model = self.model
+18 -10
View File
@@ -49,16 +49,16 @@ def _peq(src, cur: list) -> list:
def _group(src, cur: dict, ranges: dict) -> dict:
src = src if isinstance(src, dict) else {}
return {k: _int(src.get(k), lo, hi, cur[k]) for k, (lo, hi) in ranges.items()}
return {k: _int(src.get(k), *ranges.get(k, (0, 0xFFFF)), v) for k, v in cur.items()}
def _common(s: dict, c: dict) -> dict:
name = s.get("name", c["name"])
return {"name": P.clean_name(name).strip(),
"hp": _filter(s.get("hp"), c["hp"]), "lp": _filter(s.get("lp"), c["lp"]),
return {"name": P.clean_name(name).strip(), **{k: _filter(s.get(k), c[k]) for k in ("hp", "lp") if k in c},
"gain": _int(s.get("gain"), 0, 400, c["gain"]), "polarity": bool(s.get("polarity", c["polarity"])),
"delay": _int(s.get("delay"), 0, 65280, c["delay"]), "link": _int(s.get("link"), 0, 0xFFFF, c["link"]),
"mute": bool(s.get("mute", c["mute"])), "peq_bypass": bool(s.get("peq_bypass", c.get("peq_bypass", False)))}
"mute": bool(s.get("mute", c["mute"])),
**({"peq_bypass": bool(s.get("peq_bypass", c.get("peq_bypass", False)))} if "peq_bypass" in c else {})}
def clean_state(model: P.Model, src: dict, base: dict) -> dict:
@@ -69,16 +69,24 @@ def clean_state(model: P.Model, src: dict, base: dict) -> dict:
for i, c in enumerate(st["inputs"]):
s = ins[i] if i < len(ins) and isinstance(ins[i], dict) else {}
geq = s.get("geq") if isinstance(s.get("geq"), list) else []
c.update(_common(s, c), peq=_peq(s.get("peq"), c["peq"]), gate=_group(s.get("gate"), c["gate"], _GATE),
geq_bypass=bool(s.get("geq_bypass", c.get("geq_bypass", False))),
c.update(_common(s, c), peq=_peq(s.get("peq"), c["peq"]), gate=_group(s.get("gate"), c["gate"], _GATE))
if model.fir:
c.update(comp=_group(s.get("comp"), c["comp"], _COMP))
c["fir"]["bypass"] = bool((s.get("fir") if isinstance(s.get("fir"), dict) else {}).get("bypass", c["fir"]["bypass"]))
continue
c.update(geq_bypass=bool(s.get("geq_bypass", c.get("geq_bypass", False))),
geq=[_int(geq[b], 0, 240, v) if b < len(geq) else v for b, v in enumerate(c["geq"])])
for i, c in enumerate(st["outputs"]):
s = outs[i] if i < len(outs) and isinstance(outs[i], dict) else {}
mix = s.get("mix") if isinstance(s.get("mix"), list) else []
c.update(_common(s, c), peq=_peq(s.get("peq"), c["peq"]),
comp=_group(s.get("comp"), c["comp"], _COMP), limit=_group(s.get("limit"), c["limit"], _LIMIT),
limit=_group(s.get("limit"), c["limit"], _LIMIT),
matrix=_int(s.get("matrix"), 0, (1 << model.n_in) - 1, c["matrix"]),
mix=[_int(mix[k], 0, 400, v) if k < len(mix) else v for k, v in enumerate(c["mix"])])
if model.fir:
c["fir"] = P.clean_fir(s.get("fir"), c["fir"])
else:
c.update(comp=_group(s.get("comp"), c["comp"], _COMP))
if isinstance(src.get("preset_name"), str):
st["preset_name"] = src["preset_name"][:14]
return st
@@ -132,11 +140,11 @@ def import_commands(model: P.Model, st: dict, current: dict) -> list[tuple[int,
cmds.append((P.CMD_LINK, bytes([model.channel(kind, i)]) + (1 << i).to_bytes(2, "little")))
for kind, key in kinds:
for i, ch in enumerate(st[key]):
params = ["name", "gain", "polarity", "delay", "hp", "lp", "peq_bypass"] + [f"peq.{b}" for b in range(len(ch["peq"]))]
params = ["name", "gain", "polarity", "delay"] + [k for k in ("hp", "lp", "peq_bypass") if k in ch] + [f"peq.{b}" for b in range(len(ch["peq"]))]
if kind == "in":
params += [f"geq.{b}" for b in range(len(ch["geq"]))] + ["gate", "geq_bypass"]
params += ["gate", "comp", "fir"] if model.fir else [f"geq.{b}" for b in range(len(ch["geq"]))] + ["gate", "geq_bypass"]
else:
params += ["comp", "limit", "matrix"] + [f"mix.{k}" for k in range(len(ch["mix"]))]
params += (["fir", "limit"] if model.fir else ["comp", "limit"]) + ["matrix"] + [f"mix.{k}" for k in range(len(ch["mix"]))]
for p in params + ["mute"]:
cmd = P.param_command(model, kind, i, ch, p)
if relink or cmd != P.param_command(model, kind, i, current[key][i], p):
+230 -6
View File
@@ -46,6 +46,11 @@ CMD_LIMIT = 0x3F
CMD_MIX = 0x41
CMD_GEQ = 0x48
CMD_LINK = 0x3B # [ch][u16 link mask], see link_masks()
# FIR DSP 408 only
CMD_FIR = 0x4B # [ch][type][window][u16 low Hz][u16 high Hz][u16 taps index] (outputs)
CMD_FIR_COEF = 0x4E # [ch][packet][u16 total][up to 12 floats, most significant byte first]
CMD_FIR_BYPASS = 0x4F # [ch][1 = bypassed] (inputs)
CMD_FIR_NAME = 0x5B # [ch][8 characters]
CHUNK_SIZE = 50
TEST_SOURCES = ("analog", "pink", "white", "sine")
@@ -209,14 +214,16 @@ class Model:
name: str
n_in: int
n_out: int
beta: bool = False # never seen on a real device; only selectable by hand
fir: bool = False # FIR DSP 408: own memory layout, see _parse_fir
@property
def in_size(self) -> int:
return 140
return 138 if self.fir else 140
@property
def out_size(self) -> int:
return 96 + 2 * self.n_in
return 108 if self.fir else 96 + 2 * self.n_in
@property
def out_base(self) -> int:
@@ -233,6 +240,8 @@ class Model:
@property
def size(self) -> int:
if self.fir:
return 0x625
return self.globals_base + 4 + 2 * self.n_in + 2 * self.n_out + 12
@property
@@ -247,12 +256,20 @@ class Model:
return idx if kind == "in" else 4 + idx
MODELS = {"204": Model("DSP 204", 2, 4), "408": Model("DSP 408", 4, 8)}
MODELS = {"204": Model("DSP 204", 2, 4), "408": Model("DSP 408", 4, 8),
"206": Model("DSP 206", 2, 6, beta=True), "408fir": Model("FIR DSP 408", 4, 8, beta=True, fir=True)}
FIR_MAX_IN, FIR_MAX_OUT, FIR_MAX_TOTAL = 2048, 1024, 4096 # taps per input / output, all channels together
FIR_PACKET = 12 # coefficients per CMD_FIR_COEF frame
def detect_model(info: str) -> str | None:
for key in MODELS:
if f"DSP{key}" in info.replace(" ", ""):
"""Beta models are never detected, and a FIR device must not pass as a plain DSP 408."""
info = info.replace(" ", "").upper()
if "FIR" in info:
return None
for key, model in MODELS.items():
if not model.beta and f"DSP{key}" in info:
return key
return None
@@ -283,6 +300,8 @@ def _peq(buf: bytes, off: int, n: int) -> list[dict]:
def parse_state(model: Model, buf: bytes) -> dict:
"""Decode the reassembled config dump into a JSON friendly dict (raw values)."""
if model.fir:
return _parse_fir(model, buf)
u16 = lambda off: struct.unpack_from("<H", buf, off)[0]
g = model.globals_base
in_mute, out_mute = u16(g), u16(g + 2)
@@ -333,8 +352,207 @@ def parse_state(model: Model, buf: bytes) -> dict:
return {"preset_name": _name(buf[2:16]), "inputs": inputs, "outputs": outputs, "test": test}
# ---------------------------------------------------------------- FIR DSP 408
#
# Layout: header 0x10, inputs of 138 bytes, outputs of 108, then the mute masks, one word per channel with
# the bypassed PEQ bands, 8 characters of FIR name per channel and 17 bytes of other settings.
# Inputs: name, gate, 3 dynamic EQs (not used here), 8 PEQ bands, compressor, FIR taps + bypass, gain ...
# Outputs: name, matrix, mix, HP/LP (with own bypass bytes), FIR, 9 PEQ bands, limiter, gain ...
def _fir_slope(index: int, bypass: int) -> int:
"""This model keeps slope and bypass apart, the state uses one value (0 = bypass) like the other models."""
return 0 if bypass else min(index + 1, 20)
def _fir_filter(buf: bytes, freq_off: int, slope_off: int) -> dict:
return {"freq": struct.unpack_from("<H", buf, freq_off)[0], "slope": _fir_slope(buf[slope_off], buf[slope_off + 2])}
def _parse_fir(model: Model, buf: bytes) -> dict:
u16 = lambda off: struct.unpack_from("<H", buf, off)[0]
g = model.globals_base
in_mute, out_mute = u16(g), u16(g + 2)
fir_name = lambda c: _name(buf[0x5B4 + 8 * c : 0x5BC + 8 * c])
def bands(off: int, n: int, mask: int) -> list[dict]:
out = _peq(buf, off, n)
for j, b in enumerate(out):
b["bypass"] = bool(mask >> j & 1)
return out
inputs = []
for i in range(model.n_in):
o = 0x10 + i * model.in_size
comp = dict(zip(("ratio", "attack", "release", "knee", "threshold", "eq_freq"), struct.unpack_from("<6H", buf, o + 112)))
inputs.append({
"name": _name(buf[o : o + 8]),
"gate": dict(zip(("attack", "release", "hold", "threshold"), struct.unpack_from("<4H", buf, o + 8))),
"peq": bands(o + 64, 8, u16(g + 4 + 2 * i)),
"comp": {**comp, "eq_type": buf[o + 124], "eq_bypass": buf[o + 125]},
"fir": {"taps": u16(o + 126), "bypass": bool(u16(o + 128)), "name": fir_name(i)},
"gain": u16(o + 130), "polarity": u16(o + 132) != 0, "delay": u16(o + 134), "link": u16(o + 136),
"mute": bool(in_mute >> i & 1),
})
outputs = []
for i in range(model.n_out):
o = model.out_base + i * model.out_size
typ, win, low, high, taps = struct.unpack_from("<BBHHH", buf, o + 28)
outputs.append({
"name": _name(buf[o : o + 8]),
"matrix": u16(o + 8),
"mix": list(struct.unpack_from(f"<{model.n_in}H", buf, o + 10)),
"hp": _fir_filter(buf, o + 20, o + 24),
"lp": _fir_filter(buf, o + 22, o + 25),
"fir": {"type": typ, "window": win, "low": low, "high": high, "taps": taps, "name": fir_name(model.channel("out", i))},
"peq": bands(o + 36, 9, u16(g + 12 + 2 * i)),
"limit": dict(zip(("ratio", "attack", "release", "knee", "threshold"), struct.unpack_from("<5H", buf, o + 90))),
"gain": u16(o + 100), "polarity": u16(o + 102) != 0, "delay": u16(o + 104), "link": u16(o + 106),
"mute": bool(out_mute >> i & 1),
})
return {"preset_name": _name(buf[2:16]), "inputs": inputs, "outputs": outputs, "test": {"source": 0, "freq": 0}}
def _build_fir(model: Model, state: dict) -> bytearray:
buf = bytearray(model.chunks * CHUNK_SIZE)
pad = lambda s, n: s.encode("latin1")[:n].ljust(n, b" ")
buf[0:2] = b"\xff\xff"
buf[2:16] = pad(state["preset_name"], 14)
g = model.globals_base
def put_bands(off: int, bands: list[dict]) -> int:
for j, b in enumerate(bands):
struct.pack_into("<HHBB", buf, off + j * 6, b["gain"], b["freq"], b["q"], b["type"])
return sum(int(b.get("bypass", False)) << j for j, b in enumerate(bands))
in_mute = out_mute = 0
for i, ch in enumerate(state["inputs"]):
o = 0x10 + i * model.in_size
buf[o : o + 8] = pad(ch["name"], 8)
gt, c = ch["gate"], ch["comp"]
struct.pack_into("<4H", buf, o + 8, gt["attack"], gt["release"], gt["hold"], gt["threshold"])
struct.pack_into("<H", buf, g + 4 + 2 * i, put_bands(o + 64, ch["peq"]))
struct.pack_into("<6HBB", buf, o + 112, c["ratio"], c["attack"], c["release"], c["knee"], c["threshold"],
c["eq_freq"], c["eq_type"], c["eq_bypass"])
struct.pack_into("<6H", buf, o + 126, ch["fir"]["taps"], int(ch["fir"]["bypass"]), ch["gain"],
int(ch["polarity"]), ch["delay"], ch.get("link", 1 << i))
buf[0x5B4 + 8 * i : 0x5BC + 8 * i] = pad(ch["fir"]["name"], 8)
in_mute |= int(ch["mute"]) << i
for i, ch in enumerate(state["outputs"]):
o = model.out_base + i * model.out_size
buf[o : o + 8] = pad(ch["name"], 8)
struct.pack_into("<H", buf, o + 8, ch["matrix"])
struct.pack_into(f"<{model.n_in}H", buf, o + 10, *ch["mix"])
hp, lp, f, lim = ch["hp"], ch["lp"], ch["fir"], ch["limit"]
struct.pack_into("<HHBBBB", buf, o + 20, hp["freq"], lp["freq"], max(hp["slope"] - 1, 0), max(lp["slope"] - 1, 0),
int(not hp["slope"]), int(not lp["slope"]))
struct.pack_into("<BBHHH", buf, o + 28, f["type"], f["window"], f["low"], f["high"], f["taps"])
struct.pack_into("<H", buf, g + 12 + 2 * i, put_bands(o + 36, ch["peq"]))
struct.pack_into("<5H", buf, o + 90, lim["ratio"], lim["attack"], lim["release"], lim["knee"], lim["threshold"])
struct.pack_into("<4H", buf, o + 100, ch["gain"], int(ch["polarity"]), ch["delay"], ch.get("link", 1 << i))
c = model.channel("out", i)
buf[0x5B4 + 8 * c : 0x5BC + 8 * c] = pad(f["name"], 8)
out_mute |= int(ch["mute"]) << i
struct.pack_into("<HH", buf, g, in_mute, out_mute)
return buf
def _default_fir(model: Model) -> dict:
peq = lambda n: [{"gain": 120, "freq": 50 + i * 25, "q": 32, "type": 0, "bypass": False} for i in range(n)]
return {
"preset_name": "Default",
"inputs": [{
"name": f"In{chr(65 + i)}", "gate": {"attack": 0, "release": 99, "hold": 99, "threshold": 0}, "peq": peq(8),
"comp": {"ratio": 0, "attack": 49, "release": 99, "knee": 0, "threshold": 120, "eq_freq": 150, "eq_type": 0, "eq_bypass": 1},
"fir": {"taps": 0, "bypass": True, "name": ""},
"gain": 280, "polarity": False, "delay": 0, "mute": False, "link": 1 << i,
} for i in range(model.n_in)],
"outputs": [{
"name": f"Out{i + 1}", "matrix": 1 << (i % model.n_in), "mix": [280] * model.n_in,
"hp": {"freq": 0, "slope": 0}, "lp": {"freq": 300, "slope": 0},
"fir": {"type": 0, "window": 3, "low": 150, "high": 20000, "taps": 8, "name": ""},
"peq": peq(9), "limit": {"ratio": 0, "attack": 49, "release": 99, "knee": 0, "threshold": 200},
"gain": 280, "polarity": False, "delay": 0, "mute": False, "link": 1 << i,
} for i in range(model.n_out)],
"test": {"source": 0, "freq": 0},
}
def fir_channel_taps(ch: dict) -> int:
"""How many of the shared FIR taps a channel takes."""
f = ch["fir"]
if "type" in f:
return 256 + 32 * f["taps"] if f["type"] else 0
return 0 if f["bypass"] else f["taps"]
def clean_fir(value, cur: dict) -> dict:
"""FIR settings of an output limited to valid values; anything missing stays as it is."""
value = value if isinstance(value, dict) else {}
def num(key, lo, hi):
try:
return min(hi, max(lo, int(value.get(key, cur[key]))))
except (TypeError, ValueError):
return cur[key]
return {"type": num("type", 0, 4), "window": num("window", 0, 10), "low": num("low", 20, 20000),
"high": num("high", 20, 20000), "taps": num("taps", 0, 24), "name": cur.get("name", "")}
def fir_coef_frames(channel: int, coeffs: list[float]) -> list[bytes]:
"""Payloads of the CMD_FIR_COEF frames for one channel."""
n = len(coeffs)
return [bytes([channel, p]) + struct.pack("<H", n)
+ b"".join(struct.pack(">f", c) for c in coeffs[p * FIR_PACKET : (p + 1) * FIR_PACKET])
for p in range(-(-n // FIR_PACKET))]
def _fir_command(c: int, kind: str, ch: dict, top: str, rest: list[str]) -> tuple[int, bytes] | None:
if top in ("hp", "lp"):
f = ch[top]
return (CMD_HIGH_PASS if top == "hp" else CMD_LOW_PASS), bytes([c]) + _w(f["freq"]) + bytes([max(f["slope"] - 1, 0), int(not f["slope"])])
if top == "limit" and kind == "out":
return CMD_LIMIT, bytes([c]) + b"".join(_w(ch["limit"][k]) for k in ("ratio", "attack", "release", "knee", "threshold"))
if top == "comp" and kind == "in":
g = ch["comp"]
return CMD_COMP, bytes([c]) + b"".join(_w(g[k]) for k in ("ratio", "attack", "release", "knee", "threshold", "eq_freq")) + bytes([g["eq_type"], g["eq_bypass"]])
if top == "fir" and kind == "out":
f = ch["fir"]
return CMD_FIR, bytes([c, f["type"], f["window"]]) + _w(f["low"]) + _w(f["high"]) + _w(f["taps"])
if top == "fir" and kind == "in":
return CMD_FIR_BYPASS, bytes([c, int(ch["fir"]["bypass"])])
return None
def _apply_fir(ch: dict, cmd: int, p: bytes) -> bool:
"""Set commands of this model (simulator). False: handled like on the other models."""
w = lambda o: struct.unpack_from("<H", p, o)[0]
if cmd in (CMD_HIGH_PASS, CMD_LOW_PASS):
ch["hp" if cmd == CMD_HIGH_PASS else "lp"] = {"freq": w(1), "slope": _fir_slope(p[3], p[4])}
elif cmd == CMD_LIMIT:
ch["limit"] = dict(zip(("ratio", "attack", "release", "knee", "threshold"), struct.unpack_from("<5H", p, 1)))
elif cmd == CMD_COMP:
ch["comp"] = {**dict(zip(("ratio", "attack", "release", "knee", "threshold", "eq_freq"), struct.unpack_from("<6H", p, 1))),
"eq_type": p[13], "eq_bypass": p[14]}
elif cmd == CMD_FIR:
ch["fir"].update(type=p[1], window=p[2], low=w(3), high=w(5), taps=w(7))
elif cmd == CMD_FIR_BYPASS:
ch["fir"]["bypass"] = bool(p[1])
elif cmd == CMD_FIR_NAME:
ch["fir"]["name"] = _name(p[1:9])
elif cmd == CMD_FIR_COEF:
if "bypass" in ch["fir"]:
ch["fir"]["taps"] = w(2)
else:
return False
return True
def build_state_buffer(model: Model, state: dict) -> bytearray:
"""Inverse of parse_state (used by the simulator)."""
if model.fir:
return _build_fir(model, state)
buf = bytearray(model.chunks * CHUNK_SIZE)
pad = lambda s, n: s.encode("latin1")[:n].ljust(n, b" ")
buf[0:2] = b"\xff\xff"
@@ -383,6 +601,8 @@ def build_state_buffer(model: Model, state: dict) -> bytearray:
def default_state(model: Model) -> dict:
if model.fir:
return _default_fir(model)
peq = lambda n: [{"gain": 120, "freq": 50 + i * 25, "q": 32, "type": 0, "bypass": False}
for i in range(n)]
return {
@@ -465,6 +685,8 @@ def param_command(model: Model, kind: str, idx: int, ch: dict, param: str) -> tu
"""
c = model.channel(kind, idx)
top, *rest = param.split(".")
if model.fir and (fir := _fir_command(c, kind, ch, top, rest)):
return fir
if top == "gain":
return CMD_GAIN, bytes([c]) + _w(ch["gain"])
if top == "mute":
@@ -535,7 +757,9 @@ def apply_command(model: Model, state: dict, cmd: int, p: bytes):
return
ch = chans[idx]
w = lambda o: struct.unpack_from("<H", p, o)[0]
if cmd == CMD_PEQ_BYPASS:
if model.fir and _apply_fir(ch, cmd, p):
pass
elif cmd == CMD_PEQ_BYPASS:
ch["peq_bypass"] = bool(p[1])
elif cmd == CMD_GEQ_BYPASS:
ch["geq_bypass"] = bool(p[1])
+103 -6
View File
@@ -12,6 +12,7 @@ import errno
import hashlib
import json
import logging
import math
import mimetypes
import re
import secrets
@@ -143,6 +144,27 @@ def clean_soundfield(data) -> dict:
}
DASH_TYPES = ("status", "meters", "mixer", "curve", "channel", "limiter", "routing", "delays", "fir", "notes")
def clean_dashboard(data) -> dict | None:
"""Modules of the dashboard page; None = never edited (the app shows a default page)."""
if not isinstance(data, dict) or not isinstance(data.get("modules"), list):
return None
modules = []
for m in data["modules"][:40]:
if not isinstance(m, dict) or m.get("type") not in DASH_TYPES:
continue
src = m.get("cfg") if isinstance(m.get("cfg"), dict) else {}
cfg = {"device": str(src.get("device") or "")[:64], "title": str(src.get("title") or "")[:40],
"kind": "out" if src.get("kind") == "out" else "in", "idx": int(_num(src.get("idx"), 0, 15, 0)),
"text": str(src.get("text") or "")[:2000],
"overlays": [str(o) for o in src.get("overlays") or [] if re.fullmatch(r"(in|out)\d{1,2}", str(o))][:16]}
modules.append({"id": re.sub(r"[^\w-]", "", str(m.get("id") or ""))[:32] or uuid.uuid4().hex[:8], "type": m["type"],
"w": int(_num(m.get("w"), 2, 12, 4)), "h": int(_num(m.get("h"), 0, 20, 0)), "cfg": cfg})
return {"modules": modules}
def clean_colors(v) -> dict:
"""Channel colours: {"in0": "#rrggbb", "out3": ...}. Linked channels carry their group's colour; that a colour
belongs to one channel/group only is ensured by the colour picker (it knows the link groups)."""
@@ -154,6 +176,16 @@ def clean_colors(v) -> dict:
return out
def clean_linknames(v) -> dict:
"""Names of link groups, keyed by kind and members: {"out:0,1": "Tops"}. A changed group loses its name."""
out = {}
for k, n in (v.items() if isinstance(v, dict) else []):
n = "".join(c for c in str(n) if c.isprintable()).strip()[:16]
if n and re.fullmatch(r"(in|out):\d{1,2}(,\d{1,2})+", str(k)):
out[str(k)] = n
return out
def clean_maxgain(v) -> dict:
"""Software gain limits per channel: {"in0": raw 0..399} (400 = +12 dB would be no limit)."""
out = {}
@@ -191,6 +223,7 @@ class App:
self.failures: dict[str, tuple[int, float]] = {} # ip -> (failed attempts, locked until)
self.limiter: dict = clean_limiter({})
self.soundfield: dict = clean_soundfield({})
self.dashboard: dict | None = None
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
@@ -238,6 +271,8 @@ class App:
self.limiter = clean_limiter(cfg.get("limiter") or {})
if "soundfield" in cfg:
self.soundfield = clean_soundfield(cfg.get("soundfield"))
if "dashboard" in cfg:
self.dashboard = clean_dashboard(cfg.get("dashboard"))
if "logo" in cfg:
self.logo = clean_logo(cfg.get("logo"))
r = cfg.get("remote") or {}
@@ -253,7 +288,8 @@ class App:
"""App backup: devices, PIN (hashed), amplifiers/limiter data, remote access - no logins."""
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}
"limiter": self.limiter, "remote": self.remote, "soundfield": self.soundfield, "logo": self.logo,
"dashboard": self.dashboard}
async def restore_config(self, doc: dict, session: str):
if not isinstance(doc, dict) or doc.get("format") != CONFIG_FORMAT:
@@ -311,7 +347,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,
"soundfield": self.soundfield, "logo": self.logo,
"soundfield": self.soundfield, "logo": self.logo, "dashboard": self.dashboard,
"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:
@@ -327,7 +363,7 @@ class App:
transport="usb" if usb else "tcp", usb=str(d.get("usb") or ""),
lock_code=str(d.get("lock_code") or ""), auto_unlock=bool(d.get("auto_unlock")),
test_saved=clean_gains(d.get("test_saved")), colors=clean_colors(d.get("colors")),
maxgain=clean_maxgain(d.get("maxgain")))
maxgain=clean_maxgain(d.get("maxgain")), linknames=clean_linknames(d.get("linknames")))
dev.on_online = self.device_online
self.devices[dev_id] = dev
if dev.autoconnect:
@@ -375,6 +411,8 @@ class App:
return {"ok": True}
async def device_online(self, dev: Device):
if dev.model.fir and dev.test_saved is not None: # its test signal can't be read back: make sure it is off
await dev.set_test_signal(0, 0)
await self.check_audio_test(dev)
if not self.mute_all["active"] and self.mute_all["restore"].get(dev.id):
self.unmute_device(dev) # released while this DSP was offline
@@ -411,6 +449,44 @@ class App:
self.broadcast({"type": "muteall", "data": self.mute_all_info()})
return self.mute_all_info()
# ------------------------------------------------------------ FIR filters (FIR DSP 408)
@staticmethod
def check_fir_param(dev: Device, idx: int, value) -> dict:
value = P.clean_fir(value, dev.state["outputs"][idx]["fir"])
if value["type"] and dev.fir_taps_used(skip=("out", idx)) + 256 + 32 * value["taps"] > P.FIR_MAX_TOTAL:
raise RuntimeError("Out of FIR taps: all channels together have 4096")
return value
async def upload_fir(self, dev: Device, body: dict) -> dict:
kind = "in" if body.get("kind") == "in" else "out"
idx = int(body.get("idx", 0))
if not dev.state or not dev.model.fir or not 0 <= idx < len(dev.state["inputs" if kind == "in" else "outputs"]):
raise RuntimeError("DSP is not connected")
raw = body.get("coeffs")
limit = P.FIR_MAX_IN if kind == "in" else P.FIR_MAX_OUT
if not isinstance(raw, list) or not 1 <= len(raw) <= limit:
raise RuntimeError(f"Too many FIR coefficients: at most {limit} here")
try:
coeffs = [float(c) for c in raw]
except (TypeError, ValueError):
raise RuntimeError("Not valid FIR coefficients") from None
if not all(math.isfinite(c) for c in coeffs):
raise RuntimeError("Not valid FIR coefficients")
name = str(body.get("name") or "")
if kind == "out":
taps = max(0, -((256 - len(coeffs)) // 32)) # taps index that holds them
cur = dev.state["outputs"][idx]["fir"]
dev.set_param("out", idx, "fir", self.check_fir_param(dev, idx, {**cur, "type": 4, "taps": taps}))
elif dev.fir_taps_used(skip=("in", idx)) + len(coeffs) > P.FIR_MAX_TOTAL:
raise RuntimeError("Out of FIR taps: all channels together have 4096")
failed = await dev.upload_fir(kind, idx, coeffs, name)
if kind == "in" and dev.state["inputs"][idx]["fir"]["bypass"]:
dev.set_param("in", idx, "fir.bypass", False)
if failed:
raise RuntimeError(f"The DSP did not answer {failed} frames")
return {"ok": True, "count": len(coeffs)}
# ------------------------------------------------------------ copy channel settings
def copy_settings(self, body: dict) -> dict:
@@ -443,10 +519,13 @@ class App:
if kind == "in":
params += ["geq_bypass"] + [f"geq.{b}" for b in range(31)]
if "dynamics" in groups:
params += ["gate"] if kind == "in" else ["comp", "limit"]
params += ["gate", "comp"] if kind == "in" else ["comp", "limit"]
if "routing" in groups and kind == "out":
params += [f"mix.{k}" for k in range(min(len(sch["mix"]), len(tch["mix"])))]
for p in params:
top = p.split(".")[0]
if top not in sch or top not in tch or (isinstance(sch[top], dict) and sch[top].keys() != tch[top].keys()):
continue # a setting only one of the two models has
v = copy.deepcopy(self._get(sch, p))
if p == "gain":
v = dev.gain_cap(kind, idx, v)
@@ -747,6 +826,13 @@ class App:
return {"logo": self.logo}
if path == "/api/logo":
return {"logo": self.logo}
if path == "/api/dashboard" and method == "PUT":
self.dashboard = clean_dashboard(body)
self.save()
self.broadcast({"type": "dashboard", "data": self.dashboard})
return self.dashboard
if path == "/api/dashboard":
return self.dashboard
if path == "/api/soundfield" and method == "PUT":
self.soundfield = clean_soundfield(body)
self.save()
@@ -781,7 +867,7 @@ class App:
if dev.demo and (method in ("DELETE", "PUT") or action in ("unlock", "lockcode")):
raise RuntimeError("Not available for the demo device")
# during the audio test only the test controls work: generator, test fader, output mutes
if dev.test_active and (action in ("preset/recall", "preset/store", "export", "import", "undo", "link")
if dev.test_active and (action in ("preset/recall", "preset/store", "export", "import", "undo", "link", "fir")
or action == "set" and body.get("param") != "mute"):
raise RuntimeError("Audio test is on – switch it off first")
if self.demo["enabled"] and not dev.demo and action == "connect":
@@ -827,8 +913,12 @@ class App:
kind, idx, value = body["kind"], int(body["idx"]), body["value"]
if body["param"] == "gain" and not body.get("force"): # force: confirmed twice in the app
value = dev.gain_cap(kind, idx, int(value)) # software max level
if body["param"] == "fir" and dev.state:
value = self.check_fir_param(dev, int(body["idx"]), value)
dev.set_param(kind, idx, body["param"], value)
return {"ok": True, "value": value}
if action == "fir":
return await self.upload_fir(dev, body)
if action == "maxgain": # app-side setting, the DSP doesn't know it
dev.maxgain = clean_maxgain(body.get("maxgain"))
self.save()
@@ -851,6 +941,7 @@ class App:
if action == "link":
kind = "in" if body.get("kind") == "in" else "out"
groups = [[int(i) for i in g] for g in body.get("groups") or [] if isinstance(g, list)]
await dev.flush() # e.g. settings copied to a new first channel of a group must arrive before the link
await dev.set_links(kind, groups)
return {"ok": True}
if action == "refresh":
@@ -861,6 +952,11 @@ class App:
self.save()
self.broadcast({"type": "device", "device": dev.id, "data": dev.snapshot()})
return {"ok": True, "colors": dev.colors}
if action == "linknames": # display only, like the colours
dev.linknames = clean_linknames(body.get("linknames"))
self.save()
self.broadcast({"type": "device", "device": dev.id, "data": dev.snapshot()})
return {"ok": True, "linknames": dev.linknames}
if action == "test":
return await self.audio_test(dev, body)
if action == "testlevel":
@@ -1044,7 +1140,8 @@ class App:
self.clients.add(q)
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}
"demo": self.demo_info(), "muteall": self.mute_all_info(), "soundfield": self.soundfield, "logo": self.logo,
"dashboard": self.dashboard}
writer.write(f"data: {json.dumps(hello)}\n\n".encode())
await writer.drain()
while True:
+1 -1
View File
@@ -34,7 +34,7 @@ class SimDSP:
def handle(self, cmd: int, p: bytes) -> tuple[int, bytes]:
m = self.model
if cmd == P.CMD_DEVICE_INFO:
return cmd, f"DSP{self.key} V010 SIM".encode()
return cmd, f"{'FIR408' if m.fir else m.name.replace(' ', '')} V010 SIM".encode()
if cmd == P.CMD_PRESET_COUNT:
return cmd, bytes([0, 0, 0, 0, 0, 0 if self.unlocked else 1])
if cmd == P.CMD_UNLOCK:
+340 -44
View File
@@ -56,9 +56,9 @@ const store = {
};
const S = {
devices: {}, order: [], cur: store.get("dsp.cur"),
view: store.get("dsp.view") || "mixer", settings: false,
view: store.get("dsp.view") || "dash", settings: false, dash: null,
sel: { kind: "in", idx: 0 }, band: 0, busy: false, dirty: false,
routeOpen: null, es: null, linkSel: { in: [], out: [] },
routeOpen: null, es: null, linkSel: { in: [], out: [] }, linkEdit: { in: null, out: null }, firSel: { kind: "out", idx: 0 }, firDraft: null, firCoef: {},
lim: { amps: [], assign: {}, ref: {} },
demo: { enabled: false, model: "408" },
muteAll: false,
@@ -137,6 +137,9 @@ const chTitle = (d, kind, i) => { const n = chans(d, kind)[i].name; return n ? `
// Channel links (see protocol.py): a free channel's mask is its own bit, the first channel of a
// group holds all members' bits, the others 0. The DSP mirrors changes within a group itself.
const MODEL_LABEL = { "204": "DSP 204", "408": "DSP 408", "206": "DSP 206", "408fir": "FIR DSP 408" };
const MODEL_CH = { "204": [2, 4], "408": [4, 8], "206": [2, 6], "408fir": [4, 8] }; // inputs, outputs (before a DSP has connected)
const BETA_MODELS = ["206", "408fir"];
const LINK_COLORS = ["#f59e0b", "#22d3ee", "#a3e635", "#f472b6"];
function linkGroups(list) {
const seen = new Set(), groups = [];
@@ -154,9 +157,12 @@ function linkInfo(d, kind, i) { // {group, color} if the channel is linked, el
const gs = linkedGroups(d, kind), n = gs.findIndex(g => g.includes(i));
return n < 0 ? null : { group: gs[n], color: LINK_COLORS[n % LINK_COLORS.length] };
}
// group names are kept by the app, keyed by the members (a changed group starts without a name)
const linkKey = (kind, g) => `${kind}:${g.join(",")}`;
const linkName = (d, kind, g) => (d.linknames || {})[linkKey(kind, g)] || "";
const linkBadge = (d, kind, i) => {
const l = linkInfo(d, kind, i);
return l ? h("span", { class: "lnk", style: `--lc:${l.color}`, title: t("Linked: ") + l.group.map(j => chLabel(kind, j)).join(" + ") },
return l ? h("span", { class: "lnk", style: `--lc:${custColor(d, kind, i) || l.color}`, title: t("Linked: ") + l.group.map(j => chLabel(kind, j)).join(" + ") },
svgIcon(ICON.link)) : null;
};
// polarity inverted ("Phase Ø" in the channel view)
@@ -170,7 +176,7 @@ const CH_PALETTE = ["#ef4444", "#f97316", "#f59e0b", "#eab308", "#84cc16", "#22c
// channel groups of one kind: linked channels together, the others on their own
function chanGroups(d, kind) {
if (d.state) return linkGroups(chans(d, kind));
const n = kind === "in" ? d.n_in || (d.model === "408" ? 4 : 2) : d.n_out || (d.model === "408" ? 8 : 4);
const n = (kind === "in" ? d.n_in : d.n_out) || (MODEL_CH[d.model] || MODEL_CH["204"])[kind === "in" ? 0 : 1];
return Array.from({ length: n }, (_, i) => [i]);
}
// the colour chosen for a channel; linked channels show their group's colour
@@ -589,7 +595,8 @@ function renderTabs() {
const testLock = testOn(dev());
const badge = d => {
const model = d.detected_model || (d.model !== "auto" ? d.model : "");
return testOn(d) ? h("small", { class: "test-badge" }, "TEST") : d.demo ? h("small", { class: "demo-badge" }, "DEMO") : model ? h("small", {}, model) : null;
return testOn(d) ? h("small", { class: "test-badge" }, "TEST") : d.demo ? h("small", { class: "demo-badge" }, "DEMO")
: model ? h("small", {}, (MODEL_LABEL[model] || model).replace("DSP ", "")) : null;
};
const cur = S.devices[S.cur];
if (!cur) {
@@ -618,10 +625,13 @@ function renderTabs() {
$("#btn-settings").classList.toggle("on", S.settings);
$("#btn-settings").disabled = testLock;
document.querySelectorAll("#viewtabs button").forEach(b => {
if (b.dataset.view === "fir") b.hidden = !(dev() && dev().fir);
b.classList.toggle("active", !S.settings && b.dataset.view === S.view);
b.disabled = testLock && b.dataset.view !== "test";
});
fitNav(); // the DSP button's width changes with the name
if (renderTabs.view !== S.view && window.innerWidth < 760) $("#viewtabs .active")?.scrollIntoView({ inline: "center", block: "nearest" }); // scrollable bottom bar
renderTabs.view = S.view;
}
// close the DSP menu on a click elsewhere or Escape
document.addEventListener("pointerdown", e => { if (S.devMenu && !e.target.closest("#devtabs")) { S.devMenu = false; renderTabs(); } });
@@ -793,8 +803,8 @@ async function presetFileDialog(d) {
"active state – stored presets (U01 …) stay unchanged.", { name: q(d.state.preset_name || "—") })),
last ? h("p", { class: "dlg-text" }, t("A backup is made automatically before every import. Last backup: {last}.", { last })) : null),
actions: [{ label: t("Close") },
...(last && !S.locked ? [{ label: t("Undo import"), value: () => "undo" }] : []),
...(S.locked ? [] : [{ label: t("Import…"), value: () => "import" }]),
...(last && !viewOnly() ? [{ label: t("Undo import"), value: () => "undo" }] : []),
...(viewOnly() ? [] : [{ label: t("Import…"), value: () => "import" }]),
{ label: t("Export"), primary: true, value: () => "export" }],
});
try {
@@ -840,7 +850,7 @@ function reportImport(res, okMsg) {
function renderStatus() {
const bar = $("#statusbar");
const d = dev();
if (S.settings || !d) { bar.replaceChildren(); return; }
if (S.settings || !d || S.view === "dash") { bar.replaceChildren(); return; }
if (d.status !== "online" || !d.state) {
bar.replaceChildren(
h("div", { class: "preset" }, h("small", {}, `${STATUS_TEXT[d.status] || d.status} · ${d.transport === "usb" ? "USB" : d.host + ":" + d.port}`), h("b", {}, d.name),
@@ -884,7 +894,7 @@ function strip(d, kind, i) {
const ch = chans(d, kind)[i];
const db = h("button", { class: "db" + (ch.gain === 280 ? " z" : ""), title: t("Enter value") }, sign(gainDb(ch.gain)));
const showDb = v => { db.textContent = sign(gainDb(v)); db.classList.toggle("z", v === 280); };
const el = h("div", { class: `strip ${kind}` + (ch.mute ? " muted" : "") + (custColor(d, kind, i) ? " tinted" : ""), style: ccStyle(d, kind, i) });
const el = h("div", { class: `strip ${kind}` + (ch.mute ? " muted" : "") + (custColor(d, kind, i) ? " tinted" : ""), style: `${ccStyle(d, kind, i)};grid-column:${i + 1}` });
const f = fader({ min: 0, max: 400, value: ch.gain, zero: 280, ticks: GAIN_TICKS, label: `${chLabel(kind, i)} Gain`,
cap: () => gainCap(dev(), kind, i), limit: maxGain(d, kind, i),
onInput: v => { showDb(v); setParam(kind, i, "gain", v); } });
@@ -905,13 +915,182 @@ function strip(d, kind, i) {
return el;
}
// bracket over a run of neighbouring strips of one link group (a group with gaps gets one per run)
function linkBands(d, kind) {
const bands = [];
linkedGroups(d, kind).forEach(g => {
const color = custColor(d, kind, g[0]) || linkInfo(d, kind, g[0]).color, name = linkName(d, kind, g);
const title = (name ? name + " · " : "") + g.map(j => chLabel(kind, j)).join(" + ");
g.forEach((j, n) => {
if (n && g[n - 1] === j - 1) return;
let len = 1;
while (g.includes(j + len)) len++;
bands.push(h("div", { class: "lkband" + (len === 1 ? " single" : ""), style: `--lc:${color};grid-column:${j + 1} / span ${len}`, title },
h("span", { class: "lkname" + (name ? "" : " anon") }, svgIcon(ICON.link), name ? h("b", {}, name) : null)));
});
});
return bands;
}
function viewMixer(d) {
const group = (kind, title) => h("section", { class: "mgroup", style: `flex-grow:${chans(d, kind).length}` },
h("h4", {}, title), h("div", { class: "strips" }, chans(d, kind).map((_, i) => strip(d, kind, i))));
return [h("div", { class: "mixer" }, group("in", t("Inputs")), group("out", t("Outputs"))),
h("h4", {}, title), h("div", { class: "strips", style: `--n:${chans(d, kind).length}` },
linkBands(d, kind), chans(d, kind).map((_, i) => strip(d, kind, i))));
const bands = linkedGroups(d, "in").length + linkedGroups(d, "out").length > 0;
return [h("div", { class: "mixer" + (bands ? " hasbands" : "") }, group("in", t("Inputs")), group("out", t("Outputs"))),
h("p", { class: "info hint" }, t("Drag a fader by its knob · snaps at 0 dB · double-tap the knob = 0 dB · tap the dB value to type one · tap the name = edit channel"))];
}
// ------------------------------------------------------------------ FIR filters (FIR DSP 408)
const FIR_TYPES = () => [t("Bypass"), t("Low-pass"), t("High-pass"), t("Band-pass"), t("From file")];
const FIR_WINDOWS = ["Rectangle", "Bartlett", "Hanning", "Hamming", "Blackman", "Sine", "Sinc", "Nuttall", "Kaiser", "Blackman-Nuttall", "Blackman-Harris"];
const firTapCount = i => 256 + 32 * i;
const firKey = (d, kind, i) => `${d.id}|${kind}${i}`;
const firMax = kind => (kind === "in" ? 2048 : 1024);
function firTapsOf(ch) { const f = ch.fir; return "type" in f ? (f.type ? firTapCount(f.taps) : 0) : (f.bypass ? 0 : f.taps); }
const firUsed = d => [...chans(d, "in"), ...chans(d, "out")].reduce((s, ch) => s + firTapsOf(ch), 0);
function firWindow(kind, n, N) {
const x = N > 1 ? n / (N - 1) : 0, c = k => Math.cos(2 * Math.PI * k * x);
const sum = a => a.reduce((s, v, k) => s + (k % 2 ? -v : v) * c(k), 0);
switch (kind) {
case 1: return 1 - Math.abs(2 * x - 1);
case 2: return 0.5 - 0.5 * c(1);
case 3: return 0.54 - 0.46 * c(1);
case 4: return sum([0.42, 0.5, 0.08]);
case 5: return Math.sin(Math.PI * x);
case 6: { const u = 2 * x - 1; return u ? Math.sin(Math.PI * u) / (Math.PI * u) : 1; }
case 7: return sum([0.355768, 0.487396, 0.144232, 0.012604]);
case 8: { const i0 = v => { let s = 1, e = 1; for (let k = 1; k < 30; k++) { e *= (v / (2 * k)) ** 2; s += e; } return s; };
const u = 2 * x - 1; return i0(8.6 * Math.sqrt(Math.max(0, 1 - u * u))) / i0(8.6); }
case 9: return sum([0.3635819, 0.4891775, 0.1365995, 0.0106411]);
case 10: return sum([0.35875, 0.48829, 0.14128, 0.01168]);
default: return 1;
}
}
// windowed sinc, only for the preview: the DSP calculates the filter itself from type, window, cut-offs and taps
function firDesign(f) {
const N = firTapCount(f.taps), M = (N - 1) / 2, lp = c => n => { const v = n - M, w = 2 * c / FS; return v ? Math.sin(Math.PI * w * v) / (Math.PI * v) : w; };
const lo = lp(f.low), hi = lp(f.high), out = new Float64Array(N);
for (let n = 0; n < N; n++) {
const ideal = f.type === 1 ? hi(n) : f.type === 2 ? (n === M ? 1 : 0) - lo(n) : hi(n) - lo(n);
out[n] = ideal * firWindow(f.window, n, N);
}
return out;
}
function firResponseDb(h, hz) {
const w = -2 * Math.PI * hz / FS; let re = 0, im = 0;
for (let n = 0; n < h.length; n++) { re += h[n] * Math.cos(w * n); im += h[n] * Math.sin(w * n); }
return 10 * Math.log10(re * re + im * im || 1e-12);
}
function drawFir(canvas, h) {
const dpr = window.devicePixelRatio || 1, W = canvas.clientWidth, H = canvas.clientHeight;
if (!W || !H) return;
canvas.width = W * dpr; canvas.height = H * dpr;
const c = canvas.getContext("2d"); c.scale(dpr, dpr);
const x = hz => W * Math.log(hz / 20) / Math.log(1000), y = db => H * (6 - db) / 86;
c.font = "10px sans-serif"; c.lineWidth = 1;
for (const hz of [20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000]) {
c.strokeStyle = "#2a303a"; c.beginPath(); c.moveTo(x(hz), 0); c.lineTo(x(hz), H); c.stroke();
c.fillStyle = "#7b8594"; c.fillText(hz >= 1000 ? hz / 1000 + "k" : hz, Math.min(x(hz) + 3, W - 22), H - 4);
}
for (const db of [0, -20, -40, -60]) {
c.strokeStyle = db ? "#2a303a" : "#46505e"; c.beginPath(); c.moveTo(0, y(db)); c.lineTo(W, y(db)); c.stroke();
c.fillStyle = "#7b8594"; c.fillText(db + " dB", 3, y(db) - 3);
}
if (!h) return;
c.strokeStyle = "#38bdf8"; c.lineWidth = 2; c.beginPath();
for (let px = 0; px <= W; px += 2) {
const py = y(Math.max(-80, firResponseDb(h, 20 * 1000 ** (px / W))));
px ? c.lineTo(px, py) : c.moveTo(px, py);
}
c.stroke();
}
function parseFirFile(text) {
const parts = text.split(/[\s,;]+/).filter(Boolean);
const values = parts.map(Number);
if (!values.length || values.some(v => !Number.isFinite(v))) throw new Error(t("This is not a list of FIR coefficients"));
return values;
}
async function importFir(d, kind, i) {
let f;
try { f = await openFile(".txt,.csv,text/plain,text/csv"); } catch (e) { return toast(trMsg(e.message)); }
if (!f) return;
let coeffs;
try { coeffs = parseFirFile(atob(f.b64)); } catch (e) { return toast(e.message); }
if (coeffs.length > firMax(kind)) return toast(t("Too many coefficients: {n}, at most {max} here", { n: coeffs.length, max: firMax(kind) }));
const name = cleanName(f.name.replace(/\.[^.]*$/, "")).trim().slice(0, 8);
if (!await askConfirm(t("Load FIR filter"), t("Send {n} coefficients from {file} to {ch}? This changes the sound immediately – keep the amplifiers low.",
{ n: coeffs.length, file: f.name, ch: chTitle(d, kind, i) }), t("Send"))) return;
S.firBusy = true; render();
try {
await api("POST", `/api/devices/${d.id}/fir`, { kind, idx: i, coeffs, name });
S.firCoef[firKey(d, kind, i)] = Float64Array.from(coeffs);
toast(t("FIR filter loaded"));
} catch (e) { toast(t("Error: ") + trMsg(e.message)); }
S.firBusy = false; S.firDraft = null; render();
}
function viewFir(d) {
if (S.firSel.idx >= chans(d, S.firSel.kind).length) S.firSel = { kind: "out", idx: 0 };
const { kind, idx } = S.firSel, ch = chans(d, kind)[idx], key = firKey(d, kind, idx), isOut = kind === "out";
const used = firUsed(d), loaded = S.firCoef[key];
const canvas = h("canvas", { class: "fircurve" });
const pick = (k, i) => { S.firSel = { kind: k, idx: i }; S.firDraft = null; render(); };
const chip = (k, i) => h("button", { class: "firch" + (k === kind && i === idx ? " on" : "") + (firTapsOf(chans(d, k)[i]) ? " used" : ""), "data-view-ok": "", onclick: () => pick(k, i) },
h("b", {}, chLabel(k, i)), h("small", {}, firTapsOf(chans(d, k)[i]) ? `${firTapsOf(chans(d, k)[i])} ${t("taps")}` : t("off")));
const picker = h("div", { class: "card wide" }, h("h3", {}, h("span", { class: "grow" }, t("FIR filters")),
h("span", { class: "firuse" + (used > 4096 ? " over" : "") }, t("{used} of 4096 taps in use", { used }))),
h("div", { class: "firmeter" }, h("span", { style: `width:${Math.min(100, used / 40.96)}%` })),
h("div", { class: "firchs" }, chans(d, "in").map((_, i) => chip("in", i)), h("span", { class: "firsep" }), chans(d, "out").map((_, i) => chip("out", i))));
let settings, preview = null, note = "";
if (isOut) {
if (!S.firDraft || S.firDraft.key !== key) S.firDraft = { key, ...ch.fir };
const f = S.firDraft, external = f.type === 4, changed = ["type", "window", "low", "high", "taps"].some(k => f[k] !== ch.fir[k]);
const others = used - firTapsOf(ch), needed = f.type ? firTapCount(f.taps) : 0, over = others + needed > 4096;
const set = (k, v) => { f[k] = v; render(); };
const select = (label, k, items) => h("label", {}, label, h("select", { onchange: e => set(k, +e.target.value) },
items.map((o, i) => h("option", { value: i, selected: f[k] === i }, o))));
const hz = (label, k) => h("label", {}, label, h("input", { type: "number", min: 150, max: 20000, value: f[k],
onchange: e => set(k, clamp(Math.round(+e.target.value) || f[k], 150, 20000)) }));
settings = h("div", { class: "card" }, h("h3", {}, chTitle(d, kind, idx)),
h("div", { class: "form firform" },
select(t("Type"), "type", FIR_TYPES()),
f.type && !external ? select(t("Window"), "window", FIR_WINDOWS) : null,
f.type && !external ? select(t("Taps"), "taps", Array.from({ length: 25 }, (_, i) => String(firTapCount(i)))) : null,
f.type === 2 || f.type === 3 ? hz(t("Low cut (Hz)"), "low") : null,
f.type === 1 || f.type === 3 ? hz(t("High cut (Hz)"), "high") : null),
f.type === 3 && f.low >= f.high ? h("p", { class: "err" }, t("The low cut must be below the high cut.")) : null,
over ? h("p", { class: "err" }, t("Not enough taps left: {free} free, this needs {need}.", { free: 4096 - others, need: needed })) : null,
f.type && !external && needed > 512 ? h("p", { class: "info" }, t("More than 512 taps add noticeable delay (over 10 ms at 1024).")) : null,
external
? [h("p", { class: "info" }, ch.fir.type === 4 && ch.fir.name ? t("Loaded: {name}", { name: ch.fir.name }) : t("Choose a file with up to {max} coefficients (txt or csv).", { max: 1024 })),
h("div", { class: "row" }, h("button", { class: "on", disabled: S.firBusy, onclick: () => importFir(d, kind, idx) }, S.firBusy ? t("Sending…") : t("Load file…")))]
: h("div", { class: "row lkactions" }, h("button", { class: "on", disabled: !changed || over || (f.type === 3 && f.low >= f.high), onclick: () => {
setParam(kind, idx, "fir", { type: f.type, window: f.window, low: f.low, high: f.high, taps: f.taps, name: ch.fir.name }); toast(t("FIR filter set")); render();
} }, t("Apply")), changed ? h("button", { onclick: () => { S.firDraft = null; render(); } }, t("Cancel")) : null));
if (external) { preview = loaded; note = loaded ? "" : t("The DSP can't send coefficients back, so the curve only appears after loading a file here."); }
else if (f.type) { preview = firDesign(f); note = t("Calculated by this app – the DSP calculates the filter itself, so details can differ."); }
else note = t("Filter is off.");
} else {
settings = h("div", { class: "card" }, h("h3", {}, chTitle(d, kind, idx)),
h("p", { class: "info" }, ch.fir.taps ? t("Loaded: {name} ({n} taps)", { name: ch.fir.name || "–", n: ch.fir.taps }) : t("Inputs only take filters from a file: up to {max} coefficients (txt or csv).", { max: 2048 })),
h("div", { class: "row lkactions" },
h("button", { class: "on", disabled: S.firBusy, onclick: () => importFir(d, kind, idx) }, S.firBusy ? t("Sending…") : t("Load file…")),
ch.fir.taps ? toggleBtn("Bypass", kind, idx, "fir.bypass", "bypass", () => render()) : null),
ch.fir.taps > 512 ? h("p", { class: "info" }, t("More than 512 taps add noticeable delay (over 10 ms at 1024).")) : null);
preview = ch.fir.bypass ? null : loaded;
note = ch.fir.bypass ? t("Filter is off.") : loaded ? "" : t("The DSP can't send coefficients back, so the curve only appears after loading a file here.");
}
requestAnimationFrame(() => drawFir(canvas, preview));
return h("div", { class: "cards" }, picker, settings,
h("div", { class: "card" }, h("h3", {}, t("Frequency response")), canvas, note ? h("p", { class: "info" }, note) : null));
}
// ------------------------------------------------------------------ filter response (for the PEQ curve)
const FS = 96000;
@@ -968,7 +1147,7 @@ function bessel(n, s) {
return b(s);
}
function xoverH(filter, f, high) {
if (!filter.slope) return [1, 0];
if (!filter || !filter.slope) return [1, 0];
const [kind, db] = SLOPES[filter.slope].split(" -"), n = +db / 6, x = f / freqHz(filter.freq);
const s = high ? [0, -1 / x] : [0, x]; // high pass: s -> 1/s
if (kind === "LK") { const b = butterworth(n / 2, s); return cmul(b, b); }
@@ -1178,7 +1357,7 @@ function peqCard(d, kind, idx) {
setMode(store.get("dsp.curve") || "mag");
const card = h("div", { class: "card wide" + (ch.peq_bypass ? " eq-off" : "") },
h("h3", {}, h("span", { class: "grow" }, t("Parametric EQ")), modeSeg,
toggleBtn("EQ Bypass", kind, idx, "peq_bypass", "small bypass", v => { card.classList.toggle("eq-off", v); renderBand(); redraw(); }),
d.fir ? null : toggleBtn("EQ Bypass", kind, idx, "peq_bypass", "small bypass", v => { card.classList.toggle("eq-off", v); renderBand(); redraw(); }),
h("button", { class: "small", onclick: async () => {
if (!await askConfirm(t("Reset EQ"), t("Set all PEQ bands of this channel to 0 dB and clear bypass?"), t("All flat"))) return;
chans(dev(), kind)[idx].peq.forEach((bb, i) => {
@@ -1268,11 +1447,24 @@ function viewChannel(d) {
const xo = (title, key) => h("div", { class: "xo" },
h("div", { class: "row" }, h("span", { class: "sub" }, title), paramSelect(k, i, key + ".slope", SLOPES, () => { redrawPeq(); render(); }, title)),
chans(d, k)[i][key].slope ? paramSlider(t("Frequency"), k, i, key + ".freq", "freq", redrawPeq) : h("p", { class: "info off" }, t("Off (bypass)")));
const xover = h("div", { class: "card" }, h("h3", {}, t("High- / low-pass")),
xo(t("High-pass"), "hp"), xo(t("Low-pass"), "lp"));
const xover = ch.hp ? h("div", { class: "card" }, h("h3", {}, t("High- / low-pass")),
xo(t("High-pass"), "hp"), xo(t("Low-pass"), "lp")) : null;
const cards = [basics, xover];
if (k === "in") {
const cards = [basics, xover].filter(Boolean);
const dynCard = (title, key, thresh) => h("div", { class: "card" }, h("h3", {}, title),
paramSlider("Threshold", k, i, key + ".threshold", thresh),
paramSlider("Ratio", k, i, key + ".ratio", "ratio"),
paramSlider("Attack", k, i, key + ".attack", "attack"),
paramSlider("Release", k, i, key + ".release", "release"),
paramSlider("Knee", k, i, key + ".knee", "knee"));
if (d.fir && k === "in") {
cards.push(h("div", { class: "card" }, h("h3", {}, "Noise Gate"),
paramSlider("Threshold", k, i, "gate.threshold", "gthresh"),
paramSlider("Attack", k, i, "gate.attack", "attack"),
paramSlider("Hold", k, i, "gate.hold", "hold"),
paramSlider("Release", k, i, "gate.release", "release")));
cards.push(dynCard(t("Compressor"), "comp", "thresh"), peqCard(d, k, i));
} else if (k === "in") {
cards.push(h("div", { class: "card" }, h("h3", {}, "Noise Gate"),
paramSlider("Threshold", k, i, "gate.threshold", "gthresh"),
paramSlider("Attack", k, i, "gate.attack", "attack"),
@@ -1281,7 +1473,7 @@ function viewChannel(d) {
cards.push(peqCard(d, k, i), geqCard(d, i));
} else {
cards.push(routingCard(d, i), peqCard(d, k, i));
cards.push(h("div", { class: "card" }, h("h3", {}, t("Compressor")),
if (ch.comp) cards.push(h("div", { class: "card" }, h("h3", {}, t("Compressor")),
paramSlider("Threshold", k, i, "comp.threshold", "thresh"),
paramSlider("Ratio", k, i, "comp.ratio", "ratio"),
paramSlider("Attack", k, i, "comp.attack", "attack"),
@@ -1349,18 +1541,40 @@ function viewRouting(d) {
async function saveLinks(d, kind, groups, msg) {
S.linkBusy = true; render();
try { await api("POST", `/api/devices/${d.id}/link`, { kind, groups }); toast(msg); }
let ok = false;
try { await api("POST", `/api/devices/${d.id}/link`, { kind, groups }); toast(msg); ok = true; }
catch (e) { toast(t("Error: ") + e.message); }
S.linkBusy = false; S.linkSel[kind] = []; render();
S.linkBusy = false; S.linkSel[kind] = []; S.linkEdit[kind] = null; render();
return ok;
}
function linkNameInput(d, kind, g) {
const input = h("input", { type: "text", class: "lkname-in", maxlength: 16, value: linkName(d, kind, g),
placeholder: t("Group name"), "aria-label": t("Group name"), autocomplete: "off", spellcheck: "false", enterkeyhint: "done" });
const save = async () => {
const v = input.value.trim();
if (v === linkName(dev(), kind, g)) return;
const next = { ...(dev().linknames || {}) };
if (v) next[linkKey(kind, g)] = v; else delete next[linkKey(kind, g)];
try { await api("POST", `/api/devices/${d.id}/linknames`, { linknames: next }); toast(v ? t("Group name saved") : t("Group name removed")); }
catch (e) { toast(t("Error: ") + trMsg(e.message)); }
};
input.addEventListener("change", save);
input.addEventListener("keydown", e => { if (e.key === "Enter") input.blur(); });
return input;
}
function linkCard(d, kind) {
const list = chans(d, kind), linked = linkedGroups(d, kind);
const sel = S.linkSel[kind] = S.linkSel[kind].filter(i => i < list.length && !linkInfo(d, kind, i));
// editing an existing group: its members start selected, channels of other groups stay locked
let edit = S.linkEdit[kind];
if (edit && !linked.some(g => linkKey(kind, g) === linkKey(kind, edit))) edit = S.linkEdit[kind] = null; // changed meanwhile
const free = i => !linkInfo(d, kind, i) || (edit && edit.includes(i));
const sel = S.linkSel[kind] = S.linkSel[kind].filter(i => i < list.length && free(i));
const btns = list.map((ch, i) => {
const l = linkInfo(d, kind, i), on = sel.includes(i);
return h("button", { class: "lkch" + (on ? " sel" : "") + (l ? " taken" : ""), style: l ? `--lc:${l.color}` : "", "aria-pressed": String(on),
title: l ? t("Already linked – unlink the group first") : "", disabled: S.linkBusy || !!l, onclick: () => { S.linkSel[kind] = on ? sel.filter(j => j !== i) : [...sel, i].sort((a, b) => a - b); render(); } },
const l = linkInfo(d, kind, i), on = sel.includes(i), locked = !free(i);
return h("button", { class: "lkch" + (on ? " sel" : "") + (locked ? " taken" : ""), style: l ? `--lc:${custColor(d, kind, i) || l.color}` : "", "aria-pressed": String(on),
title: locked ? t("Already linked – unlink the group first") : "", disabled: S.linkBusy || locked, onclick: () => { S.linkSel[kind] = on ? sel.filter(j => j !== i) : [...sel, i].sort((a, b) => a - b); render(); } },
h("b", {}, chLabel(kind, i)), h("small", {}, ch.name || "\u00a0"),
h("span", { class: "lkmark" }, l ? svgIcon(ICON.link) : null));
});
@@ -1372,19 +1586,67 @@ function linkCard(d, kind) {
const rest = linked.map(g => g.filter(i => !sel.includes(i))).filter(g => g.length > 1);
saveLinks(d, kind, [...rest, sel], t("{names} linked", { names }));
};
const unlink = g => saveLinks(d, kind, linked.filter(x => x !== g), t("{names} unlinked", { names: g.map(i => chLabel(kind, i)).join(" + ") }));
return h("div", { class: "card" }, h("h3", {}, kind === "in" ? t("Inputs") : t("Outputs")),
const label = g => g.map(i => chLabel(kind, i)).join(" + ");
const unlink = async g => {
const names = label(g);
if (!await askConfirm(t("Unlink group"), t("Unlink {names}? Every channel keeps its current settings.", { names }), t("Unlink"), true)) return;
if (await saveLinks(d, kind, linked.filter(x => linkKey(kind, x) !== linkKey(kind, g)), t("{names} unlinked", { names }))) moveLinkName(d, kind, g, null);
};
const startEdit = g => { S.linkEdit[kind] = g.slice(); S.linkSel[kind] = g.slice(); render(); };
const cancelEdit = () => { S.linkEdit[kind] = null; S.linkSel[kind] = []; render(); };
const saveEdit = async () => {
const next = sel.slice(), added = next.filter(i => !edit.includes(i)), removed = edit.filter(i => !next.includes(i));
if (!added.length && !removed.length) return cancelEdit();
const others = linked.filter(g => linkKey(kind, g) !== linkKey(kind, edit));
if (next.length < 2) return unlink(edit); // one channel alone is no group
const lines = [
added.length ? t(added.length > 1 ? "{names} join the group and take over its settings (names{routing} stay)."
: "{names} joins the group and takes over its settings (name{routing} stays).", { names: label(added), routing: kind === "out" ? t(" and routing") : "" }) : null,
removed.length ? t(removed.length > 1 ? "{names} leave the group and keep their current settings."
: "{names} leaves the group and keeps its current settings.", { names: label(removed) }) : null];
if (!await askConfirm(t("Change group"), lines.filter(Boolean).join(" "), t("Save"))) return;
// the DSP copies the first channel's settings to the others – a new first channel gets the group's settings beforehand
if (next[0] !== edit[0] && !edit.includes(next[0])) {
try {
await api("POST", "/api/copy", { device: d.id, kind, idx: edit[0], groups: ["level", "filters", "eq", "dynamics"],
targets: [{ device: d.id, idx: next[0] }] });
} catch (e) { toast(t("Error: ") + trMsg(e.message)); return; }
}
if (await saveLinks(d, kind, [...others, next], t("Group changed: {names}", { names: label(next) }))) moveLinkName(d, kind, edit, next);
};
const editing = !!edit;
return h("div", { class: "card" + (editing ? " lkediting" : "") }, h("h3", {}, kind === "in" ? t("Inputs") : t("Outputs")),
h("div", { class: "lkgrid" }, btns),
h("div", { class: "row lkactions" },
editing
? h("div", { class: "row lkactions" },
h("span", { class: "grow info" }, sel.length < 2 ? t("Fewer than two channels – the group will be dissolved")
: t("Edit {names}: tap channels to add or remove them", { names: label(edit) })),
h("button", { disabled: S.linkBusy, onclick: cancelEdit }, t("Cancel")),
h("button", { class: sel.length < 2 ? "danger-on" : "on", disabled: S.linkBusy, onclick: saveEdit }, sel.length < 2 ? t("Dissolve group") : t("Save")))
: h("div", { class: "row lkactions" },
h("span", { class: "grow info" }, sel.length < 2 ? t("Tap at least two channels") : t("{n} channels selected", { n: sel.length })),
h("button", { class: "on", disabled: sel.length < 2 || S.linkBusy, onclick: link }, t("Link"))),
linked.length ? h("div", { class: "lkgroups" }, linked.map((g, n) =>
h("div", { class: "row lkgroup", style: `--lc:${LINK_COLORS[n % LINK_COLORS.length]}` },
svgIcon(ICON.link), h("span", { class: "grow" }, g.map(i => chLabel(kind, i)).join(" + ")),
h("button", { class: "small", disabled: S.linkBusy, onclick: () => unlink(g) }, t("Unlink")))))
linked.length ? h("div", { class: "lkgroups" }, linked.map((g, n) => {
const mine = editing && linkKey(kind, g) === linkKey(kind, edit);
return h("div", { class: "lkgroup" + (mine ? " editing" : editing ? " dim" : ""), style: `--lc:${custColor(d, kind, g[0]) || LINK_COLORS[n % LINK_COLORS.length]}` },
h("div", { class: "row" }, svgIcon(ICON.link), h("span", { class: "grow lkmembers" }, label(g)),
h("button", { class: "small", disabled: S.linkBusy || editing, onclick: () => startEdit(g) }, t("Edit")),
h("button", { class: "small", disabled: S.linkBusy || editing, onclick: () => unlink(g) }, t("Unlink"))),
linkNameInput(d, kind, g));
}))
: h("p", { class: "info" }, t("No channels linked.")));
}
// a group's name follows it when its members change (to = null: the group is gone)
async function moveLinkName(d, kind, from, to) {
const names = { ...(dev().linknames || {}) }, name = names[linkKey(kind, from)];
if (!name) return;
delete names[linkKey(kind, from)];
if (to) names[linkKey(kind, to)] = name;
try { await api("POST", `/api/devices/${d.id}/linknames`, { linknames: names }); }
catch (e) { toast(t("Error: ") + trMsg(e.message)); }
}
// channel colours of the current DSP: one row per channel or link group
function colorCard(d) {
const row = (kind, g) => {
@@ -1436,7 +1698,7 @@ function maxLevelCard(d) {
function viewLink(d) {
return [h("h2", { class: "section" }, t("Links")),
h("div", { class: "cards" }, linkCard(d, "in"), linkCard(d, "out")),
h("p", { class: "info hint" }, t("Linked channels share all settings (gain, delay, filters, EQ, dynamics, mute) – ") +
h("p", { class: "info" }, t("Linked channels share all settings (gain, delay, filters, EQ, dynamics, mute) – ") +
t("a change on one channel applies to the whole group. Name, routing and mix levels stay per channel. ") +
t("The link is stored in the DSP and also applies in the Thomann editor.")),
h("h2", { class: "section" }, t("Colours")),
@@ -1640,8 +1902,8 @@ function limiterCard(d, o) {
res,
h("div", { class: "limgrid" },
h("label", { class: "full" }, t("Amplifier"), ampSel),
h("label", {}, t("Load on channel"), ohmSel),
h("label", {}, t("Speaker RMS (W)"), spkIn)),
as ? h("label", {}, t("Load on channel"), ohmSel) : null,
as ? h("label", {}, t("Speaker RMS (W)"), spkIn) : null),
paramSlider("Threshold", "out", o, "limit.threshold", "thresh", update),
as ? h("div", { class: "target" },
h("div", { class: "row" }, h("span", { class: "sub" }, t("Limit to")), target,
@@ -1689,9 +1951,10 @@ function timingBox(d, o) {
h("b", {}, p.name), h("small", {}, p.range));
const box = h("details", { class: "more", open: limOpen.has(key),
ontoggle: () => box.open ? limOpen.add(key) : limOpen.delete(key) },
h("summary", {}, `Attack ${lim.attack + 1} ms · Release ${lim.release + 1} ms · Knee ${lim.knee} dB`,
h("summary", {}, `${"ratio" in lim ? `Ratio ${RATIOS[lim.ratio]} · ` : ""}Attack ${lim.attack + 1} ms · Release ${lim.release + 1} ms · Knee ${lim.knee} dB`,
active ? h("span", { class: "tag" }, active.name) : null),
h("div", { class: "chips presets" }, chip(auto), LIM_PRESETS.map(chip)),
"ratio" in lim ? paramSlider("Ratio", "out", o, "limit.ratio", "ratio") : null,
paramSlider("Attack", "out", o, "limit.attack", "attack"),
paramSlider("Release", "out", o, "limit.release", "release"),
paramSlider("Knee", "out", o, "limit.knee", "knee"),
@@ -1853,12 +2116,17 @@ function deviceForm(d) {
name: h("input", { type: "text", value: d.name, placeholder: t("e.g. DSP 204 stage") }),
host: h("input", { type: "text", value: d.host, placeholder: "192.168.1.101", inputmode: "decimal" }),
port: h("input", { type: "number", value: d.port }),
model: h("select", {}, [["auto", t("Automatic")], ["204", "DSP 204"], ["408", "DSP 408"]]
model: h("select", {}, [["auto", t("Automatic")], ["204", "DSP 204"], ["408", "DSP 408"],
["206", "DSP 206 (Beta)"], ["408fir", "FIR DSP 408 (Beta)"]]
.map(([v, label]) => h("option", { value: v, selected: d.model === v }, label))),
autoconnect: h("input", { type: "checkbox", checked: d.autoconnect }),
addr: h("input", { type: "number", min: 1, max: 250, value: d.addr || 1, class: "short" }),
usb: h("select", { "aria-label": t("USB device") }),
};
const betaNote = h("p", { class: "info betanote full", hidden: true },
t("Beta: this model has not been tested on a real device yet. Keep the amplifiers off for the first test."));
const showBeta = () => { betaNote.hidden = !isNew || !f.model.value || !BETA_MODELS.includes(f.model.value); };
f.model.addEventListener("change", showBeta);
let transport = d.transport || "tcp";
// USB device list (both DSP models share one USB ID, so several are told apart by port/path)
const fillUsb = list => {
@@ -1921,6 +2189,7 @@ function deviceForm(d) {
...netRows, usbRow,
h("label", {}, t("Model"), f.model),
h("label", { class: "chk" }, f.autoconnect, t("Connect automatically")),
betaNote,
h("details", { class: "more full" }, h("summary", {}, t("Advanced")),
h("label", { class: "inline idrow" }, t("Device ID"), f.addr),
h("p", { class: "info" }, t("Only needed if the ID was changed on the DSP (e.g. several DSPs on one RS-485 cable). Default 1."))),
@@ -2089,7 +2358,7 @@ async function scanDialog() {
const list = await api("POST", "/api/scan");
const used = new Set(S.order.map(id => S.devices[id].host));
box.replaceChildren(...(list.length ? list.map(x => {
const title = x.model ? `DSP ${x.model}` : t("Unknown device");
const title = MODEL_LABEL[x.model] || t("Unknown device");
const add = async b => {
b.disabled = true;
try {
@@ -2159,8 +2428,10 @@ function render() {
let content;
const d = dev();
const field = !S.settings && S.view === "soundfield"; // the room plan works without a connected DSP
document.body.dataset.view = field ? "soundfield" : S.settings || !d ? "settings" : S.view;
const dash = !S.settings && S.view === "dash"; // shows all DSPs, works without any
document.body.dataset.view = field ? "soundfield" : dash ? "dash" : S.settings || !d ? "settings" : S.view;
if (field) content = viewSoundField();
else if (dash) content = viewDash();
else if (S.settings || !d) content = viewSettings();
else if (d.status !== "online" || !d.state)
content = h("div", { class: "empty" }, h("div", { class: "spinner" + (["loading", "connecting"].includes(d.status) ? "" : " off") }),
@@ -2169,7 +2440,7 @@ function render() {
: d.status === "locked" ? h("div", {}, h("p", {}, t("This DSP is locked with a code.")),
h("button", { class: "on", onclick: () => unlockDialog(d) }, t("Enter code")))
: S.demo.enabled && !d.demo ? t("Disconnected while demo mode is on") : t("Not connected."));
else content = ({ mixer: viewMixer, channel: viewChannel, routing: viewRouting, link: viewLink, limiter: viewLimiter, test: viewTest }[S.view] || viewMixer)(d);
else content = ({ mixer: viewMixer, channel: viewChannel, routing: viewRouting, link: viewLink, fir: d.fir ? viewFir : viewMixer, limiter: viewLimiter, test: viewTest }[S.view] || viewMixer)(d);
main.replaceChildren(...[content].flat().filter(Boolean));
main.querySelectorAll(H_SCROLL).forEach((e, i) => { if (xs[i]) e.scrollLeft = xs[i]; });
window.scrollTo(0, y);
@@ -2195,7 +2466,7 @@ function fitNav() {
const kids = [...top.children].filter(el => !el.hidden && getComputedStyle(el).display !== "none");
const cs = getComputedStyle(top), gap = parseFloat(cs.columnGap) || 0;
// natural widths: the DSP button may be squeezed by flexbox, so take its content width
const need = kids.reduce((w, el) => w + (el.id === "devtabs" ? el.scrollWidth : el.getBoundingClientRect().width), 0)
const need = kids.reduce((w, el) => w + (el.id === "devtabs" ? Math.max(el.scrollWidth, 210) : el.getBoundingClientRect().width), 0)
+ gap * (kids.length - 1) + parseFloat(cs.paddingLeft) + parseFloat(cs.paddingRight);
if (need > top.clientWidth + 1) b.classList.add("navside");
}
@@ -2210,10 +2481,28 @@ new ResizeObserver(() => document.documentElement.style.setProperty("--sb", $("#
// ------------------------------------------------------------------ lock (desktop app window: look, don't touch)
// Phones and tablets on the web UI start read-only, so nothing changes by touching it by accident.
// Only a safety catch in this browser tab: it is not stored and the server knows nothing about it.
const viewOnly = () => !!S.locked || !!S.guard;
function showGuard() {
const b = $("#btn-guard"), used = !S.isApp && S.guardUsed;
b.hidden = !used;
b.setAttribute("aria-checked", String(!S.guard));
b.classList.toggle("on", !S.guard);
b.title = S.guard ? t("Read-only – tap to edit") : t("Editing – tap for read-only");
b.setAttribute("aria-label", b.title);
b.replaceChildren(h("span", { class: "guardlab" }, S.guard ? t("View") : t("Edit")), h("span", { class: "guardtrack" }, h("i")));
document.body.classList.toggle("locked", viewOnly());
}
$("#btn-guard").addEventListener("click", () => {
S.guard = !S.guard; showGuard(); render();
toast(S.guard ? t("Read-only") : t("Edit mode – changes go to the DSP"));
});
function showLock() {
const b = $("#btn-lock");
b.hidden = !S.isApp;
document.body.classList.toggle("locked", !!S.locked);
document.body.classList.toggle("locked", viewOnly());
b.classList.toggle("on", !!S.locked);
b.title = S.locked ? t("Locked – click to unlock") : t("Lock (view only)");
b.setAttribute("aria-label", b.title);
@@ -2245,14 +2534,14 @@ $("#btn-lock").addEventListener("click", async () => {
const VIEW_OK = ".chsel, .nav, .strip-head, .xout, .band, #btn-muteall, [data-view-ok]";
for (const type of ["pointerdown", "mousedown", "click", "dblclick", "keydown", "wheel"]) {
document.addEventListener(type, e => {
if (!S.locked || !(e.target instanceof Element)) return;
if (!viewOnly() || !(e.target instanceof Element)) return;
const tgt = e.target;
if (!tgt.closest("#main, #statusbar") || tgt.closest(VIEW_OK)) return;
if (type === "wheel" && !tgt.closest(".fader, input, select")) return; // page scrolling stays
if (type === "keydown" && !tgt.closest("button, input, select, textarea, .fader, [tabindex]")) return;
if (type === "pointerdown" && !tgt.closest("button, input, select, textarea, .fader, canvas, a")) return;
e.preventDefault(); e.stopPropagation();
if (type === "click" && Date.now() - (S.lockToast || 0) > 1500) { S.lockToast = Date.now(); toast(t("Locked – unlock at the top right to make changes")); }
if (type === "click" && Date.now() - (S.lockToast || 0) > 1500) { S.lockToast = Date.now(); toast(S.locked ? t("Locked – unlock at the top right to make changes") : t("Read-only – switch to edit at the top")); }
}, { capture: true, passive: false });
}
@@ -2275,6 +2564,7 @@ function connectEvents() {
if (ev.demo) S.demo = ev.demo;
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;
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]));
@@ -2307,6 +2597,8 @@ function connectEvents() {
}
case "soundfield":
sfOnRemote(ev.data); break;
case "dashboard":
dashRemote(ev.data); break;
case "logo":
S.logo = ev.data; showLogo(); if (S.settings) render(); break;
case "muteall":
@@ -2323,6 +2615,7 @@ function connectEvents() {
if (JSON.stringify(getPath(ch, ev.param)) === JSON.stringify(ev.value)) break;
setPath(ch, ev.param, ev.value);
showLive(`${ev.device}|${ev.kind}|${ev.idx}|${ev.param}`, ev.value); // even while a fader is held
if (S.view === "dash") dashSoon();
// the test fader moves every output: the audio test view only shows meters, no need to redraw
if (ev.device === S.cur && !S.settings && !(S.view === "test" && ev.param === "gain")) render();
break;
@@ -2334,7 +2627,7 @@ function connectEvents() {
updateMeters(ev); break;
case "limiter":
S.lim = ev.data;
if (!S.busy && (S.view === "limiter" || S.view === "channel")) render();
if (!S.busy && (S.view === "limiter" || S.view === "channel" || S.view === "dash")) render();
break;
}
};
@@ -2419,6 +2712,9 @@ async function startApp() {
if (store.get("dsp.lang") === a.lang) return location.reload();
}
S.locked = !!a.locked;
S.guardUsed = !S.isApp && matchMedia("(max-width: 759px), (pointer: coarse)").matches;
S.guard = S.guardUsed;
showGuard();
showLock();
showMuteAll();
if (S.isApp) S.remote = await api("GET", "/api/remote");
+400
View File
@@ -0,0 +1,400 @@
"use strict";
// Dashboard: an overview page built from modules, stored by the server as `dashboard` in config.json.
// Every module only looks: nothing here changes a DSP. Browsing (channel, EQ band) stays in this session.
const DASH_ROW = 40; // grid row + gap in px, see .dash
const DASH_DEFAULT = () => [
{ type: "status", w: 4 }, { type: "meters", w: 8 },
{ type: "curve", w: 8 }, { type: "mixer", w: 4 },
].map((m, i) => ({ id: `m${i}`, cfg: {}, ...m }));
let dashEdit = false, dashTimer = 0, dashSaveTimer = 0;
const dashBrowse = new Map(); // module id -> { kind, idx, band }
const dashMods = () => S.dash || (S.dash = DASH_DEFAULT());
const dashDevs = () => S.order.map(id => S.devices[id]).filter(d => d && (!d.demo || S.demo.enabled));
// the chosen DSP, or the first one if it is gone (e.g. while demo mode is on)
const dashDev = m => S.devices[m.cfg.device] && dashDevs().includes(S.devices[m.cfg.device]) ? S.devices[m.cfg.device] : dashDevs()[0];
const offline = d => h("p", { class: "info dempty" }, d ? t("{name} is not connected.", { name: d.name }) : t("No DSP added yet."));
function dashSave() {
clearTimeout(dashSaveTimer);
dashSaveTimer = setTimeout(() => api("PUT", "/api/dashboard", { modules: dashMods() }).catch(e => toast(t("Error: ") + trMsg(e.message))), 300);
}
// parameter changes redraw the page, but not for every single step of a fader
function dashSoon() {
clearTimeout(dashTimer);
dashTimer = setTimeout(() => { if (S.view === "dash" && !S.settings) render(); }, 250);
}
function dashRemote(data) {
S.dash = data && data.modules ? data.modules : null;
if (S.view === "dash" && !S.settings && !S.busy) render();
}
// ------------------------------------------------------------------ modules
const dashKv = (k, v, cls = "") => h("div", { class: "dkv " + cls }, h("span", {}, k), h("b", {}, v));
const dashChannels = d => [...chans(d, "in").map((_, i) => ["in", i]), ...chans(d, "out").map((_, i) => ["out", i])];
// a channel of a module, browsed with the arrows
function dashSel(m, d) {
const all = dashChannels(d);
let s = dashBrowse.get(m.id);
if (!s) { s = { kind: m.cfg.kind || "in", idx: m.cfg.idx || 0, band: 0 }; dashBrowse.set(m.id, s); }
if (!all.some(([k, i]) => k === s.kind && i === s.idx)) { s.kind = all[0][0]; s.idx = all[0][1]; }
return s;
}
function dashChannelNav(m, d, s) {
const all = dashChannels(d), at = all.findIndex(([k, i]) => k === s.kind && i === s.idx);
const go = dir => { const [k, i] = all[(at + dir + all.length) % all.length]; s.kind = k; s.idx = i; s.band = 0; render(); };
const ch = chans(d, s.kind)[s.idx];
return h("div", { class: "dnav" },
h("button", { class: "small", "data-view-ok": "", "aria-label": t("Previous channel"), onclick: () => go(-1) }, "‹"),
h("span", { class: "dnavname" }, h("b", {}, chLabel(s.kind, s.idx)), " ", ch.name),
h("button", { class: "small", "data-view-ok": "", "aria-label": t("Next channel"), onclick: () => go(1) }, "›"));
}
// link groups in the level meters: a soft tile in the group colour behind the meters, the name at its top
function dashGroups(d, kind) {
const out = [];
linkedGroups(d, kind).forEach(g => {
const color = custColor(d, kind, g[0]) || linkInfo(d, kind, g[0]).color, name = linkName(d, kind, g);
const title = (name ? name + " · " : "") + g.map(i => chLabel(kind, i)).join(" + ");
g.forEach((j, n) => {
if (n && g[n - 1] === j - 1) return;
let len = 1;
while (g.includes(j + len)) len++;
const area = `--lc:${color};grid-column:${j + 1} / span ${len}`;
out.push(h("div", { class: "dgrp", style: area, title }));
if (name && len > 1) out.push(h("div", { class: "dgrpname", style: area, title }, name)); // a single meter has no room for it
});
});
return out;
}
const dashLabelColor = (d, k, i) => {
const l = linkInfo(d, k, i);
return l ? custColor(d, k, i) || l.color : custColor(d, k, i) || (k === "in" ? IN_COLORS[i] : "var(--warn)");
};
const DASH_MODULES = {
status: {
title: () => t("DSP overview"), w: 4, min: [3, 3], max: [12, 14], h: () => 2 + Math.ceil(dashDevs().length * 1.2), global: true,
icon: '<rect x="3" y="4" width="18" height="6" rx="1.5"/><rect x="3" y="14" width="18" height="6" rx="1.5"/><path d="M7 7h.01M7 17h.01"/>',
body() {
const list = dashDevs();
if (!list.length) return offline();
return h("div", { class: "dlist" }, list.map(d => h("button", { class: "drow dlink", "data-view-ok": "", title: t("Open in the mixer"),
onclick: () => { S.cur = d.id; S.view = "mixer"; store.set("dsp.view", "mixer"); render(); window.scrollTo(0, 0); } },
h("span", { class: "dot " + d.status }),
h("span", { class: "grow dname" }, h("b", {}, d.name), h("small", {}, [MODEL_LABEL[d.detected_model || d.model] || "", d.state ? d.state.preset_name : (STATUS_TEXT[d.status] || d.status)].filter(Boolean).join(" · "))),
d.state && dashChannels(d).some(([k, i]) => chans(d, k)[i].mute) ? h("span", { class: "dtag mute" }, "MUTE") : null)));
},
},
meters: {
title: () => t("Levels"), w: 8, min: [3, 5], max: [12, 14], h: 7,
icon: '<path d="M5 20V10M10 20V4M15 20v-7M20 20V8"/>',
body(m, d) {
const col = (k, i) => h("div", { class: "dm" + (chans(d, k)[i].mute ? " muted" : ""), title: chTitle(d, k, i), style: `grid-column:${i + 1}` },
ledMeter(d.id, k, i), k === "out" ? limLed(d.id, i) : h("span", { class: "limled ph", "aria-hidden": "true" }));
const numberOf = (k, i) => h("small", { class: "dmlab", style: `color:${dashLabelColor(d, k, i)};grid-column:${i + 1}` }, chLabel(k, i).replace("Out ", "").replace("In ", ""));
const group = (k, label) => h("div", { class: "dmgroup", style: `flex-grow:${chans(d, k).length}` }, h("div", { class: "sub" }, label), h("div", { class: "dms", style: `--n:${chans(d, k).length}` }, chans(d, k).map((_, i) => col(k, i)), dashGroups(d, k), chans(d, k).map((_, i) => numberOf(k, i))));
const named = ["in", "out"].some(k => linkedGroups(d, k).some(g => linkName(d, k, g)));
return h("div", { class: "dmeters" + (named ? " hasnames" : "") }, group("in", t("Inputs")), group("out", t("Outputs")));
},
},
mixer: {
title: () => t("Faders"), w: 4, min: [3, 4], max: [8, 14], h: d => (d && d.state ? 2 + Math.ceil(dashChannels(d).length * 0.8) : 5),
icon: '<path d="M6 3v18M12 3v18M18 3v18"/><rect x="3.5" y="13" width="5" height="3" rx="1"/><rect x="9.5" y="7" width="5" height="3" rx="1"/><rect x="15.5" y="10" width="5" height="3" rx="1"/>',
body(m, d) {
const row = (k, i) => {
const ch = chans(d, k)[i];
return h("div", { class: "drow dgain" + (ch.mute ? " muted" : ""), style: ccStyle(d, k, i) },
h("span", { class: "dlab" }, chLabel(k, i)),
h("span", { class: "dbar" }, h("i", { style: `width:${ch.gain / 4}%` }), h("u")),
h("span", { class: "dval" }, ch.mute ? "MUTE" : `${sign(gainDb(ch.gain))} dB`));
};
return h("div", { class: "dlist" }, chans(d, "in").map((_, i) => row("in", i)), h("hr"), chans(d, "out").map((_, i) => row("out", i)));
},
},
curve: {
title: () => t("Frequency response"), w: 8, min: [4, 7], max: [12, 16], h: 9,
icon: '<path d="M2 14c3 0 3-7 6-7s3 10 6 10 3-6 6-6h2"/>',
body(m, d) {
const s = dashSel(m, d), ch = chans(d, s.kind)[s.idx];
if (s.band >= ch.peq.length) s.band = 0;
const canvas = h("canvas", { class: "dcurve" });
const shown = (m.cfg.overlays || []).map(key => {
const k = key.startsWith("in") ? "in" : "out", i = +key.replace(/\D/g, "");
return i < chans(d, k).length && !(k === s.kind && i === s.idx) ? { k, i, ch: chans(d, k)[i], color: chColor(d, k, i) } : null;
}).filter(Boolean);
requestAnimationFrame(() => drawCurve(canvas, ch, s.band, { mode: "mag", overlays: shown }));
const b = ch.peq[s.band];
return [dashChannelNav(m, d, s), canvas,
shown.length ? h("div", { class: "dlegend" }, shown.map(o => h("span", {}, h("i", { style: `background:${o.color}` }), chLabel(o.k, o.i)))) : null,
h("div", { class: "dbands" }, ch.peq.map((bb, i) => h("button", { class: "dband" + (i === s.band ? " on" : "") + (bb.bypass ? " off" : "") + (bb.gain !== 120 ? " act" : ""), "data-view-ok": "",
onclick: () => { s.band = i; render(); } }, h("b", {}, i + 1), h("small", {}, fmtHzShort(freqHz(bb.freq)))))),
h("p", { class: "info dbandinfo" }, `${PEQ_TYPES[b.type]} · ${SPEC.freq.fmt(b.freq)} · ${sign((b.gain - 120) / 10)} dB · Q ${Q_TABLE[b.q]}${b.bypass ? " · Bypass" : ""}`)];
},
},
channel: {
title: () => t("Channel"), w: 4, min: [3, 6], max: [8, 12], h: 9,
icon: '<circle cx="12" cy="12" r="8"/><path d="M12 8v4l3 2"/>',
body(m, d) {
const s = dashSel(m, d), ch = chans(d, s.kind)[s.idx];
const filt = f => (f && f.slope ? `${SLOPES[f.slope]} @ ${SPEC.freq.fmt(f.freq)}` : t("off"));
const on = ch.peq.filter(b => !b.bypass && b.gain !== 120).length;
return [dashChannelNav(m, d, s), h("div", { class: "dkvs" },
dashKv("Gain", ch.mute ? "MUTE" : SPEC.gain.fmt(ch.gain), ch.mute ? "bad" : ""),
dashKv("Delay", SPEC.delay.fmt(ch.delay)),
dashKv("Phase", ch.polarity ? "180°" : "0°"),
ch.hp ? dashKv(t("High-pass"), filt(ch.hp)) : null,
ch.lp ? dashKv(t("Low-pass"), filt(ch.lp)) : null,
dashKv("EQ", on ? t("{n} bands active", { n: on }) : t("flat")),
s.kind === "out" ? dashKv(t("Sources"), chans(d, "in").map((_, i) => (ch.matrix >> i & 1 ? chLabel("in", i) : "")).filter(Boolean).join(", ") || "–") : null,
s.kind === "out" ? dashKv("Limiter", SPEC.thresh.fmt(ch.limit.threshold)) : null,
s.kind === "in" ? dashKv("Gate", SPEC.gthresh.fmt(ch.gate.threshold)) : null)];
},
},
limiter: {
title: () => "Limiter", w: 4, min: [3, 3], max: [8, 12], h: d => (d && d.state ? 2 + Math.ceil(chans(d, "out").length * 0.8) : 5),
icon: '<path d="M2 7h20" stroke-dasharray="2.5 2.5"/><path d="M2 14c2 0 3-7 5-7h3c2 0 3 11 6 11s3-5 6-5"/>',
body(m, d) {
return h("div", { class: "dlist" }, chans(d, "out").map((ch, o) => {
const c = limCalc(d.id, o, ch.limit.threshold);
return h("div", { class: "drow" }, limLed(d.id, o), h("span", { class: "dlab" }, chLabel("out", o)),
h("span", { class: "grow dsub" }, c ? c.amp.name : ""),
h("b", { class: "dval" }, c ? fmtW(c.p) : SPEC.thresh.fmt(ch.limit.threshold)));
}));
},
},
routing: {
title: () => "Routing", w: 4, min: [3, 3], max: [8, 12], h: d => (d && d.state ? 2 + Math.ceil((chans(d, "out").length + 1) * 0.5) : 5),
icon: '<path d="M4 6h16M4 12h16M4 18h16M8 3v18M16 3v18"/>',
body(m, d) {
const ins = chans(d, "in");
return h("div", { class: "dmatrix", style: `--n:${ins.length}` },
h("span"), ins.map((_, i) => h("b", { style: `color:${inColor(d, i)}` }, chLabel("in", i).replace("In ", ""))),
chans(d, "out").flatMap((ch, o) => [h("span", {}, chLabel("out", o)),
...ins.map((_, i) => h("i", { class: ch.matrix >> i & 1 ? "on" : "", style: `--c:${inColor(d, i)}`, title: `${chLabel("in", i)} → ${chLabel("out", o)}` }))]));
},
},
delays: {
title: () => "Delay", w: 4, min: [3, 3], max: [8, 14], h: d => (d && d.state ? 2 + Math.ceil(dashChannels(d).length * 0.8) : 5),
icon: '<circle cx="12" cy="13" r="8"/><path d="M12 9v4l2 2M9 2h6"/>',
body(m, d) {
const row = (k, i) => {
const ch = chans(d, k)[i];
return h("div", { class: "drow" + (ch.delay ? "" : " zero") }, h("span", { class: "dlab" }, chLabel(k, i)), h("span", { class: "grow dsub" }, ch.name), h("b", { class: "dval" }, SPEC.delay.fmt(ch.delay)));
};
return h("div", { class: "dlist" }, dashChannels(d).map(([k, i]) => row(k, i)));
},
},
fir: {
title: () => t("FIR filters"), w: 4, min: [3, 3], max: [8, 12], h: 5, only: () => dashDevs().some(d => d.fir),
icon: '<path d="M2 12h3l2-7 3 14 3-11 2 6 2-3 1 1h4"/>',
body(m, d) {
if (!d.fir) return h("p", { class: "info dempty" }, t("{name} has no FIR filters.", { name: d.name }));
const used = firUsed(d);
const list = dashChannels(d).filter(([k, i]) => firTapsOf(chans(d, k)[i]));
return [h("div", { class: "firmeter" }, h("span", { style: `width:${Math.min(100, used / 40.96)}%` })),
h("p", { class: "info" }, t("{used} of 4096 taps in use", { used })),
list.length ? h("div", { class: "dlist" }, list.map(([k, i]) => {
const f = chans(d, k)[i].fir;
return h("div", { class: "drow" }, h("span", { class: "dlab" }, chLabel(k, i)),
h("span", { class: "grow dsub" }, "type" in f ? FIR_TYPES()[f.type] : f.name), h("b", { class: "dval" }, firTapsOf(chans(d, k)[i])));
})) : null];
},
},
notes: {
title: () => t("Notes"), w: 4, min: [2, 2], max: [12, 14], h: 4, global: true,
icon: '<path d="M5 3h14v18H5zM9 8h6M9 12h6M9 16h3"/>',
body(m) { return m.cfg.text ? h("p", { class: "dnote" }, m.cfg.text) : h("p", { class: "info dempty" }, t("Empty – add text in the module settings.")); },
},
};
// ------------------------------------------------------------------ editing
function dashAdd(type, at = dashMods().length) {
const mods = dashMods(), def = DASH_MODULES[type];
const id = "m" + Date.now().toString(36) + Math.floor(Math.random() * 1296).toString(36);
const d = dashDevs()[0];
const m = { id, type, w: def.w, cfg: def.global || !d ? {} : { device: d.id } };
mods.splice(at, 0, m);
dashSave();
return m;
}
async function dashSettings(m) {
const def = DASH_MODULES[m.type], d = dashDev(m);
const title = h("input", { type: "text", maxlength: 40, value: m.cfg.title || "", placeholder: def.title() });
const dev_ = def.global ? null : h("select", {}, dashDevs().map(x => h("option", { value: x.id, selected: x === d }, x.name)));
const text = m.type === "notes" ? h("textarea", { rows: 6, maxlength: 2000 }, m.cfg.text || "") : null;
// channels drawn over the curve: fixed per module, whichever channel is being looked at
const overlays = new Set(m.cfg.overlays || []);
const overlayBox = m.type === "curve" ? h("div", { class: "doverlays" }) : null;
const fillOverlays = () => {
const x = S.devices[dev_.value];
if (!x || !x.state) return overlayBox.replaceChildren(h("p", { class: "info" }, t("{name} is not connected.", { name: x ? x.name : "DSP" })));
overlayBox.replaceChildren(...dashChannels(x).map(([k, i]) => {
const key = k + i, box = h("input", { type: "checkbox", checked: overlays.has(key), onchange: () => (box.checked ? overlays.add(key) : overlays.delete(key)) });
return h("label", { class: "chk", style: `--c:${chColor(x, k, i)}` }, box, h("i"), chLabel(k, i));
}));
};
if (overlayBox) { fillOverlays(); dev_.addEventListener("change", fillOverlays); }
const res = await modal({ title: def.title(),
body: h("div", { class: "form dform" }, h("label", { class: "full" }, t("Title"), title),
dev_ ? h("label", { class: "full" }, "DSP", dev_) : null, text ? h("label", { class: "full" }, t("Text"), text) : null,
overlayBox ? h("div", { class: "full" }, h("div", { class: "sub" }, t("Show on top of the curve")), overlayBox) : null),
actions: [{ label: t("Cancel") }, { label: t("Save"), primary: true, value: () => true }] });
if (!res) return;
m.cfg = { ...m.cfg, title: title.value.trim() };
if (dev_) m.cfg.device = dev_.value;
if (text) m.cfg.text = text.value;
if (overlayBox) m.cfg.overlays = [...overlays];
dashBrowse.delete(m.id);
dashSave(); render();
}
// Drag with pointer events (mouse and touch): modules are moved, new ones come from the palette.
function dashDrag(ev, source, el) {
if (ev.button) return;
const sx = ev.clientX, sy = ev.clientY;
let ghost = null, ph = null, grid = null;
const start = () => {
S.busy = true;
grid = $("#main .dash");
const size = source.mod || { type: source.type, w: DASH_MODULES[source.type].w, cfg: {} };
ph = h("div", { class: "dmod dph", style: dashSizeStyle(size.w, dashHeight(size, source.mod ? dashDev(size) : dashDevs()[0])) });
const r = el.getBoundingClientRect();
ghost = (source.mod ? el.closest(".dmod") : el).cloneNode(true);
ghost.classList.add("dghost");
ghost.style.width = (source.mod ? el.closest(".dmod").getBoundingClientRect().width : r.width) + "px";
document.body.append(ghost);
if (source.mod) { const home = el.closest(".dmod"); home.after(ph); home.hidden = true; } else grid.append(ph);
document.body.classList.add("ddragging");
};
const place = (x, y) => {
ghost.style.transform = `translate(${x + 8}px, ${y + 8}px)`;
if (y < 70) window.scrollBy(0, -12); else if (y > window.innerHeight - 70) window.scrollBy(0, 12);
const items = [...grid.children].filter(c => c !== ph && !c.hidden);
const next = items.find(c => { const r = c.getBoundingClientRect(); return y < r.top || (y < r.bottom && x < r.left + r.width / 2); });
if (next) { if (ph.nextSibling !== next) grid.insertBefore(ph, next); } else if (grid.lastChild !== ph) grid.append(ph);
};
const move = e => {
if (!ghost) { if (Math.hypot(e.clientX - sx, e.clientY - sy) < 6) return; start(); }
e.preventDefault();
place(e.clientX, e.clientY);
};
const end = e => {
window.removeEventListener("pointermove", move); window.removeEventListener("pointerup", end); window.removeEventListener("pointercancel", end);
if (!ghost) { if (e.type === "pointerup" && source.type) { dashAdd(source.type); render(); } return; }
const items = [...grid.children].filter(c => !c.hidden);
const at = items.indexOf(ph);
const onGrid = e.type === "pointerup";
ghost.remove(); document.body.classList.remove("ddragging"); S.busy = false;
const mods = dashMods();
if (onGrid && at >= 0) {
if (source.mod) { mods.splice(mods.indexOf(source.mod), 1); mods.splice(at, 0, source.mod); dashSave(); }
else dashAdd(source.type, at);
}
render();
};
window.addEventListener("pointermove", move, { passive: false });
window.addEventListener("pointerup", end); window.addEventListener("pointercancel", end);
}
function dashPalette() {
const list = Object.entries(DASH_MODULES).filter(([, def]) => !def.only || def.only());
return h("div", { class: "card dpalette" },
h("h3", {}, h("span", { class: "grow" }, t("Add modules")), h("span", { class: "info dhelp" }, t("Drag into the page or tap"))),
h("div", { class: "dchips" }, list.map(([type, def]) => {
const c = h("button", { class: "dchip", type: "button" }, svgIcon(def.icon), def.title());
c.addEventListener("pointerdown", e => dashDrag(e, { type }, c));
return c;
})));
}
// ------------------------------------------------------------------ page
const dashSizeStyle = (w, rows) => `--w:${w};--wt:${w < 6 ? 6 : 12};--h:${rows}`;
const dashLimit = (m, axis, v) => clamp(v, DASH_MODULES[m.type].min[axis], DASH_MODULES[m.type].max[axis]);
// rows: chosen by the user, or what the module needs on this DSP
function dashHeight(m, d) {
const def = DASH_MODULES[m.type];
return dashLimit(m, 1, m.h || (typeof def.h === "function" ? def.h(d) : def.h));
}
function dashResizeStart(ev, m, el, axes) {
ev.preventDefault(); ev.stopPropagation();
const grid = $("#main .dash"), col = (grid.clientWidth + 10) / 12, sx = ev.clientX, sy = ev.clientY;
const w0 = m.w, h0 = dashHeight(m, dashDev(m));
let w = w0, rows = h0;
S.busy = true;
document.body.classList.add("dresizing");
const move = e => {
if (axes.includes("w")) w = dashLimit(m, 0, w0 + Math.round((e.clientX - sx) / col));
if (axes.includes("h")) rows = dashLimit(m, 1, h0 + Math.round((e.clientY - sy) / DASH_ROW));
el.setAttribute("style", dashSizeStyle(w, rows));
};
const end = () => {
window.removeEventListener("pointermove", move); window.removeEventListener("pointerup", end); window.removeEventListener("pointercancel", end);
document.body.classList.remove("dresizing");
S.busy = false;
if (w !== w0 || rows !== h0) { m.w = w; m.h = rows; dashSave(); }
render();
};
window.addEventListener("pointermove", move); window.addEventListener("pointerup", end); window.addEventListener("pointercancel", end);
}
function dashModule(m) {
const def = DASH_MODULES[m.type];
if (!def) return null;
const d = def.global ? null : dashDev(m);
let body;
try {
body = def.global || (d && d.status === "online" && d.state) ? def.body(m, d) : offline(d);
} catch (e) {
console.error(e);
body = h("p", { class: "info dempty" }, t("This module can't show this DSP."));
}
const controls = dashEdit ? (() => {
return h("div", { class: "dctl" },
h("button", { class: "small", "aria-label": t("Module settings"), title: t("Module settings"), onclick: () => dashSettings(m) }, "⚙"),
h("button", { class: "small danger", "aria-label": t("Remove"), title: t("Remove"), onclick: () => {
dashMods().splice(dashMods().indexOf(m), 1); dashSave(); render();
} }, "×"));
})() : null;
const head = h("h3", { title: dashEdit ? t("Drag to move") : null }, svgIcon(def.icon), h("span", { class: "grow dtitle" }, m.cfg.title || def.title()),
d && dashDevs().length > 1 ? h("small", { class: "ddev" }, d.name) : null, controls);
const el = h("section", { class: `card dmod dt-${m.type}`, style: dashSizeStyle(m.w, dashHeight(m, d)) },
head, h("div", { class: "dbody" }, body));
if (dashEdit) {
head.addEventListener("pointerdown", e => { if (!e.target.closest("button")) dashDrag(e, { mod: m }, head); });
const handle = (axes, cls, arrow, label) => {
const g = h("span", { class: "dgrab " + cls, title: label }, arrow);
g.addEventListener("pointerdown", e => dashResizeStart(e, m, el, axes));
return g;
};
el.append(handle("w", "de", "↔", t("Drag to resize")), handle("h", "ds", "↕", t("Drag to resize")), handle("wh", "dse", "↘", t("Drag to resize")));
}
return el;
}
function viewDash() {
if (viewOnly()) dashEdit = false;
const mods = dashMods();
return [
h("div", { class: "dhead" }, h("h2", {}, "Dashboard"),
viewOnly() ? null : h("button", { class: dashEdit ? "on" : "", onclick: () => { dashEdit = !dashEdit; render(); } }, dashEdit ? t("Done") : t("Customise"))),
dashEdit ? dashPalette() : null,
mods.length ? h("div", { class: "dash" + (dashEdit ? " editing" : "") }, mods.map(dashModule))
: h("div", { class: "dash" + (dashEdit ? " editing" : "") }, h("div", { class: "dmod dblank", style: dashSizeStyle(12, 4) }, t("Nothing here yet – press “Customise” and add modules."))),
];
}
let dashResize = 0;
window.addEventListener("resize", () => {
clearTimeout(dashResize);
dashResize = setTimeout(() => { if (S.view === "dash" && !S.settings && !S.busy) render(); }, 200);
});
+82
View File
@@ -501,9 +501,91 @@ const DE = {
"Above the max level of {lim} – press Apply twice to set it anyway.": "Über dem max. Pegel von {lim} – zum Setzen trotzdem zweimal Übernehmen drücken.",
"Max level: {lim}": "Max. Pegel: {lim}",
"Set anyway": "Trotzdem setzen",
"Group name": "Gruppenname",
"Group name saved": "Gruppenname gespeichert",
"Group name removed": "Gruppenname entfernt",
"Unlink group": "Gruppe trennen",
"Unlink {names}? Every channel keeps its current settings.": "{names} trennen? Jeder Kanal behält seine aktuellen Einstellungen.",
"{names} join the group and take over its settings (names{routing} stay).": "{names} kommen in die Gruppe und übernehmen ihre Einstellungen – außer Namen{routing}.",
" and routing": " und Routing",
"{names} leave the group and keep their current settings.": "{names} verlassen die Gruppe und behalten ihre aktuellen Einstellungen.",
"Change group": "Gruppe ändern",
"Group changed: {names}": "Gruppe geändert: {names}",
"Fewer than two channels – the group will be dissolved": "Weniger als zwei Kanäle – die Gruppe wird aufgelöst",
"Edit {names}: tap channels to add or remove them": "{names} bearbeiten: Kanäle antippen zum Hinzufügen oder Entfernen",
"Dissolve group": "Gruppe auflösen",
"{names} joins the group and takes over its settings (name{routing} stays).": "{names} kommt in die Gruppe und übernimmt ihre Einstellungen – außer Name{routing}.",
"{names} leaves the group and keeps its current settings.": "{names} verlässt die Gruppe und behält seine aktuellen Einstellungen.",
"Beta: this model has not been tested on a real device yet. Keep the amplifiers off for the first test.": "Beta: Dieses Modell wurde noch nicht an einem echten Gerät getestet. Beim ersten Test die Endstufen ausgeschaltet lassen.",
"Band-pass": "Bandpass",
"From file": "Aus Datei",
"Bypass": "Bypass",
"This is not a list of FIR coefficients": "Das ist keine Liste von FIR-Koeffizienten",
"Too many coefficients: {n}, at most {max} here": "Zu viele Koeffizienten: {n}, hier höchstens {max}",
"Load FIR filter": "FIR-Filter laden",
"Send {n} coefficients from {file} to {ch}? This changes the sound immediately – keep the amplifiers low.": "{n} Koeffizienten aus {file} an {ch} senden? Das ändert den Klang sofort – Endstufen leise halten.",
"Send": "Senden",
"FIR filter loaded": "FIR-Filter geladen",
"taps": "Taps",
"off": "aus",
"FIR filters": "FIR-Filter",
"{used} of 4096 taps in use": "{used} von 4096 Taps belegt",
"Window": "Fenster",
"Taps": "Taps",
"Low cut (Hz)": "Untere Grenze (Hz)",
"High cut (Hz)": "Obere Grenze (Hz)",
"The low cut must be below the high cut.": "Die untere Grenze muss unter der oberen liegen.",
"Not enough taps left: {free} free, this needs {need}.": "Nicht genug Taps frei: {free} frei, nötig sind {need}.",
"More than 512 taps add noticeable delay (over 10 ms at 1024).": "Mehr als 512 Taps bringen spürbare Verzögerung (über 10 ms bei 1024).",
"Loaded: {name}": "Geladen: {name}",
"Choose a file with up to {max} coefficients (txt or csv).": "Datei mit bis zu {max} Koeffizienten wählen (txt oder csv).",
"Sending…": "Wird gesendet…",
"Load file…": "Datei laden…",
"FIR filter set": "FIR-Filter gesetzt",
"The DSP can't send coefficients back, so the curve only appears after loading a file here.": "Der DSP kann Koeffizienten nicht zurücksenden, die Kurve erscheint daher erst nach dem Laden einer Datei hier.",
"Calculated by this app – the DSP calculates the filter itself, so details can differ.": "Von dieser App berechnet – der DSP berechnet den Filter selbst, Details können abweichen.",
"Filter is off.": "Filter ist aus.",
"Loaded: {name} ({n} taps)": "Geladen: {name} ({n} Taps)",
"Inputs only take filters from a file: up to {max} coefficients (txt or csv).": "Eingänge nehmen nur Filter aus einer Datei: bis zu {max} Koeffizienten (txt oder csv).",
"Frequency response": "Frequenzgang",
"Out of FIR taps: all channels together have 4096": "Keine FIR-Taps mehr frei: alle Kanäle zusammen haben 4096",
"Not valid FIR coefficients": "Keine gültigen FIR-Koeffizienten",
"{name} is not connected.": "{name} ist nicht verbunden.",
"No DSP added yet.": "Noch kein DSP angelegt.",
"DSP overview": "DSP-Übersicht",
"Open in the mixer": "Im Mixer öffnen",
"Levels": "Pegel",
"Faders": "Fader",
"{n} bands active": "{n} Bänder aktiv",
"flat": "flach",
"Sources": "Quellen",
"{name} has no FIR filters.": "{name} hat keine FIR-Filter.",
"Notes": "Notizen",
"Empty – add text in the module settings.": "Leer – Text in den Moduleinstellungen eintragen.",
"Title": "Titel",
"Text": "Text",
"Add modules": "Module hinzufügen",
"Drag into the page or tap": "Auf die Seite ziehen oder antippen",
"This module can't show this DSP.": "Dieses Modul kann diesen DSP nicht anzeigen.",
"Drag to move": "Zum Verschieben ziehen",
"Narrower": "Schmaler",
"Wider": "Breiter",
"Module settings": "Moduleinstellungen",
"Done": "Fertig",
"Customise": "Anpassen",
"Nothing here yet – press “Customise” and add modules.": "Noch nichts da – „Anpassen“ drücken und Module hinzufügen.",
"Show on top of the curve": "Über der Kurve anzeigen",
"Drag to resize": "Zum Ändern der Größe ziehen",
"Read-only – tap to edit": "Nur ansehen – antippen zum Bearbeiten",
"Editing – tap for read-only": "Bearbeiten – antippen für Nur ansehen",
"Read-only": "Nur ansehen",
"Edit mode – changes go to the DSP": "Bearbeiten – Änderungen gehen an den DSP",
"Read-only – switch to edit at the top": "Nur ansehen – oben auf Bearbeiten umschalten",
};
const DE_PATTERNS = [
[/^Too many FIR coefficients: at most (\d+) here$/, "Zu viele FIR-Koeffizienten: hier höchstens $1"],
[/^The DSP did not answer (\d+) frames$/, "Der DSP hat auf $1 Datenpakete nicht geantwortet"],
[/^Port (\d+) is already in use – please choose another port$/, "Port $1 ist schon belegt – bitte einen anderen Port wählen"],
[/^Port (\d+) is not available \((.*)\)$/, "Port $1 ist nicht verfügbar ($2)"],
[/^Cannot open USB device \(error (.*)\)$/, "USB-Gerät lässt sich nicht öffnen (Fehler $1)"],
+4
View File
@@ -20,15 +20,18 @@
</div>
<div id="devtabs"></div>
<nav id="viewtabs" aria-label="View" data-t-label="View">
<button data-view="dash"><svg viewBox="0 0 24 24"><rect x="3" y="3" width="8" height="9" rx="1.5"/><rect x="13" y="3" width="8" height="5" rx="1.5"/><rect x="13" y="10" width="8" height="11" rx="1.5"/><rect x="3" y="14" width="8" height="7" rx="1.5"/></svg><span>Dashboard</span></button>
<button data-view="mixer"><svg viewBox="0 0 24 24"><path d="M6 3v18M12 3v18M18 3v18"/><rect x="3.5" y="13" width="5" height="3" rx="1"/><rect x="9.5" y="7" width="5" height="3" rx="1"/><rect x="15.5" y="10" width="5" height="3" rx="1"/></svg><span>Mixer</span></button>
<button data-view="channel"><svg viewBox="0 0 24 24"><path d="M2 14c3 0 3-7 6-7s3 10 6 10 3-6 6-6h2"/></svg><span data-t="Channel">Channel</span></button>
<button data-view="routing"><svg viewBox="0 0 24 24"><path d="M4 6h16M4 12h16M4 18h16M8 3v18M16 3v18"/><circle cx="8" cy="6" r="2.2" class="f"/><circle cx="16" cy="12" r="2.2" class="f"/><circle cx="8" cy="18" r="2.2" class="f"/></svg><span>Routing</span></button>
<button data-view="link"><svg viewBox="0 0 24 24"><path d="M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1"/><path d="M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1"/></svg><span data-t="Channel settings">Channel settings</span><span class="short" data-t="Channels">Channels</span></button>
<button data-view="fir" hidden><svg viewBox="0 0 24 24"><path d="M2 12h3l2-7 3 14 3-11 2 6 2-3 1 1h4"/></svg><span>FIR</span></button>
<button data-view="limiter"><svg viewBox="0 0 24 24"><path d="M2 7h20" stroke-dasharray="2.5 2.5"/><path d="M2 14c2 0 3-7 5-7h3c2 0 3 11 6 11s3-5 6-5"/></svg><span>Limiter</span></button>
<button data-view="soundfield"><svg viewBox="0 0 24 24"><rect x="3" y="3" width="18" height="18" rx="2"/><path d="M8 7l-2 2 2 2M16 7l2 2-2 2"/><path d="M7 15.5a7 7 0 0 1 10 0" stroke-dasharray="2 2"/><circle cx="12" cy="18" r="1.2" class="f"/></svg><span>SoundField</span><span class="short">Field</span></button>
<button data-view="test"><svg viewBox="0 0 24 24"><path d="M4 9v6h4l5 4V5L8 9z"/><path d="M16.5 8.5a5 5 0 0 1 0 7M19 6a8.5 8.5 0 0 1 0 12"/></svg><span data-t="Audio test">Audio test</span><span class="short" data-t="Test">Test</span></button>
</nav>
<button id="btn-muteall" class="icon" aria-label="Mute all" title="Mute all"></button>
<button id="btn-guard" class="guard" hidden role="switch"></button>
<button id="btn-lock" class="icon" hidden aria-label="Lock" title="Lock"></button>
<button id="btn-settings" class="icon" aria-label="Settings" title="Settings" data-t-label="Settings">
<svg viewBox="0 0 24 24" width="22" height="22" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1.1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1.1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9a1.7 1.7 0 0 0 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z"/></svg>
@@ -42,5 +45,6 @@
<script src="/i18n.js"></script>
<script src="/app.js"></script>
<script src="/soundfield.js"></script>
<script src="/dashboard.js"></script>
</body>
</html>
+1 -1
View File
@@ -504,7 +504,7 @@ const sfNum = (value, step, onset, attrs = {}) => {
function sfOutputs() { // every DSP output known from the device list (also offline ones)
return S.order.map(id => S.devices[id]).filter(d => !d.demo || S.demo.enabled).map(d => {
const n = d.n_out || (d.model === "204" ? 4 : d.model === "408" ? 8 : 0);
const n = d.n_out || (MODEL_CH[d.model] || [0, 0])[1];
return { d, outs: Array.from({ length: n }, (_, o) => o) };
}).filter(x => x.outs.length);
}
+172 -8
View File
@@ -109,7 +109,9 @@ body[data-view=settings] #viewtabs button.active { background: none; color: var(
position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; border-radius: 0; border: 0; border-top: 1px solid var(--line);
padding: 4px 6px env(safe-area-inset-bottom); background: rgba(16, 18, 22, .96); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
#viewtabs button { flex: 1; flex-direction: column; gap: 2px; font-size: 11px; min-height: 54px; padding: 4px; }
#viewtabs { overflow-x: auto; scrollbar-width: none; }
#viewtabs::-webkit-scrollbar { display: none; }
#viewtabs button { flex: 1 0 60px; flex-direction: column; gap: 2px; font-size: 11px; min-height: 54px; padding: 4px; }
#viewtabs button svg { width: 22px; height: 22px; }
#toast { bottom: calc(var(--bnav) + 12px) !important; }
}
@@ -119,7 +121,8 @@ body[data-view=settings] #viewtabs button.active { background: none; color: var(
.card h3 { margin: 0 0 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim);
display: flex; align-items: center; gap: 8px; min-height: 22px; }
.grow { flex: 1; }
.cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); align-items: start; margin-bottom: 10px; }
html { scrollbar-gutter: stable; }
.cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); align-items: stretch; margin-bottom: 10px; }
.cards .wide { grid-column: 1 / -1; }
h2.section { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); margin: 14px 2px 8px; }
.empty { color: var(--dim); text-align: center; padding: 60px 16px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
@@ -190,7 +193,28 @@ input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border-radius:
.mixer { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.mgroup { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; }
.mgroup h4 { margin: 0 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--dim); font-weight: 600; }
.strips { display: flex; gap: 6px; }
/* strips sit in row 2 of a grid; row 1 holds the brackets of link groups (spanning their strips) */
.strips { display: grid; grid-template-columns: repeat(var(--n), 92px); grid-template-rows: 0 auto; gap: 0 6px; }
.mixer.hasbands .strips { grid-template-rows: 30px auto; }
.strips > .strip { grid-row: 2; }
.lkband { --lc: var(--warn); grid-row: 1; position: relative; align-self: end; height: 13px; margin: 0 14px 5px;
border: 2px solid var(--lc); border-bottom: 0; border-radius: 14px 14px 0 0;
filter: drop-shadow(0 0 5px color-mix(in srgb, var(--lc) 55%, transparent)); }
.lkband::before, .lkband::after { content: ""; position: absolute; bottom: -3px; width: 6px; height: 6px; border-radius: 50%; background: var(--lc); }
.lkband::before { left: -4px; } .lkband::after { right: -4px; }
.lkband.single { margin: 0 16px 5px; }
.lkband.single .lkname { max-width: calc(100% + 30px); padding: 1px 7px; }
.lkname { position: absolute; left: 50%; top: -1px; transform: translate(-50%, -50%); max-width: calc(100% - 20px);
display: flex; align-items: center; gap: 5px; padding: 1px 9px; border-radius: 999px; white-space: nowrap;
background: var(--bg); border: 1px solid color-mix(in srgb, var(--lc) 60%, transparent); color: var(--lc);
font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.lkname b { overflow: hidden; text-overflow: ellipsis; font-weight: inherit; }
.lkname svg { flex: none; width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.lkname.anon { padding: 2px 6px; }
.lkgroup { display: flex; flex-direction: column; gap: 6px; padding-right: 8px; }
.lkgroup > .row { flex-wrap: nowrap; }
.lkgroup .lkmembers { min-width: 0; font-weight: 600; }
.lkgroup .lkname-in { width: 100%; height: 34px; padding: 4px 10px; font-size: 13px; }
.strip { --cc: var(--warn); flex: none; width: 92px; background: linear-gradient(var(--panel), var(--bg2)); border: 1px solid var(--line);
border-radius: var(--radius); padding: 0 6px 8px; display: flex; flex-direction: column; align-items: stretch; gap: 8px;
scroll-snap-align: start; position: relative; overflow: hidden; }
@@ -208,8 +232,9 @@ input[type=range]::-moz-range-thumb { width: 22px; height: 22px; border-radius:
button.mute.on { background: var(--mute); border-color: #f87171; color: #fff; box-shadow: 0 0 10px #dc262655; }
.strip.muted { background: linear-gradient(#1f1517, var(--bg2)); }
@media (min-width: 1200px) {
.mgroup { flex-shrink: 1; flex-basis: 0; }
.strip { flex: 1 1 92px; max-width: 128px; }
.mgroup { flex: 0 1 auto !important; }
.strips { grid-template-columns: repeat(var(--n), minmax(92px, 128px)); }
.strip { width: auto; max-width: 128px; }
}
/* ------------------------------------------------------------- channel view */
@@ -360,7 +385,9 @@ canvas.curve { width: 100%; height: clamp(200px, 32vw, 320px); display: block; b
.lw small { font-size: 14px; font-weight: 500; color: var(--dim); }
.lsub { font-size: 13px; color: var(--dim); margin-top: 2px; }
.lbar { position: relative; height: 8px; border-radius: 4px; background: var(--panel3); margin: 10px 0 4px; }
.lres.none .lbar { display: none; }
.lres.none .lbar, .lres.none .lw, .lres.none .lnotes { display: none; }
.lres.none { padding: 7px 10px; }
.lres.none .lsub { margin: 0; }
.lbar i { position: absolute; inset: 0 auto 0 0; width: calc(var(--p) * 100%); border-radius: 4px; background: var(--c); transition: width .15s; }
.lbar b, .lbar::after { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text); left: calc(var(--a) * 100% - 1px); }
.lbar::after { content: ""; display: none; background: var(--warn); left: calc(var(--s) * 100% - 1px); }
@@ -485,8 +512,8 @@ input.code { width: 7.5em; text-align: center; font-family: ui-monospace, Menlo,
.tf .fader { height: 300px; }
.testval { white-space: nowrap; width: 6.5em; text-align: center; font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; }
.tf { flex: none; width: 6.5em; }
.tmeters { display: flex; gap: 6px; overflow-x: auto; min-width: 0; padding-bottom: 4px; }
.tmeter { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: none; }
.tmeters { flex: 1; display: flex; gap: 6px; overflow-x: auto; min-width: 0; padding-bottom: 4px; }
.tmeter { display: flex; flex-direction: column; align-items: center; gap: 4px; flex: 1 0 auto; max-width: 120px; }
.tmeter .led { height: 300px; }
.testfader h3 .info { margin-left: 8px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.tmeter small { font-size: 11px; color: var(--dim); }
@@ -717,3 +744,140 @@ input[type=range].haslim::-moz-range-track {
.fader .limbelow { position: absolute; left: var(--tx); width: 10px; margin-left: -5px; pointer-events: none; z-index: 0;
bottom: calc(12px + var(--f) * (100% - 24px)); height: calc(max(0, var(--v, 0) - var(--f)) * (100% - 24px));
background: var(--limgrey), #0b0d10; border-radius: 2px; }
/* ---- editing a link group */
.lkediting .lkgrid { outline: 1px dashed var(--accent); outline-offset: 6px; border-radius: 10px; }
.lkgroup.editing { background: color-mix(in srgb, var(--lc) 14%, var(--panel2)); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--lc) 45%, transparent); }
.lkgroup.dim { opacity: .5; }
.lkactions button + button { margin-left: 6px; }
/* ---- note on beta models in the add-device form */
.betanote { margin: 0; padding: 8px 10px; border-radius: 8px; color: var(--text); background: #f59e0b1f; border: 1px solid #f59e0b66; }
.betanote[hidden] { display: none; }
/* ---- FIR tab */
#viewtabs button[hidden] { display: none; }
.firuse { font-size: 12px; font-weight: 600; color: var(--dim); text-transform: none; letter-spacing: 0; }
.firuse.over { color: #f87171; }
.firmeter { height: 6px; margin: 2px 0 12px; border-radius: 3px; background: var(--line); overflow: hidden; }
.firmeter span { display: block; height: 100%; background: var(--accent); }
.firchs { display: flex; flex-wrap: wrap; gap: 6px; }
.firsep { width: 1px; margin: 0 4px; background: var(--line); }
.firch { flex-direction: column; gap: 0; min-width: 66px; min-height: 48px; padding: 4px 8px; }
.firch small { color: var(--dim); font-size: 11px; font-weight: 400; }
.firch.used small { color: var(--accent); }
.firch.on { background: var(--accent2); border-color: var(--accent); color: #fff; }
.firch.on small { color: #dbeafe; }
.firform { margin-bottom: 8px; }
canvas.fircurve { display: block; width: 100%; height: 240px; background: var(--bg2); border-radius: 8px; }
/* ---- dashboard */
.dhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 10px; }
.dhead h2 { margin: 0; font-size: 20px; }
.dash { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-rows: 30px; grid-auto-flow: dense; gap: 10px; align-items: stretch; }
.dmod { min-width: 0; display: flex; flex-direction: column; }
.dmod[hidden] { display: none; }
.dmod { position: relative; grid-column: span var(--w); grid-row: span var(--h); }
.dbody { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: auto; scrollbar-width: thin; }
@media (max-width: 1100px) { .dmod { grid-column: span var(--wt); } }
/* phones: one column, as high as the content */
@media (max-width: 759px) {
.dash { grid-auto-rows: auto; }
.dmod { grid-column: span 12; grid-row: auto; }
.dhelp, .dgrab { display: none; }
.dm .led { flex: none !important; height: 130px !important; }
canvas.dcurve { flex: none !important; height: 170px !important; }
}
.dmod > h3 svg { width: 15px; height: 15px; flex: none; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dtitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ddev { flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); font-size: 11px; font-weight: 400; text-transform: none; letter-spacing: 0; }
.dctl { display: flex; gap: 3px; flex: none; }
.dctl button { min-height: 26px; min-width: 26px; padding: 0 6px; text-transform: none; letter-spacing: 0; }
.dash.editing .dmod > h3 { cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.dgrab { position: absolute; z-index: 2; display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 6px;
font-size: 12px; line-height: 1; color: var(--text); background: var(--panel3); border: 1px solid var(--line2); touch-action: none; user-select: none; -webkit-user-select: none; }
.dgrab:hover { background: var(--accent2); border-color: var(--accent); color: #fff; }
.de { right: -7px; top: 50%; margin-top: -10px; cursor: ew-resize; }
.ds { bottom: -7px; left: 50%; margin-left: -10px; cursor: ns-resize; }
.dse { right: -7px; bottom: -7px; cursor: nwse-resize; }
body.dresizing { user-select: none; -webkit-user-select: none; }
.dresizing .dmod { transition: none; }
.dash.editing .dmod { border-style: dashed; border-color: var(--line2, #3a4250); }
.dempty { margin: auto; text-align: center; padding: 16px 4px; }
.dblank { padding: 40px 12px; text-align: center; color: var(--dim); }
.dpalette { margin-bottom: 10px; }
.dpalette h3 { margin-bottom: 8px; }
.dhelp { margin: 0; text-transform: none; letter-spacing: 0; font-weight: 400; }
.dchips { display: flex; flex-wrap: wrap; gap: 6px; }
.dchip { gap: 6px; min-height: 34px; padding: 4px 11px; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.dchip svg { width: 15px; height: 15px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dph { min-height: 110px; border: 2px dashed var(--accent); border-radius: var(--radius); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.dghost { position: fixed; left: 0; top: 0; z-index: 90; margin: 0; pointer-events: none; opacity: .85; max-height: 240px; overflow: hidden; box-shadow: 0 12px 30px #000a; }
body.ddragging { user-select: none; -webkit-user-select: none; cursor: grabbing; }
.dlist { display: flex; flex-direction: column; gap: 4px; }
.dlist hr { width: 100%; margin: 4px 0; border: 0; border-top: 1px solid var(--line); }
.drow { display: flex; align-items: center; gap: 8px; min-height: 26px; font-size: 13px; min-width: 0; }
.dlink { width: 100%; justify-content: flex-start; min-height: 42px; padding: 5px 9px; text-align: left; font-weight: 400; background: var(--panel2); }
.dname { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.dname b, .dname small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dname small { color: var(--dim); font-size: 11px; }
.dtag { flex: none; padding: 1px 6px; border-radius: 5px; font-size: 10px; font-weight: 700; letter-spacing: .05em; }
.dtag.mute { color: #fff; background: var(--mute); }
.dlab { flex: none; min-width: 3.1em; color: var(--dim); font-size: 12px; }
.dsub { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dim); font-size: 12px; }
.dval { flex: none; min-width: 4.6em; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12px; }
.dbar { --cc: var(--accent); flex: 1; position: relative; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; min-width: 30px; }
.dbar i { position: absolute; inset: 0 auto 0 0; background: var(--cc); opacity: .85; }
.dbar u { position: absolute; left: 70%; top: 0; bottom: 0; width: 1px; background: #ffffff66; }
.dgain.muted .dbar i { background: var(--dim); opacity: .4; }
.dgain.muted .dval { color: #f87171; font-size: 10px; }
.drow.zero { opacity: .5; }
.dmeters { flex: 1; min-height: 0; display: flex; gap: 14px; }
.dmgroup { flex: 1 1 0; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dmgroup .sub { flex: none !important; margin: 0; }
.dms { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); grid-template-rows: 5px minmax(0, 1fr) 18px 3px; gap: 0 4px; }
.dmeters.hasnames .dms { grid-template-rows: 15px minmax(0, 1fr) 18px 3px; }
.dms > .dm { grid-row: 2; position: relative; margin-bottom: 3px; }
.dgrp { grid-row: 1 / -1; border-radius: 8px; background: color-mix(in srgb, var(--lc) 6%, transparent); }
.dgrpname { grid-row: 1; position: relative; align-self: center; padding: 0 4px; min-width: 0; color: var(--lc); font-size: 10px; line-height: 12px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dmlab { grid-row: 3; position: relative; align-self: center; text-align: center; font-size: 11px; font-weight: 700; line-height: 18px; }
.dm { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0; min-height: 0; }
.dm .led { flex: 1 1 0; height: auto; min-height: 0; padding: 0; }
.dm.muted .led { opacity: .35; }
.dm .limled { width: 18px; height: 4px; min-height: 4px; margin: 0; font-size: 0; }
.dnav { flex: none; display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.dnav button { min-height: 28px; min-width: 32px; padding: 0 8px; font-size: 16px; line-height: 1; }
.dnavname { flex: 1; min-width: 0; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--dim); }
.dnavname b { color: var(--text); }
canvas.dcurve { display: block; width: 100%; flex: 1 1 0; min-height: 70px; background: var(--bg2); border-radius: 8px; }
.dlegend { display: flex; flex-wrap: wrap; gap: 3px 10px; margin-top: 5px; font-size: 11px; color: var(--dim); }
.dlegend span { display: inline-flex; align-items: center; gap: 4px; }
.dlegend i { width: 10px; height: 3px; border-radius: 2px; }
.doverlays { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; margin-top: 6px; }
.doverlays label { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.doverlays i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.dbands { flex: none; display: flex; gap: 3px; margin-top: 6px; overflow-x: auto; }
.dband { flex: 1 0 34px; flex-direction: column; gap: 0; min-height: 34px; padding: 2px; font-weight: 400; background: var(--panel2); }
.dband b { font-size: 12px; }
.dband small { color: var(--dim); font-size: 10px; }
.dband.act b { color: var(--accent); }
.dband.off { opacity: .45; }
.dband.on { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, var(--panel2)); }
.dbandinfo { margin: 6px 2px 0; min-height: 1.3em; }
.dkvs { display: flex; flex-direction: column; }
.dkv { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.dkv:last-child { border-bottom: 0; }
.dkv span { color: var(--dim); flex: none; }
.dkv b { font-weight: 600; text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dkv.bad b { color: #f87171; }
.dmatrix { display: grid; grid-template-columns: minmax(3.4em, auto) repeat(var(--n), minmax(16px, 1fr)); gap: 4px 3px; align-items: center; justify-items: center; font-size: 12px; }
.dmatrix span { justify-self: start; color: var(--dim); white-space: nowrap; }
.dmatrix b { font-size: 11px; }
.dmatrix i { width: 12px; height: 12px; border-radius: 50%; background: var(--line); }
.dmatrix i.on { background: var(--c); box-shadow: 0 0 6px var(--c); }
.dnote { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; line-height: 1.45; }
.dform textarea { width: 100%; resize: vertical; min-height: 110px; font: inherit; }
/* ---- read-only switch (phones, tablets) */
.guard { flex: none; gap: 6px; min-height: 34px; padding: 0 8px; font-size: 12px; font-weight: 600; color: var(--dim); background: var(--panel2); }
.guardtrack { position: relative; width: 28px; height: 16px; border-radius: 8px; background: var(--line2); transition: background .15s; }
.guardtrack i { position: absolute; left: 2px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: left .15s; }
.guard.on { color: #fff; border-color: var(--accent); }
.guard.on .guardtrack { background: var(--accent); }
.guard.on .guardtrack i { left: 14px; }
body.locked #main input[type=range] { pointer-events: none; }
+43 -2
View File
@@ -35,7 +35,7 @@ def test_layout_matches_devices():
def test_state_roundtrip():
for m in P.MODELS.values():
for m in (m for m in P.MODELS.values() if not m.fir):
st = P.default_state(m)
st["outputs"][-1]["comp"]["threshold"] = 123
st["inputs"][0]["geq"][30] = 7
@@ -140,7 +140,7 @@ def test_device_lock():
def test_test_signal():
# source/frequency follow the mute masks and one word per channel (editor: 0x2C8 on the 204, 0x59C on the 408)
assert P.MODELS["204"].test_base == 0x2C8 and P.MODELS["408"].test_base == 0x59C
for m in P.MODELS.values():
for m in (m for m in P.MODELS.values() if not m.fir):
st = P.default_state(m)
st["test"] = {"source": 3, "freq": 17}
assert P.parse_state(m, bytes(P.build_state_buffer(m, st)))["test"] == {"source": 3, "freq": 17}
@@ -165,6 +165,47 @@ def test_master_bypass():
assert P.MODELS["408"].test_base + 6 == 0x5A2
def test_beta_models():
assert P.detect_model("DSP408 V010") == "408" and P.detect_model("DSP 204") == "204"
for info in ("DSP206 V1", "FIR DSP408 V1", "FIRDSP408", "DSP408FIR"): # only selectable by hand
assert P.detect_model(info) is None, info
for key in ("206", "408fir"):
m = P.MODELS[key]
assert m.beta
st = P.default_state(m)
st["outputs"][m.n_out - 1]["gain"] = 123
back = P.parse_state(m, bytes(P.build_state_buffer(m, st)))
assert back["outputs"][m.n_out - 1]["gain"] == 123 and len(back["inputs"]) == m.n_in
def test_fir_model():
m = P.MODELS["408fir"]
assert (m.in_size, m.out_size, m.out_base, m.globals_base, m.size, m.chunks) == (138, 108, 0x238, 0x598, 0x625, 32)
st = P.default_state(m)
o = st["outputs"][7]
o["gain"], o["limit"]["threshold"], o["hp"], o["peq"][8]["bypass"] = 123, 77, {"freq": 40, "slope": 5}, True
o["fir"].update(type=3, window=8, low=200, high=8000, taps=24, name="SUB")
st["inputs"][3]["comp"]["threshold"], st["inputs"][3]["fir"] = 55, {"taps": 2048, "bypass": False, "name": "ROOM"}
st["inputs"][0]["peq"][7]["bypass"] = True
buf = bytes(P.build_state_buffer(m, st))
assert buf[0x238 + 7 * 108 + 28:0x238 + 7 * 108 + 36] == bytes([3, 8]) + (200).to_bytes(2, "little") + (8000).to_bytes(2, "little") + (24).to_bytes(2, "little")
assert buf[0x5B4 + 8 * 11:0x5B4 + 8 * 11 + 3] == b"SUB" and buf[0x59C:0x59E] == (128).to_bytes(2, "little")
back = P.parse_state(m, buf)
assert back["outputs"] == st["outputs"] and back["inputs"] == st["inputs"]
assert len(back["inputs"][0]["peq"]) == 8 and len(back["outputs"][0]["peq"]) == 9 and "geq" not in back["inputs"][0]
assert P.param_command(m, "out", 7, back["outputs"][7], "fir") == (0x4B, bytes.fromhex("0b 03 08 c8 00 40 1f 18 00"))
assert P.param_command(m, "out", 7, back["outputs"][7], "hp") == (0x32, bytes.fromhex("0b 28 00 04 00"))
assert P.param_command(m, "out", 0, back["outputs"][0], "hp") == (0x32, bytes.fromhex("04 00 00 00 01"))
assert P.param_command(m, "in", 3, back["inputs"][3], "fir.bypass") == (0x4F, bytes.fromhex("03 00"))
assert P.param_command(m, "out", 7, back["outputs"][7], "limit")[1][:3] == bytes.fromhex("0b 00 00")
assert P.fir_channel_taps(back["outputs"][7]) == 1024 and P.fir_channel_taps(back["inputs"][3]) == 2048
frames = P.fir_coef_frames(4, [1.0] + [0.0] * 12)
assert len(frames) == 2 and frames[0][:8] == bytes.fromhex("04 00 0d 00 3f 80 00 00") and len(frames[0]) == 4 + 48 and len(frames[1]) == 8
for cmd, p in ((0x4B, bytes.fromhex("04 01 02 96 00 20 4e 08 00")), (0x4E, frames[0]), (0x5B, b"\x04ABC ")):
P.apply_command(m, st, cmd, p)
assert st["outputs"][0]["fir"]["type"] == 1 and st["outputs"][0]["fir"]["name"] == "ABC"
if __name__ == "__main__":
for name, fn in list(globals().items()):
if name.startswith("test_"):