Compare commits

..
35 Commits
Author SHA1 Message Date
GivouandClaude Opus 5.5 8e7f9eaeda DSP 408: briefly tried on real hardware, not in depth
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 22:47:56 +01:00
GivouandClaude Opus 5.5 c19ad62b91 README rewritten with screenshots, local tool settings out of the repository
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 22:37:13 +01:00
GivouandClaude Opus 5.5 4a6eb2f513 DJ Brake only shows the limiter acting; presets without a look start empty
The distance to the limiter, its bar, the warn-earlier slider and the learning
are gone: the page follows the DSP's limiter bits, with one second hold. Left out
limiters stay.
A preset without colours and group names of its own no longer inherits the ones
from the preset before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 22:18:09 +01:00
GivouandClaude Opus 5.5 63b3c17fb7 DJ Brake: use the offset measured on a real DSP 204
Measured: limiter threshold minus output meter is about 26 dB when the limiter
starts (25.1 to 27.7, one DSP 204, one output, one piece of music), and the meter
is after the output gain. So the distance is right before the first hit.
The limiter flag also stayed on after raising a threshold, which would have
taught a false value: only limiters starting by themselves teach now.
The measuring tool no longer draws conclusions the data doesn't carry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 21:54:29 +01:00
GivouandClaude Opus 5.5 4cd771eb5c Measuring tool for meter, gain, threshold and limiter on real hardware
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 21:34:29 +01:00
GivouandClaude Opus 5.5 6d467d4f2d DJ Brake: learn the limiter from its onset, for the whole DSP
Replaying real tracks through a limiter model showed the level during limiting
teaches little. One hit now counts for all outputs of a DSP.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 21:24:32 +01:00
GivouandClaude Opus 5.5 bbe8a73775 Reset: nicer dialog, only in the desktop apps
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 21:20:40 +01:00
GivouandClaude Opus 5.5 29a89af562 Reset all app settings, dashboard starts empty
The reset disconnects all DSPs first and sends them nothing, asks for two random
letters (and the PIN on the web), keeps a copy of the old config and reloads
a fresh app. Refused during an audio test or mute all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 21:14:08 +01:00
GivouandClaude Opus 5.5 6d53069380 DJ Brake: learned limiter levels survive a restart
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 21:10:04 +01:00
GivouandClaude Opus 5.5 cf35a1faa1 Looks per preset, steadier DJ Brake, no zoom on phones, simple dashboard on touch
Colours and link group names now belong to the preset (by name, the DSP has no
IDs) and travel in preset files. DJ Brake: limiters are left out instead of
chosen; a slowly falling peak mark, an average bar, a warning before the limit,
and it learns from real hits where the limiter sits on the meter. Pinch and
double tap zoom are off. On touchscreens the dashboard only offers widget settings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 21:09:16 +01:00
GivouandClaude Opus 5.5 99613327f8 Start animation also in German
The app's new port means empty browser storage, so a German app reloaded right
after the start and lost the animation. The language now comes with the login.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 20:32:35 +01:00
GivouandClaude Opus 5.5 a639abf216 Handbooks reworked: wider dialog, clear steps, tips and pictures
The text ran outside the dialog box. Now it has a section bar, numbered steps,
button names that stand out and screenshots in both languages.
Phone: card headers wrap, so the EQ buttons no longer run off the screen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 19:24:30 +01:00
GivouandClaude Opus 5.5 fc0322cbc9 Phone: larger limiter displays
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 18:58:40 +01:00
GivouandClaude Opus 5.5 7932ef62c7 UI pass: controls of one kind line up and have one size
Remote access uses the same switch as demo mode and one column for its controls.
Button rows in settings get equal widths, checkboxes one look, link grids even
rows with their buttons aligned. No half-empty rows in the channel view.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 18:56:08 +01:00
GivouandClaude Opus 5.5 28624caead DJ Brake settings move next to remote access
In the apps the page is only reachable through remote access, so it can only be
switched on while that runs. All its addresses are listed there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 18:51:28 +01:00
GivouandClaude Opus 5.5 910cf3fc17 DJ Brake: warn a few dB before the real limiter
The page moves its limit down by a chosen margin. The limiter itself does not
change and the page never reveals the setting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 18:47:31 +01:00
GivouandClaude Opus 5.5 d6be627f32 DJ Brake: note that the limiter is not the goal, with its own settings
Shown by default and always in English by default; both can be switched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 18:45:38 +01:00
GivouandClaude Opus 5.5 8919f0016c DJ Brake: choose which limiters count, horizontal distance to the limiter
Outputs can be left out per device, muted outputs never count. The page also
shows how far the closest watched output is from its limiter threshold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 18:42:56 +01:00
GivouandClaude Opus 5.5 e56524a8cd DJ Brake page without login; routing level text follows the slider live
Optional page /djbrake (off by default) with a red light while a limiter works.
It needs no PIN and only ever gets {on, ready} from /djbrake/state.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 18:38:36 +01:00
GivouandClaude Opus 5.5 3ce0334aea Routing: white level text, short animation when switching; lock option in the PIN card
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 18:31:52 +01:00
GivouandClaude Opus 5.5 2fbb5e7424 Routing: level of a connection inside its crosspoint
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 18:29:35 +01:00
GivouandClaude Opus 5.5 5c391d932c Routing: soft signal pulse on connected crosspoints
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 18:28:11 +01:00
GivouandClaude Opus 5.5 a75b803264 Settings: more room below the section buttons
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 18:26:19 +01:00
GivouandClaude Opus 5.5 5f0f893810 Channel tab: LIM next to the gain value and in the channel bar
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 18:25:05 +01:00
GivouandClaude Opus 5.5 f043e1a261 Lock option: only show dashboard while locked; Sound Lab only in the desktop apps
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 18:23:35 +01:00
GivouandClaude Opus 5.5 9203cab4df Sound Lab: not offered on phones
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 18:19:59 +01:00
GivouandClaude Opus 5.5 a754021381 Sound Lab tab for REW, handbooks, settings note; VK-Audio only in the start animation and settings
Sound Lab takes filters from REW's API or a filter file onto a channel with a comparison
curve, and sends a channel's curve or filters back. Only checked against a fake server
built from REW's OpenAPI spec.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 18:18:33 +01:00
GivouandClaude Opus 5.5 14ca3aec4b Start animation in the desktop apps, VK-Audio wordmark
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 18:05:51 +01:00
GivouandClaude Opus 5.5 144f62f240 Audio test and dashboard limiter module: LIM text instead of the bar
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 17:59:05 +01:00
GivouandClaude Opus 5.5 a02e5dd53e Limiter tab: limiter LED dot next to the Channel button
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 17:56:34 +01:00
GivouandClaude Opus 5.5 9e2636c6d6 Mixer: limiter as glowing LIM text instead of a bar
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 17:55:00 +01:00
GivouandClaude Opus 5.5 fe24b620bf Dashboard curve: Overlay as its own entry next to the single channels
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 17:51:57 +01:00
GivouandClaude Opus 5.5 3a9059d420 Dashboard levels: LIM segment lights up its text only
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 17:50:09 +01:00
GivouandClaude Opus 5.5 763a8781f4 No DSPs by default: new installs start empty and say so
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 17:46:00 +01:00
GivouandClaude Opus 5.5 9c6d2d6e35 Dashboard levels: limiter as a LIM segment on top of the meter
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 17:45:27 +01:00
33 changed files with 1762 additions and 168 deletions

No files matched your search

-8
View File
@@ -1,8 +0,0 @@
{
"version": "0.0.1",
"configurations": [
{"name": "sim-204", "runtimeExecutable": "python", "runtimeArgs": ["sim.py", "--model", "204", "--port", "9761"], "port": 9761},
{"name": "sim-408", "runtimeExecutable": "python", "runtimeArgs": ["sim.py", "--model", "408", "--port", "9762"], "port": 9762},
{"name": "webui", "runtimeExecutable": "python", "runtimeArgs": ["server.py", "--port", "8080"], "port": 8080}
]
}
+1 -1
View File
@@ -12,4 +12,4 @@ __pycache__/
.DS_Store
# personal Claude Code settings
.claude/settings.local.json
.claude/
+16 -2
View File
@@ -17,7 +17,7 @@ pi_writer.py → pi_image.py (cloud-init SD card, installs server.py as a system
backups. Config is one JSON file (`config.json`, gitignored) – `load()` / `apply_config()` / `save()`.
* **Auth** – 4-digit PIN, PBKDF2 hash in `config.json`, session cookie `dspsess` (30 days), lockout after 5 failures.
The desktop app logs in via `/app-login?t=<one-time token>`; app sessions live in memory only, skip the PIN and may
toggle remote access (`/api/remote`) and the lock (`/api/lock`, server answers 423 while locked). Remote clients
toggle remote access (`/api/remote`) and the lock (`/api/lock`, server answers 423 while locked; with `lock_dash` the window shows only the dashboard). Remote clients
always need the PIN.
* **`dsp/device.py`** – one `Device` per DSP: connect (TCP or `usbhid.open_stream`), handshake, config dump
(50-byte chunks), command queue (one request in flight), meter polling (also keepalive), auto-reconnect.
@@ -55,6 +55,17 @@ pi_writer.py → pi_image.py (cloud-init SD card, installs server.py as a system
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.
* **Sound Lab / REW** (`static/rew.js`, handbooks in `static/docs.js`, `rew_call` in `server.py`) – the server talks to REW's API on `127.0.0.1:4735`, which only answers on
REW's own computer; so Sound Lab is only in the desktop apps (`S.isApp`, the server refuses `/api/rew/` otherwise). Only checked against a fake server built from its OpenAPI spec.
Pictures of the handbooks: `static/docimg/<name>.<lang>.jpg`, one per language, only ever from this app itself.
* **DJ Brake** (`static/djbrake.html`, `App.dj_note`, `App.dj_state`) – the only page without a login, off by default. It may only ever
learn `{on, ready, hint}` from `/djbrake/state`: never add device data or controls there. On its own on purpose, without `app.js`.
It only follows the DSP's limiter bits. A distance to the limiter was tried and dropped: see the measurement in `PROTOCOL.md`.
Its settings sit in the access section; in the apps it needs remote access, since the app itself only listens on 127.0.0.1.
* **Preset looks** – `Device.looks` keeps `colors`/`linknames` per preset name; `sync_look` swaps them whenever a read of the DSP
shows another name (the DSP has no preset IDs: same name = same look), a preset without a look starts empty. Preset files carry them as `look`.
* **Reset** (`App.reset_config`, `POST /api/reset`, app window only, never remote) – stops all devices before anything else and sends them nothing, then defaults from
a fresh `App`. Refused during an audio test or mute all, because the DSP would stay changed. Keeps `config.before-reset.json`.
* **Network search** – `App.scan_network` probes the local /24 networks on TCP 9761 (handshake + device info),
skipping DSPs this app is connected to.
* **Copy settings / mute all** – `App.copy_settings` (`POST /api/copy`, groups level/filters/eq/dynamics/routing) and
@@ -104,6 +115,8 @@ python sim.py --model 408 --port 9762
python server.py --port 8080 --config <some temp file>.json
```
`tools/dsp_measure.py` measures on real hardware how meter, gain, threshold and limiter relate (lowers only, restores itself).
Log in with PIN `1234`, add devices `127.0.0.1:9761` / `:9762`. Check both languages after UI changes (⚙ →
Language / Sprache). For the desktop app run `python desktop.py` (needs `pywebview`).
@@ -123,7 +136,8 @@ Not verified yet – ask for a log (`python server.py -v`) from real hardware be
`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)
* **DSP 408 on real hardware**: briefly tried by the maintainer and seemed to work, not tested in depth (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
of preset slots comes from (20 is assumed when the `0x2C` answer carries the lock state)
+7 -2
View File
@@ -56,10 +56,15 @@ All 16-bit words are little endian.
* Level = float32 from the bytes `00 b2 b0 b1` (little endian) → linear, dB = 20·log10.
* Positions: 0–3 = In A–D, 4–11 = Out 1–8. The 204 uses 0, 1 and 4–7.
* The level is measured before mute.
* The level is measured before mute and after the output gain (one DSP 204: -6 dB gain moved it by -6.3 dB against the input).
* The level is far below the limiter threshold's scale. One DSP 204 (V0104P), one output, one piece of music: when the limiter
starts, threshold minus the loudest level read is 26 dB (25.1 to 27.7 in five rounds, the same with -6 dB gain). How much of
that is a fixed offset and how much are peaks between the readings is not separated. Whether the level is before or after
the limiter is open: 6 dB below the start of limiting it fell only 0.9 dB against the input.
* **Limiter active**: the status bytes are a bit mask of the outputs (bit 0 = Out 1). Measured on a DSP 204:
`00 03` while Out 1+2 limit, `00 0C` for Out 3+4. That Out 5–8 of the 408 continue in the same 16-bit value
is *assumed*.
is *assumed*. The bit does not simply follow the level: it stayed on for 4 s, in two of six cases also after the threshold had
been raised to +20 dB, and went off within 0.2 s in others. Why is not known.
## Channel numbers
+134 -78
View File
@@ -1,88 +1,140 @@
# BetterDSPControl
**A modern, phone-friendly control app for the t.racks DSP 204 and DSP 408 loudspeaker processors.**
Control all your DSPs at the same time from a phone, tablet or computer, over the network or USB.
![Dashboard with levels, EQ curve and faders](docs/screenshots/dashboard.jpg)
> [!WARNING]
> **Vibe-coded – read this first.** I'm a hobbyist and wrote this app almost entirely with an AI coding assistant,
> for my own two DSPs. It works for me, but large parts have only been tested against a simulator, and some protocol
> **Vibe-coded, read this first.** I'm a hobbyist and wrote this app almost entirely with an AI coding assistant,
> for my own DSPs. It works for me, but large parts have only been tested against a simulator, and some protocol
> details are educated guesses (see [Verified vs. unverified](CLAUDE.md#verified-vs-unverified)).
> It talks directly to your loudspeaker processor and can change gains, limiters and crossovers – a wrong value can
> It talks directly to your loudspeaker processor and can change gains, limiters and crossovers: a wrong value can
> be loud and can damage speakers. **Export a preset before you start, keep the volume down while trying things out,
> and don't use it on a show you can't afford to lose.**
> You use it entirely at your own risk. I'm not responsible for anything that happens to your DSP, your speakers,
> your ears, your gig or your neighbours – nor for anything else, should the sky fall on you while you use it.
> your ears, your gig or your neighbours, nor for anything else, should the sky fall on you while you use it.
> No warranty of any kind (see [LICENSE](LICENSE)).
**A modern, phone-friendly control app for the t.racks DSP 204 and DSP 408 loudspeaker processors.**
Control both devices at the same time from your phone, tablet or computer – over the network or USB.
> **Unofficial project.** BetterDSPControl is an independent open-source project. It is not affiliated with,
> endorsed by or supported by Musikhaus Thomann or the t.racks brand. "Thomann" and "t.racks" are trademarks of
> their respective owner and are used here only to name the devices this software works with.
> Use at your own risk – see [Disclaimer](#disclaimer).
> See [Disclaimer](#disclaimer).
* Pure Python 3.10+ standard library on the server side – no packages to install
* Vanilla HTML/CSS/JavaScript web UI – no build tools
* Runs on Windows, macOS, Linux and a Raspberry Pi
* Runs on Windows, macOS, Linux and a Raspberry Pi, and in any browser
* No packages to install for the server (Python 3.10+ standard library), no build tools for the web UI
* English and German user interface
* **Want to look around first?** ⚙ → *Demo mode* starts a simulated DSP inside the app. Nothing is sent to real devices
## Features
All screenshots show the built-in simulator with made-up settings.
* **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
magnitude or phase (crossover filters, all-pass filters) and can overlay any other channel, e.g. to line up a
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) 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
state (stored presets stay untouched), writes only what actually differs and makes an automatic backup first
("Undo import")
* **Limiter calculator** – enter your amplifiers' datasheet values (power at 8/4/2 Ω, sensitivity or gain), assign
outputs, and see the resulting power when the limiter engages, the clipping headroom and the speaker load.
"Limit to … W" calculates the threshold. Attack/release presets per band (infra, sub, kick, mid, high)
* **SoundField** – top view of the room: place mains, subs, delays and fills by dragging (tops can stand on a sub with a
distance pole – drop the top onto the sub), see a level map, a sub
map at a chosen frequency (phase-correct, shows cancellation lanes) and a timing map for delay speakers. It
suggests aiming, height, delay lines, sub placement and front fills (one click to apply), calculates the delays
from the speed of sound and writes them to the assigned DSP outputs
* **Copy channel settings** – level/delay/polarity, filters, EQ, dynamics and routing from one channel to any number
of channels on all connected DSPs
* **Channel colours** – line and lightly tinted name in the mixer, channel view, routing and curve overlays; linked
channels share one colour, every colour is used once per DSP
* **Network search** – finds DSPs in the local network and adds them with one click; the device ID (address byte,
default 1) is under the device's advanced settings
* **Custom logo** – your own logo top left and as the browser icon (settings → Logo; PNG/JPG/WebP/SVG, ideally square, ≥ 64×64 px)
* **Fits every screen** – menu in the top bar on wide screens, a sidebar when the window gets narrow, a bottom bar on phones
* **Mute all** – one button mutes every channel of every connected DSP; releasing it unmutes only what was open before
* **Settings backup** – devices, amplifier data, SoundField plan, PIN and remote access in one file
* **Device lock** – DSPs locked with their 4-character code (e.g. `A1BA`) are detected on connect and the app asks
for the code; optionally it remembers the code and unlocks automatically. A new code can be set under ⚙
* **Audio test** – switch the DSP's test generator (pink noise, white noise, sine 20 Hz–20 kHz) on and off. All
outputs drop to −50 dB first and a single test fader raises them together; mute buttons for every output.
Presets can't be saved or recalled meanwhile, and stopping the test switches the noise off before every fader
returns to its previous value. A DSP found playing a test signal on connect goes straight into this mode
* **Demo mode** – one switch under ⚙ starts a simulated DSP 204 or 408 inside the app to try everything; the real
DSPs are disconnected meanwhile and nothing is sent to them
* **Many phones at once** – every change is pushed live to all connected clients
* Tap a value to type it in (`-3.5`, `1.2k`, delay in metres `2.5m`); faders snap at 0 dB, double-tap = 0 dB
## What it can do
### Mixer
Faders, mute and live meters for every input and output, on all screens. **LIM** lights up when an output's limiter
acts, as reported by the DSP. Linked channels are grouped under a named bracket in their colour.
![Mixer with named link groups](docs/screenshots/mixer.jpg)
Tap a value to type it (`-3.5`, `1.2k`, a delay in metres like `2.5m`). Faders snap at 0 dB and a double tap returns
to 0 dB. **Mute all** silences every channel of every connected DSP, and releasing it unmutes only what was open before.
### Channel and EQ
Drag the bands directly on the curve. The 8- or 9-band parametric EQ shows magnitude or phase, including crossover
filters, and can overlay any other channel, for example to line up a sub with a top.
![Parametric EQ with draggable bands](docs/screenshots/eq.jpg)
* Name, gain, delay, polarity, high and low pass, *EQ Bypass*
* Inputs: noise gate, 31-band graphic EQ
* Outputs: compressor, limiter, input routing with mix levels
* **Copy settings** from one channel to any number of channels, on all connected DSPs
### Routing
Connect inputs and outputs in a matrix. Each connection shows its level inside the crosspoint and follows the
slider as you move it.
![Routing matrix with levels](docs/screenshots/routing.jpg)
### Link groups, colours and presets
Link channels into groups, so the DSP mirrors changes within a group. Give each group a name and a colour.
![Link groups](docs/screenshots/groups.jpg)
* **Colours and group names belong to the preset.** The DSP has no preset IDs, so they are kept by preset name: same
name, same look. A preset without its own look starts empty
* **Max level** per channel: a software lock, the fader can't go higher
* **Preset files:** export the current DSP state and import it again, colours and group names included. An import
only changes the active state, writes only what actually differs and makes a backup first (*Undo import*)
### Limiter calculator
Enter your amplifiers' datasheet values (power at 8/4/2 Ω, sensitivity or gain), assign outputs and see the resulting
power when the limiter engages, the clipping headroom and the speaker load. *Limit to … W* calculates the threshold.
Attack and release presets per band (infra, sub, kick, mid, high). It is a planning aid based on an assumed reference
level, so verify it with a measurement.
![Limiter tab](docs/screenshots/limiter.jpg)
### SoundField
A top view of the room for planning. Place mains, subs, delays and fills by dragging, and see a level map, a sub map at
a chosen frequency with its cancellation lanes, and a timing map for delay speakers. It suggests aiming, height, delay
lines and sub placement, calculates the delays and writes them to the assigned DSP outputs. It is a free-field model
without reflections, so a planning aid and not a measurement. A handbook with real cases is built in.
![SoundField room plan](docs/screenshots/soundfield.jpg)
### Dashboard
Your own overview page: DSP overview, levels, faders, frequency response, channel, limiter, routing, delay, notes. Drag
modules on with a mouse, then move and resize them. It only looks and never changes a DSP. On touchscreens only the
settings of each module can be changed. The dashboard starts empty.
### DJ Brake
An optional page at `/djbrake` for a tablet at the DJ booth: a big red light when a limiter acts, on for one more second
afterwards. Limiters that don't matter, a monitor for example, can be left out. It needs no PIN, shows nothing else
and changes nothing. Turn it on under ⚙ → *Remote access* in the desktop apps, or ⚙ → *Security* on the web. In the
desktop apps it needs remote access to be on. The limiter signal comes from the DSP, and on a real DSP 204 it was seen
staying on for up to 4 seconds in some cases, so the light can stay on longer than that one second.
<img src="docs/screenshots/djbrake.jpg" alt="DJ Brake showing the limiter light" width="640">
### On your phone
The whole app adapts to phones and tablets. The web UI starts **read-only** on touch devices, and a small switch at the
top allows changes, so nothing moves by accident. Zooming is turned off so it can't get in the way of the faders. Every
change is pushed live to all connected devices.
<img src="docs/screenshots/phone.jpg" alt="The app on a phone" width="300">
### And also
* **Several DSPs at once:** pick one at the top, the model is detected automatically
* **Network search** finds DSPs in the local network and adds them with one click
* **Sound Lab** (desktop apps only): works with [REW](https://www.roomeqwizard.com/). Take the filters of a measurement or
a REW filter file onto a channel, compare before applying, send a channel's curve back. So far only tested against a
stand-in built from REW's API description, not against REW itself
* **Audio test:** the DSP's generator (pink noise, white noise, sine). All outputs drop to −50 dB first and one test
fader raises them together
* **Device lock:** DSPs locked with their 4-character code are detected and the app asks for the code
* **Settings backup** in one file, and in the desktop apps **Reset app settings**. The DSPs are disconnected first and
nothing on them changes
* **Your own logo** at the top left and as the browser icon
## Supported hardware
| Device | Network | USB | Tested on real hardware |
|--------|---------|-----|-------------------------|
| 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 |
| t.racks DSP 408 | ✓ | ✓ | briefly tried, not tested in depth; 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, 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
@@ -91,7 +143,7 @@ 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.
The DSPs accept only **one** connection at a time, so close any other control software first.
## Quick start (web UI)
@@ -117,18 +169,18 @@ Open `http://<IP-of-this-computer>:8080` in a browser (from a phone: same Wi-Fi/
`config.json` is created on the first start. Options: `--port 8080`, `--host 0.0.0.0`, `--config path/to/config.json`,
`-v` (debug log). On Windows you can also double-click `start.bat`.
**Forgot the PIN?** Stop the server, delete the `auth` entry from `config.json` and start again – the PIN is `1234`
**Forgot the PIN?** Stop the server, delete the `auth` entry from `config.json` and start again. The PIN is `1234`
again.
### Security
The PIN protects against accidental access in your own network, nothing more: it has 4 digits, a logged-in device
stays logged in for 30 days, and after 5 wrong attempts the login is blocked (30 s, growing up to 15 min). The server speaks
plain HTTP. **Do not expose it to the internet** (no port forwarding) – use a VPN if you need remote access.
plain HTTP. **Do not expose it to the internet** (no port forwarding); use a VPN if you need remote access.
## Desktop apps (Windows, macOS)
The desktop app runs the server and the UI in its own window – **no PIN needed** in the app window.
The desktop app runs the server and the UI in its own window, with **no PIN needed** in the app window.
Under ⚙ → *Remote access* you can turn on a web server for phones and tablets (port selectable); other devices
then log in with the PIN. The lock icon (top right) locks the app window (view only); unlock with the PIN.
@@ -156,16 +208,17 @@ python packaging/build.py
* installs BetterDSPControl from the card (the Pi needs no internet), as a systemd service on port 80
After 2–5 minutes open `http://<hostname>.local`. Needs administrator rights; only USB/SD drives that are not the
system or boot disk are offered. If Windows then asks to format the Linux partition, click **Cancel**.
system or boot disk are offered. If Windows then asks to format the Linux partition, click **Cancel**. Writing to a real
SD card and the first boot on a real Pi have not been tested yet.
On any other Linux machine: `python3 server.py --port 8080`. For USB access as a normal user add a udev rule for
`hidraw` devices with VID `0168` / PID `0821` (see `INSTALL_SH` in `pi_image.py`).
## USB
Choose *USB cable* for a device under ⚙. The DSPs are USB HID devices (VID 0168 / PID 0821) – no driver needed – and
speak the same frames as over the network. Works on Windows (hid.dll), macOS (IOKit) and Linux (hidraw). With two
DSPs on USB, pick the right one in the drop-down.
Choose *USB cable* for a device under ⚙. The DSPs are USB HID devices (VID 0168 / PID 0821), so no driver is needed, and
they speak the same frames as over the network. Written for Windows (hid.dll), macOS (IOKit) and Linux (hidraw); tested
on a real DSP on macOS. With two DSPs on USB, pick the right one in the drop-down.
## Testing without hardware
@@ -184,7 +237,7 @@ python sim.py --model 408 --port 9762
python server.py
```
Then add devices with IP `127.0.0.1` and ports 9761 / 9762 in the web UI. Protocol self-test:
Then add devices with IP `127.0.0.1` and ports 9761 / 9762 in the web UI. Self-test:
```bash
python tests/test_protocol.py
@@ -202,9 +255,11 @@ 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`), dashboard in `static/dashboard.js`, SoundField in `static/soundfield.js`, translations in `static/i18n.js` |
| `static/` | Web UI: `app.js`, `dashboard.js`, `soundfield.js`, `rew.js`, handbooks in `docs.js`, translations in `i18n.js` |
| `packaging/` | Build script and icons |
| `tests/` | Protocol tests |
| `tests/` | Self-tests |
| `tools/dsp_measure.py` | Measures on a real DSP how meter, gain, threshold and limiter relate |
| `docs/screenshots/` | The pictures in this file |
| `PROTOCOL.md` | Protocol documentation |
| `CLAUDE.md` | Guide for AI coding assistants (architecture, conventions, open points) |
@@ -215,7 +270,7 @@ working on it in your own Claude session. `CLAUDE.md` is read automatically by C
architecture, conventions and what is still unverified.
1. Clone the repository (see [Quick start](#quick-start-web-ui)).
2. Open the folder in Claude Code – either the **Claude desktop app** (tab *Code* → choose the folder) or in a
2. Open the folder in Claude Code: either the **Claude desktop app** (tab *Code* → choose the folder) or in a
terminal:
```bash
@@ -245,14 +300,15 @@ What I want to do: <describe your goal>.
## Contributing
Issues and pull requests are welcome – especially captures and test results from a real **DSP 408** and anything
listed as unverified in `CLAUDE.md`. Please test with the simulator first and run `python tests/test_protocol.py`.
Issues and pull requests are welcome, especially detailed test results from a real **DSP 408** and anything listed as unverified
in `CLAUDE.md`. Please test with the simulator first and run `python tests/test_protocol.py`. Owners of another model
can help a lot with `tools/dsp_measure.py`: it only lowers values, puts them back and writes a small result file.
## Disclaimer
This software talks to your audio hardware. Wrong settings (e.g. limiter thresholds, gain, crossover filters) can
damage loudspeakers or amplifiers. The limiter calculator is a planning aid based on datasheet values and an assumed
reference level – verify with a measurement before relying on it. The software is provided "as is", without
reference level, so verify with a measurement before relying on it. The software is provided "as is", without
warranty of any kind, see [LICENSE](LICENSE).
The protocol was documented for interoperability purposes only, by observing the communication of the devices and
Binary file not shown.

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 157 KiB

+48 -3
View File
@@ -22,7 +22,8 @@ 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, linknames: dict | None = None):
colors: dict | None = None, maxgain: dict | None = None, linknames: dict | None = None,
looks: dict | None = None, look_name: str = ""):
self.id = dev_id
self.name = name
self.host = host
@@ -39,6 +40,13 @@ class Device:
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"}
# colours and group names per preset. The DSP has no IDs for presets, only slots and names, and only the name
# is in its memory image, so that is the key. colors/linknames above always are those of look_name.
self.looks: dict[str, dict] = looks or {}
self.look_name = look_name
self.look_dirty = False
self.recalled = "" # the preset last loaded through the app, as listed by the DSP ...
self.recalled_image = None # ... and the name its memory image showed right after
self.maxgain: dict[str, int] = maxgain or {} # software limit of the gain fader per channel (raw), e.g. {"out0": 260}
# 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
@@ -75,11 +83,13 @@ 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, "linknames": self.linknames}
"colors": self.colors, "maxgain": self.maxgain, "linknames": self.linknames,
"looks": self.looks, "look_name": self.look_name}
def snapshot(self) -> dict:
cfg = self.config()
cfg["lock_code"] = bool(self.lock_code) # clients only learn whether a code is remembered
del cfg["looks"], cfg["look_name"]
cfg["test_level"] = self.test_level
return {**cfg, "demo": self.demo, "status": self.status, "error": self.error, "info": self.info,
"detected_model": self.model_name or None,
@@ -245,9 +255,39 @@ class Device:
self.state = state
self._emit_state()
def remember_look(self):
"""Keeps the current colours and group names with the loaded preset."""
self.looks[self.look_name] = {"colors": dict(self.colors), "linknames": dict(self.linknames)}
while len(self.looks) > 64:
del self.looks[next(k for k in self.looks if k != self.look_name)]
self.look_dirty = True
def sync_look(self):
"""After reading the DSP: another preset brings its own look, one that has none starts without.
Only the very first preset ever seen keeps what is there: those are the settings from before looks existed."""
if self.state is None:
return
name = self.state.get("preset_name", "").strip()
# that the memory image shows the new name after loading a preset is not verified on hardware: trust the list
if self.recalled:
if self.recalled_image is None:
self.recalled_image = name
if name == self.recalled_image:
name = self.recalled
else:
self.recalled = ""
if name == self.look_name and name in self.looks:
return
if self.looks:
look = self.looks.get(name, {"colors": {}, "linknames": {}})
self.colors, self.linknames = dict(look["colors"]), dict(look["linknames"])
self.look_name = name
self.remember_look()
async def recall_preset(self, index: int):
await self._request(P.CMD_PRESET_RECALL, bytes([index + 1]), timeout=2.0)
await asyncio.sleep(0.3)
self.recalled, self.recalled_image = (self.presets[index].strip() if index < len(self.presets) else ""), None
await self._load_config()
self._emit_state()
@@ -259,6 +299,9 @@ class Device:
self.presets[index] = name
if self.state:
self.state["preset_name"] = name
self.look_name = name.strip() # also when overwriting: what is stored now is what we see now
self.recalled = ""
self.remember_look()
self._emit_state()
@property
@@ -268,7 +311,8 @@ class Device:
async def export_preset(self) -> dict:
"""The DSP's current state, read fresh from the device."""
await self.refresh()
return preset.export_doc(self.model_name, self.info, self.state, self.raw)
return {**preset.export_doc(self.model_name, self.info, self.state, self.raw),
"look": {"colors": self.colors, "linknames": self.linknames}}
async def import_preset(self, state: dict) -> list[str]:
"""Put the DSP into `state` (working state only). Returns the paths that did not take."""
@@ -440,6 +484,7 @@ class Device:
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
self.sync_look()
async def _read_config(self) -> dict:
model = self.model
+259 -11
View File
@@ -16,12 +16,16 @@ import math
import mimetypes
import re
import secrets
import shutil
import socket
import struct
import sys
import time
import uuid
from pathlib import Path
from urllib.error import HTTPError, URLError
from urllib.parse import parse_qs, urlsplit
from urllib.request import Request, urlopen
import sim
from dsp import preset, usbhid
@@ -144,6 +148,83 @@ def clean_soundfield(data) -> dict:
}
REW_URL = "http://127.0.0.1:4735" # REW's API only answers on its own computer
def rew_call(method: str, path: str, body=None):
"""One request to REW's API."""
data = json.dumps(body).encode() if body is not None else None
req = Request(REW_URL + path, data=data, method=method, headers={"Content-Type": "application/json"})
try:
with urlopen(req, timeout=8) as r:
raw = r.read()
except HTTPError as e:
try:
msg = json.loads(e.read()).get("message", "")
except (ValueError, AttributeError):
msg = ""
raise RuntimeError(f"REW: {msg or e.code}") from None
except (URLError, OSError):
raise RuntimeError("REW can't be reached") from None
return json.loads(raw) if raw else {}
def rew_id(body: dict) -> str:
mid = str(body.get("id") or "")
if not re.fullmatch(r"[\w-]{1,64}", mid):
raise ValueError("No measurement chosen")
return mid
def rew_filters(mid: str) -> list:
res = rew_call("GET", f"/measurements/{mid}/filters")
return res.get("filters", []) if isinstance(res, dict) else res
def rew_measurements() -> list:
res = rew_call("GET", "/measurements")
items = res.values() if isinstance(res, dict) else res
return [{"id": m.get("uuid") or "", "title": m.get("title") or "?"} for m in items if isinstance(m, dict) and m.get("uuid")]
def rew_send_filters(mid: str, filters: list):
"""Put a channel's EQ on a measurement. The generic equaliser takes all filter types and enough filters."""
rew_call("POST", f"/measurements/{mid}/equaliser", {"manufacturer": "Generic", "model": "Generic"})
filters = [f for f in filters if isinstance(f, dict)][:9]
for i, f in enumerate(filters):
f["index"] = i + 1
rest = [{"index": f.get("index"), "type": "None", "enabled": True, "isAuto": False}
for f in rew_filters(mid) if isinstance(f, dict) and f.get("index", 0) > len(filters) and f.get("type") not in (None, "None")]
rew_call("POST", f"/measurements/{mid}/filters", {"filters": filters + rest})
def rew_floats(values) -> str:
"""REW's data format: base64 of 32-bit floats, most significant byte first."""
return base64.b64encode(struct.pack(f">{len(values)}f", *[float(v) for v in values])).decode()
def rew_send_curve(body: dict):
mag, phase = body.get("magnitude"), body.get("phase")
if not isinstance(mag, list) or not isinstance(phase, list) or not 2 <= len(mag) <= 4000 or len(mag) != len(phase):
raise ValueError("No curve to send")
rew_call("POST", "/import/frequency-response-data", {
"identifier": str(body.get("identifier") or "DSP Control")[:60], "isImpedance": False,
"startFreq": _num(body.get("startFreq"), 1, 20000, 20), "ppo": int(_num(body.get("ppo"), 1, 192, 96)),
"magnitude": rew_floats(mag), "phase": rew_floats(phase)})
DJ_HOLD = 1.0 # s the light of /djbrake stays on after a limiter acted
def clean_dj_ignore(data) -> dict:
"""Outputs the DJ Brake does not watch, per device id. Everything else is watched, so new DSPs count by default."""
if not isinstance(data, dict):
return {}
out = {str(k)[:64]: sorted({i for i in v if type(i) is int and 0 <= i < 16})
for k, v in list(data.items())[:64] if isinstance(v, list)}
return {k: v for k, v in out.items() if v}
DASH_TYPES = ("status", "meters", "mixer", "curve", "channel", "limiter", "routing", "delays", "fir", "notes")
@@ -186,6 +267,15 @@ def clean_linknames(v) -> dict:
return out
def clean_looks(v) -> dict:
"""Colours and group names per preset name: {"Party": {"colors": {...}, "linknames": {...}}}."""
out = {}
for k, look in list(v.items() if isinstance(v, dict) else [])[:64]:
if isinstance(look, dict):
out[str(k)[:14]] = {"colors": clean_colors(look.get("colors")), "linknames": clean_linknames(look.get("linknames"))}
return out
def clean_maxgain(v) -> dict:
"""Software gain limits per channel: {"in0": raw 0..399} (400 = +12 dB would be no limit)."""
out = {}
@@ -224,6 +314,13 @@ class App:
self.limiter: dict = clean_limiter({})
self.soundfield: dict = clean_soundfield({})
self.dashboard: dict | None = None
self.djbrake = False # page /djbrake for the DJ: without PIN, shows only whether a limiter acts
self.dj_ignore: dict = {} # device id -> outputs not watched
self.dj_hint = True # short text on the page: the limiter is not the goal
self.dj_hint_en = True # that text always in English, else in the language of the browser
self.dj_hit = 0.0 # when a limiter was last seen acting
self.dj_ready: dict = {} # device id -> has it an output that is watched
self.dj_streams = 0
self.logo = ""
# desktop app: its own window logs in with a one-time token, other devices need the PIN
self.app_token: str | None = None
@@ -233,6 +330,7 @@ class App:
self.remote_writers: set[asyncio.StreamWriter] = set()
self.remote_error = ""
self.locked = False # desktop app window read-only until unlocked with the PIN
self.lock_dash = False # while locked the app window shows nothing but the dashboard
self.lang = "" # UI language chosen in the desktop app ("" = not chosen yet, English)
# demo mode: the real DSPs are disconnected and a simulated one runs inside the server
self.demo = {"enabled": False, "model": "408"}
@@ -247,13 +345,11 @@ class App:
if self.config_path.exists():
cfg = json.loads(self.config_path.read_text(encoding="utf-8"))
else:
cfg = {"devices": [
{"id": "dsp204", "name": "DSP 204", "host": "192.168.1.101", "model": "204", "autoconnect": False},
{"id": "dsp408", "name": "DSP 408", "host": "192.168.1.102", "model": "408", "autoconnect": False},
]}
cfg = {"devices": []}
now = time.time()
self.sessions = {k: v for k, v in cfg.get("sessions", {}).items() if v > now}
self.locked = bool(cfg.get("locked"))
self.lock_dash = bool(cfg.get("lock_dash"))
self.lang = cfg.get("lang") if cfg.get("lang") in ("en", "de") else ""
m = cfg.get("mute_all") or {}
self.mute_all = {"active": bool(m.get("active")), "restore": {
@@ -273,6 +369,10 @@ class App:
self.soundfield = clean_soundfield(cfg.get("soundfield"))
if "dashboard" in cfg:
self.dashboard = clean_dashboard(cfg.get("dashboard"))
self.djbrake = bool(cfg.get("djbrake"))
self.dj_ignore = clean_dj_ignore(cfg.get("dj_ignore"))
self.dj_hint = bool(cfg.get("dj_hint", True))
self.dj_hint_en = bool(cfg.get("dj_hint_en", True))
if "logo" in cfg:
self.logo = clean_logo(cfg.get("logo"))
r = cfg.get("remote") or {}
@@ -289,7 +389,35 @@ class App:
return {"format": CONFIG_FORMAT, "version": 1, "exported": time.strftime("%Y-%m-%dT%H:%M:%S"),
"devices": [d.config() for d in self.real_devices()], "auth": self.auth,
"limiter": self.limiter, "remote": self.remote, "soundfield": self.soundfield, "logo": self.logo,
"dashboard": self.dashboard}
"dashboard": self.dashboard, "djbrake": self.djbrake, "dj_ignore": self.dj_ignore, "dj_hint": self.dj_hint, "dj_hint_en": self.dj_hint_en}
async def reset_config(self):
"""Back to a fresh app. Only the app: the DSPs get disconnected first and receive nothing."""
if any(d.test_active for d in self.real_devices()):
raise ValueError("End the audio test first: the DSP would stay at the lowered level")
if self.mute_all["active"]:
raise ValueError("Release mute all first: the DSPs would stay muted")
self.demo_resume = set()
if self.demo["enabled"]:
await self.stop_demo()
for dev in self.real_devices():
await dev.stop()
del self.devices[dev.id]
self.broadcast({"type": "removed", "device": dev.id})
if self.config_path.exists(): # one way back, in case this was a mistake
shutil.copyfile(self.config_path, self.config_path.with_name("config.before-reset.json"))
sessions = {k: v for k, v in self.sessions.items() if k in self.app_sessions}
keep = {"config_path", "clients", "app_token", "app_sessions", "remote_server", "remote_writers", "failures", "dj_streams"}
for name, value in vars(App(self.config_path)).items():
if name not in keep:
setattr(self, name, value)
self.sessions = sessions
self.apply_config({})
self.save()
self.broadcast({"type": "reset"})
await asyncio.sleep(0.2) # let the phones hear it before their connection goes
if self.app_token:
await self.start_remote()
async def restore_config(self, doc: dict, session: str):
if not isinstance(doc, dict) or doc.get("format") != CONFIG_FORMAT:
@@ -331,8 +459,17 @@ class App:
for old in self.undo_files(dev.id)[MAX_UNDO:]:
old.unlink(missing_ok=True)
diffs = await dev.import_preset(state)
self.take_look(dev, body.get("doc"))
return {"ok": not diffs, "differences": diffs[:20], "name": state.get("preset_name", "")}
def take_look(self, dev: Device, doc):
"""Colours and group names that came with a preset file (older files have none)."""
look = doc.get("look") if isinstance(doc, dict) else None
if isinstance(look, dict):
dev.colors, dev.linknames = clean_colors(look.get("colors")), clean_linknames(look.get("linknames"))
dev.remember_look()
self.broadcast({"type": "device", "device": dev.id, "data": dev.snapshot()})
async def undo_import(self, dev: Device) -> dict:
files = self.undo_files(dev.id)
if not files:
@@ -340,14 +477,15 @@ class App:
doc = json.loads(files[0].read_text(encoding="utf-8"))
state = preset.read_file(dev.model_name, dev.model, dev.state, doc=doc)
diffs = await dev.import_preset(state)
self.take_look(dev, doc)
files[0].unlink()
return {"ok": not diffs, "differences": diffs[:20]}
def save(self):
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, "dashboard": self.dashboard,
"sessions": sessions, "limiter": self.limiter, "remote": self.remote, "locked": self.locked, "lock_dash": self.lock_dash,
"soundfield": self.soundfield, "logo": self.logo, "dashboard": self.dashboard, "djbrake": self.djbrake, "dj_ignore": self.dj_ignore, "dj_hint": self.dj_hint, "dj_hint_en": self.dj_hint_en,
"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:
@@ -363,7 +501,8 @@ 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")), linknames=clean_linknames(d.get("linknames")))
maxgain=clean_maxgain(d.get("maxgain")), linknames=clean_linknames(d.get("linknames")),
looks=clean_looks(d.get("looks")), look_name=str(d.get("look_name") or "")[:14])
dev.on_online = self.device_online
self.devices[dev_id] = dev
if dev.autoconnect:
@@ -803,7 +942,34 @@ class App:
# ------------------------------------------------------------ events
def dj_note(self, ev: dict, now: float | None = None):
"""Keeps the state of the /djbrake page. A muted output is not watched: nobody hears it."""
dev = self.devices.get(ev["device"])
if not dev or not dev.state:
return
now = time.monotonic() if now is None else now
watched, ignore = False, self.dj_ignore.get(dev.id, ())
for i, limit in enumerate(ev["limit"]):
if i not in ignore and not dev.state["outputs"][i]["mute"]:
watched = True
if limit:
self.dj_hit = now
self.dj_ready[dev.id] = watched
def dj_state(self, now: float) -> dict:
"""All /djbrake may know, without a login. Nothing else leaves here."""
return {"on": now - self.dj_hit < DJ_HOLD,
"ready": any(self.dj_ready.get(d.id) for d in self.devices.values() if d.status == "online"),
"hint": ("en" if self.dj_hint_en else "auto") if self.dj_hint else None}
def broadcast(self, ev: dict):
if ev["type"] == "meters":
self.dj_note(ev)
elif ev["type"] == "device":
dev = self.devices.get(ev["device"])
if dev and dev.look_dirty:
dev.look_dirty = False
self.save()
msg = json.dumps(ev, separators=(",", ":"))
for q in list(self.clients):
if ev["type"] == "meters" and q.qsize() > 50:
@@ -826,6 +992,19 @@ class App:
return {"logo": self.logo}
if path == "/api/logo":
return {"logo": self.logo}
if path == "/api/djbrake" and method == "PUT":
if "enabled" in body:
self.djbrake = bool(body["enabled"])
if "ignore" in body:
self.dj_ignore = clean_dj_ignore(body["ignore"])
if "hint" in body:
self.dj_hint = bool(body["hint"])
if "hint_en" in body:
self.dj_hint_en = bool(body["hint_en"])
self.save()
ans = {"enabled": self.djbrake, "ignore": self.dj_ignore, "hint": self.dj_hint, "hint_en": self.dj_hint_en}
self.broadcast({"type": "djbrake", **ans})
return ans
if path == "/api/dashboard" and method == "PUT":
self.dashboard = clean_dashboard(body)
self.save()
@@ -850,6 +1029,19 @@ class App:
return await self.set_demo(body) if method == "PUT" else self.demo_info()
if path == "/api/scan" and method == "POST":
return await self.scan_network()
if path == "/api/rew/status" and method == "GET":
res = await asyncio.to_thread(rew_call, "GET", "/version")
return {"version": res.get("message", "") if isinstance(res, dict) else str(res)}
if path == "/api/rew/measurements" and method == "GET":
return await asyncio.to_thread(rew_measurements)
if path == "/api/rew/filters" and method == "POST":
return await asyncio.to_thread(rew_filters, rew_id(body))
if path == "/api/rew/send-filters" and method == "POST":
await asyncio.to_thread(rew_send_filters, rew_id(body), body.get("filters") or [])
return {"ok": True}
if path == "/api/rew/send-curve" and method == "POST":
await asyncio.to_thread(rew_send_curve, body)
return {"ok": True}
if path == "/api/usb" and method == "GET":
return await asyncio.to_thread(usbhid.list_devices)
if path == "/api/limiter" and method == "GET":
@@ -949,11 +1141,13 @@ class App:
return {"ok": True}
if action == "colors": # display only, stays in the app (the DSP doesn't know colours)
dev.colors = clean_colors(body.get("colors"))
dev.remember_look()
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"))
dev.remember_look()
self.save()
self.broadcast({"type": "device", "device": dev.id, "data": dev.snapshot()})
return {"ok": True, "linknames": dev.linknames}
@@ -1012,10 +1206,15 @@ class App:
cookie = self.app_login(parse_qs(url.query).get("t", [""])[0])
if cookie:
await self.respond(writer, 302, b"", "text/plain",
"Location: /\r\n" + self.cookie(cookie, SESSION_TTL))
f"Location: /?start=app&lang={self.lang or 'en'}\r\n" + self.cookie(cookie, SESSION_TTL))
else:
await self.respond(writer, 401, b"invalid app token", "text/plain")
return
if path == "/djbrake/state":
await self.dj_stream(writer)
return
if path in ("/djbrake", "/djbrake/"):
path = "/djbrake.html"
if path.startswith("/api/"):
try:
data = json.loads(body) if body else {}
@@ -1027,7 +1226,7 @@ class App:
is_app = session in self.app_sessions
if path == "/api/auth":
await self.respond_json(writer, 200, {"authenticated": bool(session), "app": is_app,
"locked": is_app and self.locked,
"locked": is_app and self.locked, "lock_dash": is_app and self.lock_dash,
"lang": self.lang if is_app else ""})
return
if path == "/api/login" and method == "POST":
@@ -1052,6 +1251,18 @@ class App:
self.save()
await self.respond_json(writer, 200, {"lang": self.lang})
return
if path.startswith("/api/rew/") and not is_app: # REW runs next to the desktop app
await self.respond_json(writer, 403, {"error": "desktop app only"})
return
if path == "/api/lock-dash" and method == "POST":
if not is_app:
await self.respond_json(writer, 403, {"error": "desktop app only"})
else:
self.lock_dash = bool(data.get("enabled"))
self.save()
self.broadcast({"type": "lockdash", "enabled": self.lock_dash})
await self.respond_json(writer, 200, {"enabled": self.lock_dash})
return
if path in ("/api/lock", "/api/unlock") and method == "POST":
if not is_app:
await self.respond_json(writer, 403, {"error": "desktop app only"})
@@ -1068,6 +1279,16 @@ class App:
if path == "/api/pin" and method == "POST":
await self.respond_json(writer, *await self.change_pin(session, data))
return
if path == "/api/reset" and method == "POST":
if not is_app:
await self.respond_json(writer, 403, {"error": "desktop app only"})
else:
try:
await self.reset_config()
await self.respond_json(writer, 200, {"ok": True})
except ValueError as e:
await self.respond_json(writer, 400, {"error": str(e)})
return
if path == "/api/backup":
if method == "GET":
await self.respond_json(writer, 200, self.export_config())
@@ -1124,6 +1345,9 @@ class App:
async def static(self, writer, path: str):
rel = "index.html" if path in ("/", "") else path.lstrip("/")
if rel == "djbrake.html" and not self.djbrake:
await self.respond(writer, 404, b"not found", "text/plain")
return
f = (STATIC / rel).resolve()
if STATIC not in f.parents or not f.is_file():
await self.respond(writer, 404, b"not found", "text/plain")
@@ -1133,6 +1357,30 @@ class App:
ctype += "; charset=utf-8"
await self.respond(writer, 200, f.read_bytes(), ctype)
async def dj_stream(self, writer):
if not self.djbrake or self.dj_streams >= 20:
await self.respond(writer, 404, b"not found", "text/plain")
return
self.dj_streams += 1
writer.write(b"HTTP/1.1 200 OK\r\nContent-Type: text/event-stream\r\nCache-Control: no-cache\r\n"
b"Connection: keep-alive\r\nX-Accel-Buffering: no\r\n\r\n")
last, idle = None, 0.0
try:
while self.djbrake:
now = time.monotonic()
state = self.dj_state(now)
if state != last:
writer.write(f"data: {json.dumps(state)}\n\n".encode())
last, idle = state, 0.0
elif idle > 15:
writer.write(b": ping\n\n")
idle = 0.0
await writer.drain()
await asyncio.sleep(0.1)
idle += 0.1
finally:
self.dj_streams -= 1
async def sse(self, writer):
writer.write(b"HTTP/1.1 200 OK\r\nContent-Type: text/event-stream\r\nCache-Control: no-cache\r\n"
b"Connection: keep-alive\r\nX-Accel-Buffering: no\r\n\r\n")
@@ -1141,7 +1389,7 @@ class App:
try:
hello = {"type": "hello", "devices": [d.snapshot() for d in self.devices.values()], "limiter": self.limiter,
"demo": self.demo_info(), "muteall": self.mute_all_info(), "soundfield": self.soundfield, "logo": self.logo,
"dashboard": self.dashboard}
"dashboard": self.dashboard, "djbrake": self.djbrake, "dj_ignore": self.dj_ignore, "dj_hint": self.dj_hint, "dj_hint_en": self.dj_hint_en}
writer.write(f"data: {json.dumps(hello)}\n\n".encode())
await writer.drain()
while True:
+179 -27
View File
@@ -553,7 +553,7 @@ const limitOn = new Map(); // "dev|idx" -> time it was last reported active
let limEls = [];
const LIM_HOLD = 300; // ms an LED stays lit, so short hits are visible
const limLed = (devId, i, cls = "") => h("span", { class: "limled " + cls, "data-lim": `${devId}|${i}`, title: t("Limiter active"), "aria-hidden": "true" },
cls ? "LIM" : null);
cls && cls !== "dot" ? "LIM" : null);
function updateMeters(ev) {
for (const kind of ["in", "out"])
@@ -626,6 +626,7 @@ function renderTabs() {
$("#btn-settings").disabled = testLock;
document.querySelectorAll("#viewtabs button").forEach(b => {
if (b.dataset.view === "fir") b.hidden = !(dev() && dev().fir);
if (b.dataset.view === "lab") b.hidden = !S.isApp;
b.classList.toggle("active", !S.settings && b.dataset.view === S.view);
b.disabled = testLock && b.dataset.view !== "test";
});
@@ -908,7 +909,7 @@ function strip(d, kind, i) {
el.append(
h("button", { class: "strip-head", onclick: () => openChannel(kind, i), title: t("Edit channel") },
h("span", { class: "kind" }, chLabel(kind, i), linkBadge(d, kind, i), polBadge(d, kind, i)), h("span", { class: "nm" }, ch.name || " "),
kind === "out" ? limLed(d.id, i) : h("span", { class: "limled ph", "aria-hidden": "true" })), // keeps faders level with the outputs
kind === "out" ? limLed(d.id, i, "txt") : h("span", { class: "limled txt ph", "aria-hidden": "true" }, "LIM")), // keeps faders level with the outputs
h("div", { class: "faderbox" }, ledMeter(d.id, kind, i), f),
db,
toggleBtn("MUTE", kind, i, "mute", "mute", v => el.classList.toggle("muted", v)));
@@ -1164,7 +1165,7 @@ const hasQ = type => [0, 4, 6, 7, 8].includes(type);
const OUT_COLORS = ["#f97316", "#facc15", "#4ade80", "#e879f9", "#60a5fa", "#fb7185", "#2dd4bf", "#c084fc"];
const chColor = (d, kind, i) => custColor(d, kind, i) || (kind === "in" ? IN_COLORS[i] : OUT_COLORS[i]);
// opts: { mode: "mag" | "phase", overlays: [{ ch, color }] }
// opts: { mode: "mag" | "phase", overlays: [{ ch, color }], overlaysOnly: no curve or bands of `ch` itself }
function drawCurve(canvas, ch, selBand, opts = canvas.curveOpts ? canvas.curveOpts() : {}) {
const dpr = window.devicePixelRatio || 1, W = canvas.clientWidth, H = canvas.clientHeight;
if (!W || !H) return null;
@@ -1211,7 +1212,8 @@ function drawCurve(canvas, ch, selBand, opts = canvas.curveOpts ? canvas.curveOp
g.strokeStyle = color; g.lineWidth = width; g.lineJoin = "round";
for (const sg of segs) { g.beginPath(); sg.forEach(([x, y], i) => i ? g.lineTo(x, y) : g.moveTo(x, y)); g.stroke(); }
};
for (const o of opts.overlays || []) stroke(trace(f => channelH(o.ch, f)), o.color + "cc", 1.5);
for (const o of opts.overlays || []) stroke(trace(f => channelH(o.ch, f)), o.color + "cc", opts.overlaysOnly ? 2 : 1.5);
if (opts.overlaysOnly) return { fx, dy, W, H, phase }; // dashboard: only the compared channels
const sb = ch.peq[selBand];
if (!phase && sb && !sb.bypass && !ch.peq_bypass) { // selected band's own contribution, filled
g.beginPath(); g.moveTo(0, dy(0));
@@ -1358,6 +1360,7 @@ function peqCard(d, kind, idx) {
const card = h("div", { class: "card wide" + (ch.peq_bypass ? " eq-off" : "") },
h("h3", {}, h("span", { class: "grow" }, t("Parametric EQ")), modeSeg,
d.fir ? null : toggleBtn("EQ Bypass", kind, idx, "peq_bypass", "small bypass", v => { card.classList.toggle("eq-off", v); renderBand(); redraw(); }),
S.isApp ? h("button", { class: "small", "data-view-ok": "", title: t("Open this channel in Sound Lab (REW)"), onclick: () => openLab(kind, idx) }, "REW") : null,
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) => {
@@ -1413,7 +1416,7 @@ function channelBar(d) {
h("div", { class: "chselwrap", style: ccStyle(d, kind, idx) }, sel),
h("button", { class: "icon nav", "aria-label": t("Next channel"), onclick: () => go(pos + 1) }, svgIcon(ICON.next)),
ledMeter(d.id, kind, idx, "h"),
kind === "out" ? limLed(d.id, idx, "h") : null,
kind === "out" ? limLed(d.id, idx, "txt barlim") : null,
toggleBtn("MUTE", kind, idx, "mute", "mute"));
}
@@ -1423,6 +1426,12 @@ function viewChannel(d) {
const redrawPeq = () => { const c = main.querySelector("canvas.curve"); c && drawCurve(c, chans(dev(), k)[i], S.band); };
const li = linkInfo(d, k, i);
// gain of an output: LIM lights up next to the value when the limiter acts
const gainRow = () => {
const row = paramSlider("Gain", k, i, "gain", "gain");
if (k === "out") row.querySelector(".valbox").before(limLed(d.id, i, "txt gainlim"));
return row;
};
const basics = h("div", { class: "card" }, h("h3", {}, h("span", { class: "grow" }, t("Channel")),
h("button", { class: "small", onclick: () => copyDialog(d, k, i) }, t("Copy to…"))),
li ? h("p", { class: "info linknote", style: `--lc:${li.color}` }, svgIcon(ICON.link),
@@ -1441,7 +1450,7 @@ function viewChannel(d) {
},
onchange: e => { setParam(k, i, "name", cleanName(e.target.value).trim()); render(); } })),
toggleBtn("Phase Ø", k, i, "polarity")),
paramSlider("Gain", k, i, "gain", "gain"),
gainRow(),
paramSlider("Delay", k, i, "delay", "delay"));
const xo = (title, key) => h("div", { class: "xo" },
@@ -1465,11 +1474,11 @@ function viewChannel(d) {
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"),
cards.push(h("div", { class: "card wide" }, h("h3", {}, "Noise Gate"), h("div", { class: "paramgrid" },
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")));
paramSlider("Release", k, i, "gate.release", "release"))));
cards.push(peqCard(d, k, i), geqCard(d, i));
} else {
cards.push(routingCard(d, i), peqCard(d, k, i));
@@ -1497,16 +1506,25 @@ function mixList(d, o) {
const m = chans(dev(), "out")[o].matrix ^ (1 << i);
setParam("out", o, "matrix", m); render();
} }, h("span", { class: "sw" }), chTitle(d, "in", i));
return h("div", { class: "mixrow" + (on ? "" : " off") }, btn, paramSlider(t("Level"), "out", o, `mix.${i}`, "mix"));
return h("div", { class: "mixrow" + (on ? "" : " off") }, btn, paramSlider(t("Level"), "out", o, `mix.${i}`, "mix",
v => showLive(`${d.id}|out|${o}|mix.${i}`, v)));
});
}
function routingCard(d, o) {
return h("div", { class: "card" }, h("h3", {}, t("Sources → ") + chLabel("out", o)), mixList(d, o));
return h("div", { class: "card wide" }, h("h3", {}, t("Sources → ") + chLabel("out", o)), mixList(d, o));
}
// ------------------------------------------------------------------ routing view
function xpLevel(o, i, raw) {
const el = h("small");
const show = v => { const db = gainDb(v); el.textContent = db === 0 ? "0" : sign(db); el.title = `${sign(db)} dB`; };
show(raw);
onLive("out", o, `mix.${i}`, show);
return el;
}
function viewRouting(d) {
const ins = chans(d, "in"), outs = chans(d, "out");
const grid = h("div", { class: "xmatrix", style: `--n:${ins.length}` });
@@ -1523,12 +1541,15 @@ function viewRouting(d) {
h("span", { class: "chev" }, open ? "▴" : "▾")));
ins.forEach((_, i) => {
const on = oc.matrix >> i & 1;
grid.append(h("button", { class: "xp" + (on ? " on" : ""), style: `--cc:${inColor(d, i)}`,
const fx = S.xpFx === `${d.id}|${o}|${i}`; // just switched: short animation, once
if (fx) S.xpFx = null;
grid.append(h("button", { class: "xp" + (on ? " on" : "") + (fx ? " fx" : ""), style: `--cc:${inColor(d, i)}`,
"aria-label": `${chLabel("in", i)} → ${chLabel("out", o)}`, "aria-pressed": String(!!on),
onclick: () => {
const m = chans(dev(), "out")[o].matrix ^ (1 << i);
S.xpFx = `${d.id}|${o}|${i}`;
setParam("out", o, "matrix", m); render();
} }, h("span", { class: "node" }), on ? h("small", {}, gainDb(oc.mix[i]) === 0 ? "0 dB" : sign(gainDb(oc.mix[i]))) : null));
} }, h("span", { class: "node" }), on ? xpLevel(o, i, oc.mix[i]) : null));
});
if (open) grid.append(h("div", { class: "xpanel" }, h("div", { class: "xpanel-h" }, t("Level for {ch}", { ch: chTitle(d, "out", o) }),
h("button", { class: "small", onclick: () => openChannel("out", o) }, t("Open channel"))), mixList(d, o)));
@@ -1657,6 +1678,7 @@ function colorCard(d) {
g.length > 1 ? h("span", { class: "lnk" }, svgIcon(ICON.link)) : null);
};
return h("div", { class: "card wide colorbox" }, h("h3", {}, t("Channel colours")),
h("p", { class: "info" }, t("Colours and group names belong to the loaded preset (by its name) and come back when you load it.")),
h("p", { class: "info" }, t("Shown on the mixer strips and in the channel view. Linked channels share one colour; every colour can only be used once per DSP.")),
h("div", { class: "colgrid" },
h("div", {}, h("div", { class: "sub" }, t("Inputs")), chanGroups(d, "in").map(g => row("in", g))),
@@ -1897,7 +1919,7 @@ function limiterCard(d, o) {
] : [];
const card = h("div", { class: "card limcard" },
h("h3", {}, h("span", { class: "grow" }, chTitle(d, "out", o)), ledMeter(d.id, "out", o, "h"),
h("h3", {}, h("span", { class: "grow" }, chTitle(d, "out", o)), ledMeter(d.id, "out", o, "h"), limLed(d.id, o, "dot"),
h("button", { class: "small", onclick: () => openChannel("out", o) }, t("Channel"))),
res,
h("div", { class: "limgrid" },
@@ -2089,7 +2111,7 @@ function viewTest(d) {
ticks: [-60, -50, -40, -30, -20, -10, 0].map(db => [(db - LVL_MIN) * 2, String(db)]),
onInput: v => { const db = LVL_MIN + v / 2; d.test_level = db; val.textContent = `${db.toFixed(1)} dB`; sendTestLevel(d, db); } });
const outs = chans(d, "out").map((ch, i) => {
const m = h("div", { class: "tmeter" + (ch.mute ? " muted" : "") }, ledMeter(d.id, "out", i), h("small", {}, chLabel("out", i)), limLed(d.id, i));
const m = h("div", { class: "tmeter" + (ch.mute ? " muted" : "") }, ledMeter(d.id, "out", i), h("small", {}, chLabel("out", i)), limLed(d.id, i, "txt"));
m.append(toggleBtn("MUTE", "out", i, "mute", "mute small", v => m.classList.toggle("muted", v)));
return m;
});
@@ -2198,6 +2220,39 @@ function deviceForm(d) {
}
// App settings backup: devices, amplifiers/limiter data, PIN, remote access (not the DSP presets)
// a fresh app: what this browser remembers goes as well
function appWasReset() {
try { Object.keys(localStorage).filter(k => k.startsWith("dsp.")).forEach(k => localStorage.removeItem(k)); sessionStorage.clear(); } catch { /* private mode */ }
location.replace(S.isApp ? "/?start=app&lang=en" : "/");
}
async function resetDialog() {
const letters = "ABCDEFGHJKMNPQRSTUVWXYZ"; // no I, L and O: easy to mistake
const code = [0, 1].map(() => letters[Math.floor(Math.random() * letters.length)]).join("");
const matches = () => input.value.trim().toUpperCase() === code;
const input = h("input", { type: "text", class: "code resetcode", maxlength: 2, autocomplete: "off", autocapitalize: "characters", spellcheck: "false", "aria-label": t("Letters"),
oninput: () => { document.querySelector("#modal .dlg-actions button:last-child").disabled = !matches(); } });
const stuck = S.order.map(id => S.devices[id]).filter(d => !d.demo && d.test_saved && d.status !== "online").map(d => d.name);
const open = modal({ title: t("Reset all app settings?"),
body: h("div", { class: "resetbody" },
h("p", { class: "resetlead" }, t("All DSPs are disconnected first, then the app starts fresh.")),
h("div", { class: "resetlists" },
h("div", { class: "resetlist gone" }, h("b", {}, t("Removed from the app")), h("ul", {},
[t("DSP list"), t("Colours and group names"), t("Amplifiers and SoundField plan"), t("Dashboard and DJ Brake"), t("Remote access and language"), t("PIN, back to 1234")].map(x => h("li", {}, x)))),
h("div", { class: "resetlist stays" }, h("b", {}, t("Stays as it is")), h("ul", {},
[t("All settings in the DSPs"), t("Presets in the DSPs"), t("A copy of the old app settings")].map(x => h("li", {}, x))))),
stuck.length ? h("p", { class: "resetwarn" }, t("{names} still has the lowered levels of an interrupted audio test. The app can no longer undo that after the reset.", { names: stuck.join(", ") })) : null,
h("div", { class: "resetcheck" }, h("span", {}, t("To confirm, type these letters:")),
h("div", { class: "resetrow" },
h("div", { class: "resetletters", role: "img", "aria-label": code }, [...code].map(c => h("i", {}, c))),
h("span", { class: "resetarrow", "aria-hidden": "true" }, "→"), input))),
actions: [{ label: t("Cancel") }, { label: t("Reset"), primary: true, cls: "danger-on", value: () => matches() ? true : undefined }] });
document.querySelector("#modal .dlg-actions button:last-child").disabled = true;
if (!await open) return;
try { await api("POST", "/api/reset"); appWasReset(); }
catch (e) { toast(t("Error: ") + trMsg(e.message)); }
}
function backupCard() {
const exportCfg = async () => {
try { if (await saveFile(`DSP-Control-${t("Settings")}_${today()}.json`, await api("GET", "/api/backup"))) toast(t("Settings backed up")); }
@@ -2226,10 +2281,20 @@ function backupCard() {
return h("div", { class: "card" }, h("h3", {}, t("App settings")),
h("p", { class: "info" }, t("Saves devices, amplifiers & limiter calculator, PIN and remote access to a file. ") +
t("The settings inside the DSPs are saved per device via “File…” at the top.")),
h("div", { class: "row" }, h("button", { onclick: exportCfg }, t("Back up…")), h("button", { onclick: restore }, t("Restore…"))));
h("div", { class: "row" }, h("button", { onclick: exportCfg }, t("Back up…")), h("button", { onclick: restore }, t("Restore…")),
S.isApp ? h("button", { class: "danger", onclick: resetDialog }, t("Reset all app settings…")) : null));
}
// Desktop app only: let phones/tablets on the LAN use this PC as server (they need the PIN)
function lockOption() {
const box = h("input", { type: "checkbox", checked: !!S.lockDash, onchange: async () => {
try { S.lockDash = (await api("POST", "/api/lock-dash", { enabled: box.checked })).enabled; }
catch (e) { box.checked = !!S.lockDash; toast(t("Error: ") + trMsg(e.message)); }
} });
return h("div", { class: "lockopt" }, h("label", { class: "chk" }, box, t("Only show dashboard while locked")),
h("p", { class: "info" }, t("With the lock on, this window then shows just your dashboard, until it is unlocked with the PIN.")));
}
function remoteCard() {
const r = S.remote || { enabled: false, port: 8080, urls: [] };
const port = h("input", { type: "number", min: 1, max: 65535, value: r.port, class: "short", "aria-label": "Port" });
@@ -2237,8 +2302,10 @@ function remoteCard() {
try { S.remote = await api("PUT", "/api/remote", body); } catch (e) { toast(e.message); }
render();
};
const sw = h("button", { class: r.enabled ? "on" : "", "aria-pressed": String(r.enabled), onclick: () => put({ enabled: !r.enabled, port: +port.value || 8080 }) },
r.enabled ? t("On") : t("Off"));
const sw = h("div", { class: "seg" }, [[false, t("Off")], [true, t("On")]].map(([v, label]) => {
const on = v === !!r.enabled;
return h("button", { class: on ? "on" : "", "aria-pressed": String(on), onclick: () => on || put({ enabled: v, port: +port.value || 8080 }) }, label);
}));
let status;
if (r.error) status = h("div", { class: "err" }, trMsg(r.error));
else if (r.running) status = h("div", { class: "remote-urls" }, h("div", { class: "info" }, t("Open on a phone in the same Wi-Fi:")),
@@ -2246,9 +2313,9 @@ function remoteCard() {
else status = h("p", { class: "info" }, t("Off – only this window has access."));
return h("div", { class: "card" }, h("h3", {}, h("span", { class: "dot " + (r.running ? "online" : r.error ? "error" : "disconnected") }),
h("span", { class: "grow" }, t("Remote access (web server)"))),
h("div", { class: "row" }, h("span", { class: "grow" }, t("Allow phones & tablets")), sw),
h("div", { class: "row" }, h("span", { class: "grow" }, "Port"), port,
h("button", { class: "small", onclick: () => put({ port: +port.value || 8080 }) }, t("Apply"))),
h("div", { class: "kv" }, h("span", {}, t("Allow phones & tablets")), h("div", { class: "kvc" }, sw)),
h("div", { class: "kv" }, h("span", {}, "Port"), h("div", { class: "kvc" }, port,
h("button", { onclick: () => put({ port: +port.value || 8080 }) }, t("Apply")))),
status,
h("p", { class: "info" }, t("Other devices log in with the PIN (changeable below). Only runs while this app is open. "),
r.platform === "darwin"
@@ -2278,7 +2345,8 @@ function pinCard() {
S.isApp ? null : h("button", { onclick: logout }, svgIcon(ICON.logout), t(" Log out")))),
h("p", { class: "info" }, S.isApp
? t("This app needs no PIN. The default is 1234; changing it logs out all phones.")
: t("The default PIN is 1234. After changing it only this device stays logged in.")));
: t("The default PIN is 1234. After changing it only this device stays logged in.")),
S.isApp ? lockOption() : null);
}
// ------------------------------------------------------------------ custom logo (top left and browser icon)
@@ -2324,7 +2392,7 @@ function logoCard() {
h("div", { class: "grow" },
h("p", { class: "info" }, t("Your own logo top left (and as the browser icon). PNG, JPG, WebP or SVG, ideally square, at least 64×64 pixels, transparent background recommended. It is scaled to 128×128 pixels; other shapes are centred without distortion.")))),
h("div", { class: "actions" },
h("button", { class: "on", onclick: async () => {
h("button", { onclick: async () => {
try {
const r = await logoFromFile();
if (!r) return;
@@ -2336,6 +2404,60 @@ function logoCard() {
}
// Language per device (stored in the browser); the desktop app also tells the server, for its own dialogs
function djBrakeCard() {
// the app's own address only works on this computer: other devices come through remote access
const r = S.remote || {};
const reachable = !S.isApp || !!r.running;
const urls = (S.isApp ? r.urls || [] : [location.origin]).map(u => `${u}/djbrake`);
const box = h("input", { type: "checkbox", checked: !!S.djbrake, disabled: !reachable, onchange: async () => {
try { S.djbrake = (await api("PUT", "/api/djbrake", { enabled: box.checked })).enabled; render(); }
catch (e) { box.checked = !!S.djbrake; toast(t("Error: ") + trMsg(e.message)); }
} });
return h("div", { class: "card" }, h("h3", {}, "DJ Brake"),
h("p", { class: "info" }, t("A page for a tablet at the DJ booth: a big red light comes on when a limiter is working, so turning up more won't help.")),
h("label", { class: "chk" }, box, t("Share the page /djbrake")),
!reachable ? h("p", { class: "info djwarn" }, t("Only reachable while remote access is on.")) : null,
S.djbrake && reachable ? urls.map(url => h("div", { class: "row djurl" }, h("code", {}, url),
h("button", { class: "small", "data-view-ok": "", onclick: async () => {
try { await navigator.clipboard.writeText(url); toast(t("Address copied")); } catch { toast(url); }
} }, t("Copy")))) : null,
S.djbrake && reachable ? djLimiters() : null,
S.djbrake && reachable ? djHintOptions() : null,
S.djbrake && reachable ? h("p", { class: "info" }, t("Anyone in your network can open it without a PIN. It shows only the light and changes nothing.")) : null);
}
function djHintOptions() {
const save = async (key, on) => {
try {
const r = await api("PUT", "/api/djbrake", { [key]: on });
S.djHint = r.hint; S.djHintEn = r.hint_en; render();
} catch (e) { toast(t("Error: ") + trMsg(e.message)); render(); }
};
return h("div", { class: "djlim" },
h("label", { class: "chk" }, h("input", { type: "checkbox", checked: S.djHint, onchange: e => save("hint", e.target.checked) }),
t("Show a short note that the limiter is not the goal")),
S.djHint ? h("label", { class: "chk" }, h("input", { type: "checkbox", checked: S.djHintEn, onchange: e => save("hint_en", e.target.checked) }),
t("Note always in English")) : null);
}
function djLimiters() {
const devs = S.order.map(id => S.devices[id]).filter(d => d.state && !d.demo);
const toggle = async (id, i) => {
const cur = S.djIgnore[id] || [];
const ignore = { ...S.djIgnore, [id]: cur.includes(i) ? cur.filter(x => x !== i) : [...cur, i] };
try { S.djIgnore = (await api("PUT", "/api/djbrake", { ignore })).ignore; render(); }
catch (e) { toast(t("Error: ") + trMsg(e.message)); }
};
return h("div", { class: "djlim" }, h("b", {}, t("Leave out these limiters")),
h("p", { class: "info" }, t("All others count. Muted outputs never count.")),
devs.length ? devs.map(d => h("div", { class: "djdev" }, devs.length > 1 ? h("small", {}, d.name) : null,
h("div", { class: "djchs" }, chans(d, "out").map((c, i) => {
const out = (S.djIgnore[d.id] || []).includes(i);
return h("button", { class: "djch" + (out ? " out" : ""), "aria-pressed": String(out), onclick: () => toggle(d.id, i) },
chLabel("out", i), c.name ? h("small", {}, c.name) : null);
})))) : h("p", { class: "info" }, t("Connect a DSP to choose.")));
}
function langCard() {
const set = async lang => {
if (lang === LANG) return;
@@ -2395,7 +2517,7 @@ function viewSettings() {
["devices", t("Devices"), t("Several DSPs can be connected at the same time – pick one at the top. A DSP accepts only one connection: close the Thomann editor first."),
"wide", [...S.order.filter(id => !S.devices[id].demo).map(id => deviceForm(S.devices[id])), scanCard(), addDeviceCard()]],
["access", S.isApp ? t("Remote access") : t("Security"), S.isApp ? t("Let phones and tablets in your network control this computer – they log in with the PIN.") : t("Who may use this web interface."),
"wide", [S.isApp ? remoteCard() : null, pinCard()]],
"wide", [S.isApp ? remoteCard() : null, djBrakeCard(), pinCard()]],
["backup", t("Backup"), t("Save and restore the settings of this app."), "wide", [backupCard()]],
];
const nav = h("nav", { class: "setnav", "aria-label": t("Settings") }, sections.map(([id, title]) =>
@@ -2403,16 +2525,35 @@ function viewSettings() {
return h("div", { class: "setwrap" }, nav, sections.map(([id, title, desc, cls, cards]) =>
h("section", { class: "setsec", id: "set-" + id },
h("header", {}, h("h2", {}, title), h("p", {}, desc)),
h("div", { class: "setgrid " + cls }, cards.filter(Boolean)))));
h("div", { class: "setgrid " + cls }, cards.filter(Boolean)))),
h("div", { class: "disclaimer" }, svgIcon('<path d="M12 3l9.5 17h-19zM12 10v4M12 17.5v.01"/>'),
h("p", {}, h("b", {}, t("Not from Thomann.")), " ", t("This is an independent project, not connected to Thomann or t.racks, and much of it was written with AI. It comes without any guarantee: you use it at your own risk."))),
h("p", { class: "vkfoot" }, "VK-Audio"));
}
// ------------------------------------------------------------------ render
const H_SCROLL = ".mixer, .bands, .geq, .routing";
// first start: nothing added yet
function noDspView() {
return h("div", { class: "empty nodsp" }, svgIcon('<rect x="3" y="7" width="18" height="10" rx="2"/><path d="M7 12h.01M11 12h6"/>'),
h("b", {}, t("No DSP added yet")),
h("p", {}, t("Add your DSP over the network or USB. To look around first, switch on demo mode in the settings.")),
h("button", { class: "on", "data-view-ok": "", onclick: () => {
S.settings = true; S.addDev = true; render();
document.getElementById("set-devices")?.scrollIntoView({ block: "start" });
} }, t("Add a DSP")));
}
function render() {
if (S.busy) { S.dirty = true; return; }
if ($("#app").hidden) return;
if (!S.devices[S.cur]) S.cur = S.order[0] || null;
// locked with "only show dashboard": back to where it was after unlocking
if (dashOnly() && !testOn(S.devices[S.cur])) {
if (S.view !== "dash" || S.settings) { S.beforeLock = S.beforeLock || { view: S.view, settings: S.settings }; S.view = "dash"; S.settings = false; }
} else if (S.beforeLock) { S.view = S.beforeLock.view; S.settings = S.beforeLock.settings; S.beforeLock = null; }
document.body.classList.toggle("dashonly", dashOnly() && !testOn(S.devices[S.cur]));
if (testOn(S.devices[S.cur])) { S.view = "test"; S.settings = false; } // stays in the audio test until the analog input is back
// keep focus on a text field (e.g. while typing a device name) – re-rendering would steal it
const ae = document.activeElement;
@@ -2429,10 +2570,11 @@ function render() {
const d = dev();
const field = !S.settings && S.view === "soundfield"; // the room plan works without a connected DSP
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;
document.body.dataset.view = field ? "soundfield" : dash ? "dash" : S.settings ? "settings" : S.view;
if (field) content = viewSoundField();
else if (dash) content = viewDash();
else if (S.settings || !d) content = viewSettings();
else if (S.settings) content = viewSettings();
else if (!d) content = noDspView();
else if (d.status !== "online" || !d.state)
content = h("div", { class: "empty" }, h("div", { class: "spinner" + (["loading", "connecting"].includes(d.status) ? "" : " off") }),
d.status === "loading" ? t("Loading the configuration from the DSP…")
@@ -2440,7 +2582,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, fir: d.fir ? viewFir : viewMixer, limiter: viewLimiter, test: viewTest }[S.view] || viewMixer)(d);
else content = ({ mixer: viewMixer, channel: viewChannel, routing: viewRouting, link: viewLink, fir: d.fir ? viewFir : viewMixer, lab: S.isApp ? viewLab : 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);
@@ -2484,6 +2626,7 @@ new ResizeObserver(() => document.documentElement.style.setProperty("--sb", $("#
// 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;
const dashOnly = () => !!S.locked && !!S.lockDash;
function showGuard() {
const b = $("#btn-guard"), used = !S.isApp && S.guardUsed;
b.hidden = !used;
@@ -2565,6 +2708,7 @@ function connectEvents() {
if (ev.muteall) { S.muteAll = ev.muteall.active; showMuteAll(); }
if (ev.soundfield) S.sf = ev.soundfield;
if ("dashboard" in ev) S.dash = ev.dashboard && ev.dashboard.modules;
S.djbrake = !!ev.djbrake; S.djIgnore = ev.dj_ignore || {}; S.djHint = ev.dj_hint !== false; S.djHintEn = ev.dj_hint_en !== false;
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]));
@@ -2599,6 +2743,10 @@ function connectEvents() {
sfOnRemote(ev.data); break;
case "dashboard":
dashRemote(ev.data); break;
case "reset":
appWasReset(); break;
case "djbrake":
S.djbrake = ev.enabled; S.djIgnore = ev.ignore; S.djHint = ev.hint; S.djHintEn = ev.hint_en; if (S.settings && !S.busy) render(); break;
case "logo":
S.logo = ev.data; showLogo(); if (S.settings) render(); break;
case "muteall":
@@ -2623,6 +2771,9 @@ function connectEvents() {
case "lock":
if (S.isApp) { S.locked = ev.locked; showLock(); render(); }
break;
case "lockdash":
if (S.isApp) { S.lockDash = ev.enabled; render(); }
break;
case "meters":
updateMeters(ev); break;
case "limiter":
@@ -2712,6 +2863,7 @@ async function startApp() {
if (store.get("dsp.lang") === a.lang) return location.reload();
}
S.locked = !!a.locked;
S.lockDash = !!a.lock_dash;
S.guardUsed = !S.isApp && matchMedia("(max-width: 759px), (pointer: coarse)").matches;
S.guard = S.guardUsed;
showGuard();
+43 -28
View File
@@ -4,15 +4,13 @@
// 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;
// dragging modules around is no good on a touchscreen: there only their settings can be changed
const dashTouch = () => matchMedia("(pointer: coarse)").matches;
const dashBrowse = new Map(); // module id -> { kind, idx, band }
const dashMods = () => S.dash || (S.dash = DASH_DEFAULT());
const dashMods = () => S.dash || (S.dash = []);
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];
@@ -41,17 +39,23 @@ const dashChannels = d => [...chans(d, "in").map((_, i) => ["in", i]), ...chans(
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 (!s) { s = { kind: m.cfg.kind || "in", idx: m.cfg.idx || 0, band: 0, overlay: !!(m.cfg.overlays || []).length }; 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];
// arrows through the channels; the frequency response module has "Overlay" as one more entry, in front
function dashChannelNav(m, d, s, overlay = false) {
const all = [...(overlay ? [["overlay", 0]] : []), ...dashChannels(d)];
const at = all.findIndex(([k, i]) => (s.overlay ? k === "overlay" : k === s.kind && i === s.idx));
const go = dir => {
const [k, i] = all[(at + dir + all.length) % all.length];
s.overlay = k === "overlay";
if (!s.overlay) { s.kind = k; s.idx = i; }
s.band = 0; render();
};
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("span", { class: "dnavname" }, s.overlay ? h("b", {}, "Overlay") : [h("b", {}, chLabel(s.kind, s.idx)), " ", chans(d, s.kind)[s.idx].name]),
h("button", { class: "small", "data-view-ok": "", "aria-label": t("Next channel"), onclick: () => go(1) }, "›"));
}
@@ -85,7 +89,7 @@ const DASH_MODULES = {
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); } },
onclick: () => { if (dashOnly()) return; 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)));
@@ -95,8 +99,13 @@ const DASH_MODULES = {
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" }));
// limiter as one more segment on top; inputs keep the room so all scales line up
const meter = (k, i) => {
const el = ledMeter(d.id, k, i);
el.append(k === "out" ? limLed(d.id, i, "seg") : h("span", { class: "limled seg ph", "aria-hidden": "true" }));
return el;
};
const col = (k, i) => h("div", { class: "dm" + (chans(d, k)[i].mute ? " muted" : ""), title: chTitle(d, k, i), style: `grid-column:${i + 1}` }, meter(k, i));
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)));
@@ -126,12 +135,17 @@ const DASH_MODULES = {
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;
return i < chans(d, k).length ? { 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 }));
if (!shown.length) s.overlay = false;
const nav = dashChannelNav(m, d, s, shown.length > 0);
if (s.overlay) {
requestAnimationFrame(() => drawCurve(canvas, ch, -1, { mode: "mag", overlays: shown, overlaysOnly: true }));
return [nav, canvas, h("div", { class: "dlegend" }, shown.map(o => h("span", {}, h("i", { style: `background:${o.color}` }), chLabel(o.k, o.i))))];
}
requestAnimationFrame(() => drawCurve(canvas, ch, s.band, { mode: "mag", overlays: [] }));
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,
return [nav, canvas,
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" : ""}`)];
@@ -162,7 +176,7 @@ const DASH_MODULES = {
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)),
return h("div", { class: "drow" }, limLed(d.id, o, "txt"), 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)));
}));
@@ -230,7 +244,7 @@ async function dashSettings(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
// channels of the "Overlay" entry
const overlays = new Set(m.cfg.overlays || []);
const overlayBox = m.type === "curve" ? h("div", { class: "doverlays" }) : null;
const fillOverlays = () => {
@@ -245,7 +259,7 @@ async function dashSettings(m) {
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),
overlayBox ? h("div", { class: "full" }, h("div", { class: "sub" }, t("Channels shown together as “Overlay”")), overlayBox) : null),
actions: [{ label: t("Cancel") }, { label: t("Save"), primary: true, value: () => true }] });
if (!res) return;
m.cfg = { ...m.cfg, title: title.value.trim() };
@@ -361,15 +375,15 @@ function dashModule(m) {
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: () => {
dashTouch() ? null : 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()),
const head = h("h3", { title: dashEdit && !dashTouch() ? 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) {
if (dashEdit && !dashTouch()) {
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);
@@ -383,13 +397,14 @@ function dashModule(m) {
function viewDash() {
if (viewOnly()) dashEdit = false;
if (!dashDevs().length) return noDspView();
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."))),
viewOnly() ? null : h("button", { class: dashEdit ? "on" : "", onclick: () => { dashEdit = !dashEdit; render(); } }, dashEdit ? t("Done") : dashTouch() ? t("Widget settings") : t("Customise"))),
dashEdit && !dashTouch() ? dashPalette() : null,
mods.length ? h("div", { class: "dash" + (dashEdit && !dashTouch() ? " editing" : "") }, mods.map(dashModule))
: h("div", { class: "dash" + (dashEdit ? " editing" : "") }, h("div", { class: "dmod dblank", style: dashSizeStyle(12, 4) }, dashTouch() ? t("Nothing here yet – you can add modules on a computer.") : t("Nothing here yet – press “Customise” and add modules."))),
];
}
+87
View File
@@ -0,0 +1,87 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">
<meta name="theme-color" content="#000000">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>DJ Brake</title>
<style>
html { touch-action: manipulation; }
html, body { height: 100%; margin: 0; background: #050608; color: #fff; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; overflow: hidden; }
body { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5vmin; text-align: center; -webkit-user-select: none; user-select: none; }
/* on at once, off quickly: the server already holds it for a second after the limiter */
#wash, #halo, #core { transition: opacity .25s ease-out; opacity: 0; }
body.on #wash, body.on #halo, body.on #core { transition: opacity .09s ease-out; opacity: 1; }
#wash { position: fixed; inset: 0; background: radial-gradient(circle at 50% 46%, #6e0a0a 0%, #2a0505 42%, #050608 78%); }
#lamp { position: relative; width: 64vmin; height: 64vmin; display: grid; place-items: center; }
#halo, #core, #glass, #ring { position: absolute; inset: 0; border-radius: 50%; }
#glass { background: radial-gradient(circle at 50% 38%, #171a20, #0b0d11 70%); box-shadow: inset 0 0 0 1px #ffffff14; }
#core { background: radial-gradient(circle at 50% 36%, #ff6a5c 0%, #f4201c 46%, #b80c0f 100%); box-shadow: inset 0 0 0 1px #ffb3a8, inset 0 -3vmin 7vmin #5e000380; }
#halo { inset: -7vmin; background: radial-gradient(circle, #ff2a1f 44%, #ff2a1f00 70%); filter: blur(3vmin); }
#ring { border: .5vmin solid #ff5a4c; opacity: 0; pointer-events: none; }
#word { position: relative; font-size: 10.5vmin; font-weight: 800; letter-spacing: .03em; line-height: 1; color: #4b5260; transition: color .25s; }
#sub { position: relative; min-height: 1.3em; font-size: 4.4vmin; font-weight: 500; color: #8b93a1; transition: color .25s; }
#hint { position: relative; max-width: 88vw; font-size: 2.8vmin; color: #6b7280; transition: color .25s; }
body.on #word { color: #fff; transition: color .09s; }
body.on #sub { color: #ffd9d4; transition: color .09s; }
body.on #hint { color: #ffc9c4; transition: color .09s; }
/* while it lasts: slow breathing, one ring on each new hit, no hard flashing */
body.on #halo { animation: breathe 2.2s ease-in-out infinite; }
body.on #ring { animation: ripple .9s cubic-bezier(.2, .6, .3, 1); }
@keyframes breathe { 50% { transform: scale(.94); filter: blur(4.5vmin); } }
@keyframes ripple { from { transform: scale(1); opacity: .75; } to { transform: scale(1.32); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { body.on #halo, body.on #ring { animation: none; } }
</style>
</head>
<body>
<div id="wash"></div>
<div id="lamp">
<div id="halo"></div>
<div id="ring"></div>
<div id="glass"></div>
<div id="core"></div>
<div id="word">—</div>
</div>
<div id="sub"></div>
<div id="hint"></div>
<script>
// Red light for the DJ: comes on when a limiter of a connected DSP acts.
// On its own on purpose: this page needs no PIN and gets nothing but this one state from the server.
(function () {
var de = /^de/i.test(navigator.language || "");
var text = de
? { on: "LIMITER", more: "Mehr Gas bringt nichts", lost: "Keine Verbindung", none: "Kein Limiter überwacht" }
: { on: "LIMITER", more: "More gain won't help", lost: "No connection", none: "No limiter being watched" };
var word = document.getElementById("word"), sub = document.getElementById("sub"), hint = document.getElementById("hint");
var notes = { en: "The limiter is a safety net, not the target. Stay below it.", de: "Der Limiter ist die Sicherung, nicht das Ziel. Bleib darunter." };
document.documentElement.lang = de ? "de" : "en";
function show(on, main, small) {
document.body.className = on ? "on" : "";
word.textContent = main;
sub.textContent = small;
}
var es = new EventSource("/djbrake/state");
es.onmessage = function (e) {
var s = JSON.parse(e.data);
hint.textContent = !s.hint ? "" : s.hint === "auto" && de ? notes.de : notes.en;
if (s.on) show(true, text.on, text.more);
else if (s.ready) show(false, "OK", "");
else show(false, "—", text.none);
};
es.onerror = function () { show(false, "—", text.lost); };
// keep the screen on where the browser allows it
function awake() { if (navigator.wakeLock) navigator.wakeLock.request("screen").catch(function () {}); }
awake();
document.addEventListener("visibilitychange", function () { if (!document.hidden) awake(); });
})();
</script>
</body>
</html>
Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

+96
View File
@@ -0,0 +1,96 @@
"use strict";
// Short handbooks behind the book symbol: what it is for, then real cases step by step.
const DOC_LAB = () => ({
title: t("Sound Lab handbook"),
parts: [
{ n: t("Overview"), h: t("What it is for"), fig: ["lab-take", t("A measurement taken over from REW: the orange curve is the prediction, the table lists each filter before anything reaches the DSP.")], p: t("REW (Room EQ Wizard, free) measures your speakers in the room. Sound Lab brings its filters onto a channel of the DSP and sends the channel's EQ back to REW, so you don't type values by hand.") },
{ n: t("Setting up"), h: t("Setting up"), steps: [
t("Install REW on the computer running this app and connect a measuring microphone."),
t("In REW: Preferences → API → start the API, and tick that it starts with REW."),
t("Open Sound Lab and press “Check”. The dot turns green and shows the REW version."),
], tip: t("REW's API only answers on its own computer, so Sound Lab is part of the Windows and macOS apps only.") },
{ n: t("Correcting"), h: t("Example: correcting a top in a hall"), steps: [
t("Export a preset first (File… → Export), so you can go back."),
t("Mute everything except the speaker you are measuring and set a low level. Put the microphone at ear height in the audience area."),
t("Measure in REW, open its EQ window, choose the equaliser “Generic” and let it calculate filters with “Match response to target”."),
t("In Sound Lab pick the channel of this speaker, e.g. Out 1, choose the measurement and press “Take filters”."),
t("Check the orange curve and the table. Outputs have 9 bands and inputs 8; anything above that is left out and shown in the note."),
t("Press “Apply” and measure again. The new measurement should now look like the prediction."),
], tip: t("Prefer cutting peaks to filling dips. A dip caused by the room can't be filled by more power, and big boosts only use up headroom.") },
{ n: t("Comparing"), h: t("Example: checking the channel against a measurement"), steps: [
t("Pick the channel and press “Send curve as a new measurement”."),
t("In REW it appears in the measurement list. Show it in “All SPL” together with your real measurement."),
t("So you see at a glance whether crossover and EQ on the DSP do what the measurement needs."),
] },
{ n: t("Trying first"), h: t("Example: trying changes in REW first"), steps: [
t("Choose a measurement and press “Send filters to the chosen measurement”. This replaces the filters of that measurement in REW."),
t("In REW's EQ window change the filters and watch the predicted result. Nothing changes on the DSP."),
t("If you like it, press “Take filters” in Sound Lab, check and apply."),
] },
{ n: t("Without the API"), h: t("Without the API"), steps: [
t("In REW's EQ window: File → Export → Filter settings as text."),
t("In Sound Lab press “Load REW filter file…”, check and apply."),
] },
],
});
const DOC_SF = () => ({
title: t("SoundField handbook"),
parts: [
{ n: t("Overview"), h: t("What it is for"), fig: ["sf-plan", t("The “Level” map: green is around the median of the audience area, red is 12 dB below it.")], p: t("SoundField is a top view of the room for planning before you set up: where speakers go, how evenly the room is covered, and which delays they need. It calculates a free field without reflections, so it is a planning aid, not a measurement.") },
{ n: t("Planning"), h: t("Example: a band in a hall of 20 × 30 m"), steps: [
t("Under “Room” enter width 20 and depth 30, stage 8 × 4 m, the temperature and the ear height of the audience."),
t("Press “Quick start” under “Suggestions” for a stereo pair and a sub, or “Stacks” for a sub left and right with the top on a pole."),
t("Drag the reference cross to your mixing position. Mains and subs are aligned in time at this point."),
t("Click a speaker: set its type, height and coverage, drag it into place and aim it with the white handle."),
t("Look at the “Level” map and the spread below the plan. Aim for as many listeners as possible within ±3 dB."),
t("Follow “Suggestions”: they offer aiming, raising the mains, or delay speakers when the back of the room falls off."),
] },
{ n: t("The map"), h: t("Reading the map"), list: [
t("“Level”: how loud each spot of the room is, compared with the median of the audience area."),
t("“Sub”: where the subs add up and where they cancel at the chosen frequency."),
t("“Timing”: marked areas mean a delay arrives before the mains or more than 30 ms late."),
] },
{ n: t("Back of the hall"), h: t("Example: the back of the hall is too quiet"), steps: [
t("Press “Add delay line” in the suggestion, or add “+ Delay” and drag it to about two thirds of the room."),
t("Drag its dashed target point to the middle of the area it should cover."),
t("Switch the map to “Timing”: marked areas mean the delay arrives before the mains or more than 30 ms late."),
t("The offset under “Delays” keeps the mains arriving first, so the sound still seems to come from the stage. 5 ms is a good start."),
] },
{ n: t("Subs"), h: t("Example: subs, and why two can be worse than one"), steps: [
t("Switch the map to “Sub” and choose a frequency such as 80 Hz."),
t("With subs left and right you see lanes of cancellation through the room."),
t("Try the “Centre cluster” suggestion and compare: the lanes disappear."),
] },
{ n: t("To the DSP"), h: t("Taking the delays to the DSP"), fig: ["sf-delays", t("The “Delays” table: distance and delay per speaker, next to what is set on the DSP now.")], steps: [
t("Export a preset first (File… → Export)."),
t("Select a speaker and tick which DSP outputs feed it."),
t("In the “Delays” table press “Apply” for one speaker, or “Apply all”. The column “Now on DSP” shows what is set."),
], tip: t("Check the result by ear or with a measurement: temperature, reflections and real speakers differ from the model.") },
],
});
// “Names of buttons” in the texts stand out; the quotes go, the German ones too
const docText = s => s.split(/([“„][^”“]+[”“])/).map(x => /^[“„]/.test(x) ? h("b", { class: "docui" }, x.slice(1, -1)) : x);
function docDialog(doc) {
const d = doc();
const body = h("div", { class: "docbody" });
const secs = d.parts.map(part => h("section", {}, h("h4", {}, part.h),
part.p ? h("p", {}, docText(part.p)) : null,
part.fig ? h("figure", {}, h("img", { src: `docimg/${part.fig[0]}.${LANG}.jpg`, alt: "" }), h("figcaption", {}, docText(part.fig[1]))) : null,
part.steps ? h("ol", {}, part.steps.map(s => h("li", {}, docText(s)))) : null,
part.list ? h("ul", {}, part.list.map(s => h("li", {}, docText(s)))) : null,
part.tip ? h("p", { class: "doctip" }, docText(part.tip)) : null));
body.append(h("nav", { class: "docnav" }, d.parts.map((part, i) => h("button", { class: "chip", onclick: () => {
body.scrollTo({ top: secs[i].offsetTop - body.offsetTop - 48, behavior: "smooth" });
} }, part.n))), ...secs);
return modal({ title: d.title,
body,
actions: [{ label: t("Close"), primary: true, value: () => true }] });
}
const docButton = doc => h("button", { class: "icon docbtn", "data-view-ok": "", title: t("Handbook"), "aria-label": t("Handbook"), onclick: () => docDialog(doc) },
svgIcon('<path d="M5 4.5A1.5 1.5 0 0 1 6.5 3H19v15H6.5A1.5 1.5 0 0 0 5 19.5z"/><path d="M5 19.5A1.5 1.5 0 0 0 6.5 21H19v-3M9 7.5h6M9 11h6"/>'));
+142 -1
View File
@@ -574,13 +574,154 @@ const DE = {
"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",
"Channels shown together as “Overlay”": "Kanäle, die zusammen als „Overlay“ angezeigt werden",
"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",
"No DSP added yet": "Noch kein DSP angelegt",
"Add your DSP over the network or USB. To look around first, switch on demo mode in the settings.": "Lege deinen DSP über Netzwerk oder USB an. Zum Ausprobieren gibt es in den Einstellungen den Demo-Modus.",
"Not from Thomann.": "Nicht von Thomann.",
"This is an independent project, not connected to Thomann or t.racks, and much of it was written with AI. It comes without any guarantee: you use it at your own risk.": "Das ist ein unabhängiges Projekt ohne Verbindung zu Thomann oder t.racks, und vieles daran wurde mit KI geschrieben. Es gibt keine Garantie: Die Nutzung erfolgt auf eigene Gefahr.",
"Room EQ Wizard: take filters or send this EQ": "Room EQ Wizard: Filter übernehmen oder diesen EQ senden",
"gain limited to ±12 dB": "Gain auf ±12 dB begrenzt",
"frequency limited to 20 Hz … 20 kHz": "Frequenz auf 20 Hz … 20 kHz begrenzt",
"Looking for REW…": "Suche REW…",
"Measurement": "Messung",
"{cut} filters left out: this channel has {n} bands": "{cut} Filter weggelassen: Dieser Kanal hat {n} Bänder",
"{n} filters skipped: type not available on the DSP": "{n} Filter übersprungen: Typ gibt es am DSP nicht",
"No usable filters found.": "Keine verwendbaren Filter gefunden.",
"Apply to {ch}": "Auf {ch} übernehmen",
"{n} filters applied to {ch}": "{n} Filter auf {ch} übernommen",
"No REW filters found in this file.": "In dieser Datei sind keine REW-Filter.",
"Filters sent to “{m}”": "Filter an „{m}“ gesendet",
"Curve sent to REW as a new measurement": "Kurve als neue Messung an REW gesendet",
"Take filters": "Filter holen",
"Send filters to this measurement": "Filter an diese Messung senden",
"Send curve as a new measurement": "Kurve als neue Messung senden",
"Load REW filter file…": "REW-Filterdatei laden…",
"Also works without a connection: in REW, File → Export → Filter settings as text": "Geht auch ohne Verbindung: in REW Datei → Export → Filter settings as text",
"From this channel to REW": "Von diesem Kanal an REW",
"REW – {ch}": "REW – {ch}",
"Connected to REW {v}. {n} measurements.": "Mit REW {v} verbunden. {n} Messungen.",
"No measurements in REW": "Keine Messungen in REW",
"REW can't be reached. Start REW on the computer running this app and switch on its API (Preferences → API). The filter file works anyway.": "REW ist nicht erreichbar. Starte REW auf dem Computer, auf dem diese App läuft, und schalte die API ein (Preferences → API). Die Filterdatei geht trotzdem.",
"REW can't be reached": "REW ist nicht erreichbar",
"No measurement chosen": "Keine Messung gewählt",
"No curve to send": "Keine Kurve zum Senden",
"Open this channel in Sound Lab (REW)": "Diesen Kanal im Sound Lab öffnen (REW)",
"Discard": "Verwerfen",
"REW {v} · {n} measurements": "REW {v} · {n} Messungen",
"REW not connected": "REW nicht verbunden",
"Check": "Prüfen",
"now": "jetzt",
"after applying": "nach dem Übernehmen",
"From REW to this channel": "Von REW auf diesen Kanal",
"As a measurement you can compare the channel's curve with real measurements in REW. Filters on a measurement let REW predict the result.": "Als Messung kannst du die Kurve des Kanals in REW mit echten Messungen vergleichen. Filter auf einer Messung lassen REW das Ergebnis vorhersagen.",
"Send filters to the chosen measurement": "Filter an die gewählte Messung senden",
"Handbook": "Handbuch",
"Sound Lab handbook": "Sound-Lab-Handbuch",
"SoundField handbook": "SoundField-Handbuch",
"What it is for": "Wofür das gut ist",
"REW (Room EQ Wizard, free) measures your speakers in the room. Sound Lab brings its filters onto a channel of the DSP and sends the channel's EQ back to REW, so you don't type values by hand.": "REW (Room EQ Wizard, kostenlos) misst deine Lautsprecher im Raum. Das Sound Lab bringt dessen Filter auf einen Kanal des DSP und schickt den EQ des Kanals zurück an REW, sodass du keine Werte abtippen musst.",
"Setting up": "Einrichten",
"Install REW on the computer running this app and connect a measuring microphone.": "REW auf dem Computer installieren, auf dem diese App läuft, und ein Messmikrofon anschließen.",
"In REW: Preferences → API → start the API, and tick that it starts with REW.": "In REW: Preferences → API → die API starten und anhaken, dass sie mit REW startet.",
"Open Sound Lab and press “Check”. The dot turns green and shows the REW version.": "Das Sound Lab öffnen und „Prüfen“ drücken. Der Punkt wird grün und zeigt die REW-Version.",
"REW's API only answers on its own computer, so Sound Lab is part of the Windows and macOS apps only.": "Die API von REW antwortet nur auf dem eigenen Computer, darum gibt es das Sound Lab nur in den Apps für Windows und macOS.",
"Example: correcting a top in a hall": "Beispiel: ein Top in einer Halle korrigieren",
"Export a preset first (File… → Export), so you can go back.": "Zuerst ein Preset exportieren (Datei… → Export), damit du zurück kannst.",
"Mute everything except the speaker you are measuring and set a low level. Put the microphone at ear height in the audience area.": "Alles außer dem gemessenen Lautsprecher stummschalten und einen niedrigen Pegel einstellen. Das Mikrofon auf Ohrhöhe in den Publikumsbereich stellen.",
"Measure in REW, open its EQ window, choose the equaliser “Generic” and let it calculate filters with “Match response to target”.": "In REW messen, das EQ-Fenster öffnen, den Equalizer „Generic“ wählen und mit „Match response to target“ Filter berechnen lassen.",
"In Sound Lab pick the channel of this speaker, e.g. Out 1, choose the measurement and press “Take filters”.": "Im Sound Lab den Kanal dieses Lautsprechers wählen, z. B. Out 1, die Messung auswählen und „Filter holen“ drücken.",
"Check the orange curve and the table. Outputs have 9 bands and inputs 8; anything above that is left out and shown in the note.": "Die orange Kurve und die Tabelle prüfen. Ausgänge haben 9 Bänder, Eingänge 8; was darüber liegt, wird weggelassen und im Hinweis genannt.",
"Press “Apply” and measure again. The new measurement should now look like the prediction.": "„Übernehmen“ drücken und neu messen. Die neue Messung sollte jetzt wie die Vorhersage aussehen.",
"Example: checking the channel against a measurement": "Beispiel: den Kanal mit einer Messung vergleichen",
"Pick the channel and press “Send curve as a new measurement”.": "Den Kanal wählen und „Kurve als neue Messung senden“ drücken.",
"In REW it appears in the measurement list. Show it in “All SPL” together with your real measurement.": "In REW erscheint sie in der Messungsliste. Zeige sie in „All SPL“ zusammen mit deiner echten Messung an.",
"So you see at a glance whether crossover and EQ on the DSP do what the measurement needs.": "So siehst du auf einen Blick, ob Weiche und EQ am DSP das tun, was die Messung braucht.",
"Example: trying changes in REW first": "Beispiel: Änderungen zuerst in REW ausprobieren",
"Choose a measurement and press “Send filters to the chosen measurement”. This replaces the filters of that measurement in REW.": "Eine Messung wählen und „Filter an die gewählte Messung senden“ drücken. Das ersetzt die Filter dieser Messung in REW.",
"In REW's EQ window change the filters and watch the predicted result. Nothing changes on the DSP.": "Im EQ-Fenster von REW die Filter ändern und die Vorhersage beobachten. Am DSP ändert sich dabei nichts.",
"If you like it, press “Take filters” in Sound Lab, check and apply.": "Wenn es passt, im Sound Lab „Filter holen“ drücken, prüfen und übernehmen.",
"Without the API": "Ohne die API",
"In REW's EQ window: File → Export → Filter settings as text.": "Im EQ-Fenster von REW: File → Export → Filter settings as text.",
"In Sound Lab press “Load REW filter file…”, check and apply.": "Im Sound Lab „REW-Filterdatei laden…“ drücken, prüfen und übernehmen.",
"SoundField is a top view of the room for planning before you set up: where speakers go, how evenly the room is covered, and which delays they need. It calculates a free field without reflections, so it is a planning aid, not a measurement.": "SoundField ist eine Draufsicht auf den Raum zum Planen vor dem Aufbau: wo die Lautsprecher hinkommen, wie gleichmäßig der Raum abgedeckt ist und welche Delays sie brauchen. Es rechnet im Freifeld ohne Reflexionen, ist also eine Planungshilfe und keine Messung.",
"Example: a band in a hall of 20 × 30 m": "Beispiel: eine Band in einer Halle mit 20 × 30 m",
"Under “Room” enter width 20 and depth 30, stage 8 × 4 m, the temperature and the ear height of the audience.": "Unter „Raum“ Breite 20 und Tiefe 30 eintragen, Bühne 8 × 4 m, die Temperatur und die Ohrhöhe des Publikums.",
"Press “Quick start” under “Suggestions” for a stereo pair and a sub, or “Stacks” for a sub left and right with the top on a pole.": "Unter „Vorschläge“ „Schnellstart“ drücken für ein Stereopaar und einen Sub, oder „Stacks“ für je einen Sub links und rechts mit dem Top auf der Distanzstange.",
"Drag the reference cross to your mixing position. Mains and subs are aligned in time at this point.": "Das Referenzkreuz auf deinen Mischplatz ziehen. Mains und Subs werden an diesem Punkt zeitlich ausgerichtet.",
"Click a speaker: set its type, height and coverage, drag it into place and aim it with the white handle.": "Einen Lautsprecher anklicken: Typ, Höhe und Abstrahlwinkel einstellen, an seinen Platz ziehen und mit dem weißen Griff ausrichten.",
"Look at the “Level” map and the spread below the plan. Aim for as many listeners as possible within ±3 dB.": "Die Karte „Pegel“ und die Streuung unter dem Plan ansehen. Ziel: möglichst viele Zuhörer innerhalb von ±3 dB.",
"Follow “Suggestions”: they offer aiming, raising the mains, or delay speakers when the back of the room falls off.": "Den „Vorschlägen“ folgen: Sie bieten Ausrichten, Höherstellen der Mains oder Delay-Lautsprecher an, wenn es hinten zu leise wird.",
"Example: the back of the hall is too quiet": "Beispiel: Hinten in der Halle ist es zu leise",
"Press “Add delay line” in the suggestion, or add “+ Delay” and drag it to about two thirds of the room.": "Im Vorschlag „Delay-Linie hinzufügen“ drücken, oder „+ Delay“ hinzufügen und auf etwa zwei Drittel des Raums ziehen.",
"Drag its dashed target point to the middle of the area it should cover.": "Seinen gestrichelten Zielpunkt in die Mitte des Bereichs ziehen, den er abdecken soll.",
"Switch the map to “Timing”: marked areas mean the delay arrives before the mains or more than 30 ms late.": "Die Karte auf „Timing“ stellen: Markierte Bereiche bedeuten, dass das Delay vor den Mains oder über 30 ms zu spät ankommt.",
"The offset under “Delays” keeps the mains arriving first, so the sound still seems to come from the stage. 5 ms is a good start.": "Der Offset unter „Delays“ sorgt dafür, dass die Mains zuerst ankommen und der Klang weiter von der Bühne zu kommen scheint. 5 ms sind ein guter Start.",
"Example: subs, and why two can be worse than one": "Beispiel: Subs, und warum zwei schlechter sein können als einer",
"Switch the map to “Sub” and choose a frequency such as 80 Hz.": "Die Karte auf „Sub“ stellen und eine Frequenz wählen, etwa 80 Hz.",
"With subs left and right you see lanes of cancellation through the room.": "Mit Subs links und rechts siehst du Auslöschungsgassen durch den Raum.",
"Try the “Centre cluster” suggestion and compare: the lanes disappear.": "Den Vorschlag „Mittig bündeln“ ausprobieren und vergleichen: Die Gassen verschwinden.",
"Taking the delays to the DSP": "Die Delays auf den DSP bringen",
"Export a preset first (File… → Export).": "Zuerst ein Preset exportieren (Datei… → Export).",
"Select a speaker and tick which DSP outputs feed it.": "Einen Lautsprecher wählen und anhaken, welche DSP-Ausgänge ihn speisen.",
"In the “Delays” table press “Apply” for one speaker, or “Apply all”. The column “Now on DSP” shows what is set.": "In der Tabelle „Delays“ für einen Lautsprecher „Übernehmen“ drücken, oder „Alle übernehmen“. Die Spalte „Jetzt im DSP“ zeigt, was gesetzt ist.",
"Check the result by ear or with a measurement: temperature, reflections and real speakers differ from the model.": "Das Ergebnis mit dem Ohr oder per Messung prüfen: Temperatur, Reflexionen und echte Lautsprecher weichen vom Modell ab.",
"Only show dashboard while locked": "Während der Sperre nur das Dashboard zeigen",
"With the lock on, this window then shows just your dashboard, until it is unlocked with the PIN.": "Bei aktiver Sperre zeigt dieses Fenster dann nur dein Dashboard, bis es mit der PIN entsperrt wird.",
"A page for a tablet at the DJ booth: a big red light comes on when a limiter is working, so turning up more won't help.": "Eine Seite für ein Tablet am DJ-Pult: Ein großes rotes Licht geht an, wenn ein Limiter arbeitet, mehr Gas also nichts mehr bringt.",
"Share the page /djbrake": "Seite /djbrake freigeben",
"Address copied": "Adresse kopiert",
"Only reachable while remote access is on.": "Nur erreichbar, solange der Fernzugriff an ist.",
"Connect a DSP to choose.": "Verbinde einen DSP, um auszuwählen.",
"Show a short note that the limiter is not the goal": "Kurzen Hinweis anzeigen, dass der Limiter nicht das Ziel ist",
"Note always in English": "Hinweis immer auf Englisch",
"Overview": "Überblick",
"Correcting": "Korrigieren",
"Comparing": "Vergleichen",
"Trying first": "Erst ausprobieren",
"Planning": "Planen",
"The map": "Die Karte",
"Reading the map": "Die Karte lesen",
"Back of the hall": "Hinten in der Halle",
"Subs": "Subs",
"To the DSP": "Auf den DSP",
"A measurement taken over from REW: the orange curve is the prediction, the table lists each filter before anything reaches the DSP.": "Eine aus REW übernommene Messung: Die orange Kurve ist die Vorhersage, die Tabelle zeigt jeden Filter, bevor etwas auf den DSP kommt.",
"Prefer cutting peaks to filling dips. A dip caused by the room can't be filled by more power, and big boosts only use up headroom.": "Senke lieber Spitzen ab, statt Löcher aufzufüllen. Ein Loch durch den Raum lässt sich mit mehr Leistung nicht füllen, und große Anhebungen kosten nur Headroom.",
"The “Level” map: green is around the median of the audience area, red is 12 dB below it.": "Die Karte „Pegel“: Grün liegt um den Median der Publikumsfläche, Rot 12 dB darunter.",
"“Level”: how loud each spot of the room is, compared with the median of the audience area.": "„Pegel“: wie laut jede Stelle im Raum ist, verglichen mit dem Median der Publikumsfläche.",
"“Sub”: where the subs add up and where they cancel at the chosen frequency.": "„Sub“: wo sich die Subs bei der gewählten Frequenz addieren und wo sie sich auslöschen.",
"“Timing”: marked areas mean a delay arrives before the mains or more than 30 ms late.": "„Timing“: Markierte Flächen bedeuten, dass ein Delay vor den Mains oder mehr als 30 ms zu spät ankommt.",
"The “Delays” table: distance and delay per speaker, next to what is set on the DSP now.": "Die Tabelle „Delays“: Abstand und Delay pro Lautsprecher, daneben der aktuelle Wert auf dem DSP.",
"Leave out these limiters": "Diese Limiter ausnehmen",
"All others count. Muted outputs never count.": "Alle anderen zählen. Stummgeschaltete Ausgänge zählen nie.",
"Colours and group names belong to the loaded preset (by its name) and come back when you load it.": "Farben und Gruppennamen gehören zum geladenen Preset (über seinen Namen) und kommen beim Laden wieder.",
"Widget settings": "Widget-Einstellungen",
"Reset all app settings…": "Alle App-Einstellungen zurücksetzen…",
"Reset all app settings?": "Alle App-Einstellungen zurücksetzen?",
"{names} still has the lowered levels of an interrupted audio test. The app can no longer undo that after the reset.": "{names} hat noch die abgesenkten Pegel eines abgebrochenen Audiotests. Nach dem Zurücksetzen kann die App das nicht mehr rückgängig machen.",
"To confirm, type these letters:": "Zum Bestätigen diese Buchstaben eingeben:",
"Letters": "Buchstaben",
"Nothing here yet – you can add modules on a computer.": "Noch nichts da – Module kannst du am Computer hinzufügen.",
"End the audio test first: the DSP would stay at the lowered level": "Beende zuerst den Audiotest: Der DSP würde sonst auf dem abgesenkten Pegel bleiben",
"Release mute all first: the DSPs would stay muted": "Hebe zuerst „Alle stumm“ auf: Die DSPs würden sonst stumm bleiben",
"All DSPs are disconnected first, then the app starts fresh.": "Zuerst werden alle DSPs getrennt, dann startet die App frisch.",
"Removed from the app": "Wird aus der App gelöscht",
"DSP list": "DSP-Liste",
"Colours and group names": "Farben und Gruppennamen",
"Amplifiers and SoundField plan": "Verstärker und SoundField-Plan",
"Dashboard and DJ Brake": "Dashboard und DJ Brake",
"Remote access and language": "Fernzugriff und Sprache",
"PIN, back to 1234": "PIN, zurück auf 1234",
"Stays as it is": "Bleibt, wie es ist",
"All settings in the DSPs": "Alle Einstellungen in den DSPs",
"Presets in the DSPs": "Presets in den DSPs",
"A copy of the old app settings": "Eine Kopie der alten App-Einstellungen",
"Anyone in your network can open it without a PIN. It shows only the light and changes nothing.": "Jeder in deinem Netzwerk kann sie ohne PIN öffnen. Sie zeigt nur das Licht und ändert nichts.",
};
const DE_PATTERNS = [
+26 -1
View File
@@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover">
<meta name="theme-color" content="#0b0c0f">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
@@ -12,6 +12,28 @@
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='6' fill='%23111418'/%3E%3Cpath d='M7 22V10M13 22V6M19 22V14M25 22V9' stroke='%2338bdf8' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E">
</head>
<body>
<script>
// no zoom on phones and tablets: it breaks the faders. Safari ignores the viewport tag for this
["gesturestart", "gesturechange", "gestureend"].forEach(function (t) { document.addEventListener(t, function (e) { e.preventDefault(); }); });
document.addEventListener("touchmove", function (e) { if (e.touches.length > 1) e.preventDefault(); }, { passive: false });
</script>
<div id="splash" aria-hidden="true">
<svg viewBox="0 0 32 32" width="72" height="72"><path d="M7 22V10"/><path d="M13 22V6"/><path d="M19 22V14"/><path d="M25 22V9"/></svg>
<b>DSP Control</b><small>VK-Audio</small>
</div>
<script>
// start animation of the desktop apps: only their login arrives with this parameter, a reload doesn't.
// The language comes along: on the app's new port the browser storage is empty, and correcting it later needs a reload
(function () {
var el = document.getElementById("splash");
var m = /^\?start=app&lang=(en|de)$/.exec(location.search);
if (!m) return el.remove();
try { localStorage.setItem("dsp.lang", m[1]); } catch (e) { /* private mode */ }
history.replaceState(null, "", "/");
el.classList.add("show");
setTimeout(function () { el.remove(); }, 1500);
})();
</script>
<div id="login" hidden></div>
<div id="app" hidden>
<header id="top">
@@ -28,6 +50,7 @@
<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="lab" hidden><svg viewBox="0 0 24 24"><path d="M9.5 3h5M10.5 3v6.5L5 19a1.3 1.3 0 0 0 1.1 2h11.8a1.3 1.3 0 0 0 1.1-2l-5.5-9.5V3"/><path d="M7.5 15h9"/></svg><span>Sound Lab</span><span class="short">Lab</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>
@@ -46,5 +69,7 @@
<script src="/app.js"></script>
<script src="/soundfield.js"></script>
<script src="/dashboard.js"></script>
<script src="/docs.js"></script>
<script src="/rew.js"></script>
</body>
</html>
+157
View File
@@ -0,0 +1,157 @@
"use strict";
// Sound Lab: working together with REW (Room EQ Wizard). Take filters from a measurement or a filter file, compare them
// with the channel before applying, send a channel's EQ back. Desktop apps only: REW's API only answers on the computer
// it runs on, so the server inside the app talks to it (see rew_call).
const REW_IN = { PK: 0, PEAK: 0, LS: 1, LSC: 1, LSQ: 1, HS: 2, HSC: 2, HSQ: 2, HP1: 3, HP: 4, HPQ: 4, LP1: 5, LP: 6, LPQ: 6, AP: 8 };
const REW_OUT = ["PK", "LS", "HS", "HP1", "HP", "LP1", "LP", "AP", "AP"];
const lab = { dev: null, sel: { kind: "out", idx: 0 }, rows: null, from: "", rew: null, measId: "", checked: false };
const num2 = s => Number(String(s).replace(",", "."));
// "Filter 1: ON PK Fc 100.0 Hz Gain -3.0 dB Q 2.00" from REW's filter settings text
function rewParseText(text) {
const out = [];
for (const line of text.split(/\r?\n/)) {
const m = /^\s*Filter\s+(\d+)\s*:\s*(ON|OFF)\s+(\S+)(.*)$/i.exec(line);
if (!m || /^none$/i.test(m[3])) continue;
const rest = m[4];
const fc = /Fc\s*([\d.,]+)\s*(k?)Hz/i.exec(rest), gain = /Gain\s*([-+\d.,]+)\s*dB/i.exec(rest), q = /\bQ\s*([\d.,]+)/i.exec(rest);
out.push({ type: m[3].toUpperCase(), enabled: m[2].toUpperCase() === "ON",
frequency: fc ? num2(fc[1]) * (fc[2] ? 1000 : 1) : 0, gaindB: gain ? num2(gain[1]) : 0, q: q ? num2(q[1]) : 0 });
}
return out;
}
const rewNearestQ = q => Q_TABLE.reduce((best, v, i) => (Math.abs(Math.log(v / q)) < Math.abs(Math.log(Q_TABLE[best] / q)) ? i : best), 0);
// REW filter -> band of the DSP, with a note where the DSP can't take it exactly
function rewToBand(f) {
if (/^none$/i.test(String(f.type || "None"))) return null;
const type = REW_IN[String(f.type).toUpperCase().replace(/\s/g, "")];
if (type === undefined) return { unsupported: true };
const gain = clamp(Math.round(120 + (f.gaindB || 0) * 10), 0, 240), q = f.q > 0 ? rewNearestQ(f.q) : 32;
const notes = [];
if (Math.abs(f.gaindB || 0) > 12) notes.push(t("gain limited to ±12 dB"));
if (f.frequency < 20 || f.frequency > 20000) notes.push(t("frequency limited to 20 Hz … 20 kHz"));
return { band: { type, freq: hzFreq(f.frequency), gain, q, bypass: f.enabled === false }, notes };
}
function rewFromBand(b, i) {
return { index: i + 1, type: REW_OUT[b.type], enabled: !b.bypass, isAuto: false, frequency: +freqHz(b.freq).toFixed(1),
gaindB: hasGain(b.type) ? eqDb(b.gain) : 0, q: Q_TABLE[b.q] };
}
function rewCurve(d, kind, idx) {
const ch = chans(d, kind)[idx], ppo = 96, n = Math.floor(Math.log2(1000) * ppo) + 1, magnitude = [], phase = [];
for (let i = 0; i < n; i++) {
const hh = channelH(ch, 20 * 2 ** (i / ppo));
magnitude.push(+cdb(hh).toFixed(3));
phase.push(+cdeg(hh).toFixed(2));
}
return { identifier: `${d.name} ${chLabel(kind, idx)}`.slice(0, 60), startFreq: 20, ppo, magnitude, phase };
}
async function labCheck() {
try {
const st = await api("GET", "/api/rew/status"), meas = await api("GET", "/api/rew/measurements");
lab.rew = { version: st.version, meas };
if (!meas.some(m => m.id === lab.measId)) lab.measId = meas[0] ? meas[0].id : "";
} catch { lab.rew = null; lab.measId = ""; }
lab.checked = true;
if (S.view === "lab" && !S.settings) render();
}
function openLab(kind, idx) {
lab.sel = { kind, idx }; lab.rows = null;
S.view = "lab"; store.set("dsp.view", "lab"); render(); window.scrollTo(0, 0);
}
function labTake(filters, from) { lab.rows = filters.map(rewToBand).filter(Boolean); lab.from = from; render(); }
async function labFromFile() {
let f;
try { f = await openFile(".txt,text/plain"); } catch (e) { return toast(trMsg(e.message)); }
if (!f) return;
const list = rewParseText(atob(f.b64));
if (!list.length) return toast(t("No REW filters found in this file."));
labTake(list, f.name);
}
function viewLab(d) {
if (lab.dev !== d.id) { lab.dev = d.id; lab.rows = null; lab.sel = { kind: "out", idx: 0 }; }
if (lab.sel.idx >= chans(d, lab.sel.kind).length) lab.sel = { kind: "out", idx: 0 };
if (!lab.checked) { lab.checked = true; labCheck(); }
const { kind, idx } = lab.sel, ch = chans(d, kind)[idx], name = chTitle(d, kind, idx), n = ch.peq.length;
const measName = () => (lab.rew.meas.find(m => m.id === lab.measId) || {}).title || "";
const chip = (k, i) => h("button", { class: "firch" + (k === kind && i === idx ? " on" : "") + (chans(d, k)[i].peq.some(b => !b.bypass && b.gain !== 120) ? " used" : ""), "data-view-ok": "",
onclick: () => { lab.sel = { kind: k, idx: i }; lab.rows = null; render(); } },
h("b", {}, chLabel(k, i)), h("small", {}, chans(d, k)[i].name || " "));
// proposal from REW: bands that fit, what doesn't
const usable = (lab.rows || []).filter(r => r.band), kept = usable.slice(0, n), bands = kept.map(r => r.band);
const skipped = (lab.rows || []).length - usable.length, cut = usable.length - kept.length;
const proposed = lab.rows && kept.length ? { ...ch, peq: ch.peq.map((old, i) => bands[i] || { ...old, gain: 120, bypass: false }) } : null;
const canvas = h("canvas", { class: "labcurve" });
requestAnimationFrame(() => drawCurve(canvas, ch, -1, { mode: "mag", overlays: proposed ? [{ ch: proposed, color: "#f59e0b" }] : [] }));
const apply = () => {
proposed.peq.forEach((b, i) => setParam(kind, idx, `peq.${i}`, b));
toast(t("{n} filters applied to {ch}", { n: bands.length, ch: name }));
lab.rows = null; render();
};
const warn = [...new Set(kept.flatMap(r => r.notes))];
if (cut > 0) warn.push(t("{cut} filters left out: this channel has {n} bands", { cut, n }));
if (skipped > 0) warn.push(t("{n} filters skipped: type not available on the DSP", { n: skipped }));
const proposal = lab.rows ? h("div", { class: "labprop" }, h("div", { class: "sub" }, lab.from),
kept.length ? h("table", { class: "rewtable" },
h("tr", {}, ["", t("Type"), t("Frequency"), "Gain", "Q"].map(x => h("th", {}, x))),
kept.map((r, i) => h("tr", { class: r.band.bypass ? "off" : "" }, h("td", {}, String(i + 1)), h("td", {}, PEQ_SHORT[r.band.type]), h("td", {}, fmtHz(freqHz(r.band.freq))),
h("td", {}, hasGain(r.band.type) ? `${sign(eqDb(r.band.gain))} dB` : "–"), h("td", {}, hasQ(r.band.type) ? String(Q_TABLE[r.band.q]) : "–"))))
: h("p", { class: "info" }, t("No usable filters found.")),
warn.length ? h("p", { class: "rewwarn" }, warn.join(" · ")) : null,
h("div", { class: "row" },
kept.length && !viewOnly() ? h("button", { class: "on", onclick: apply }, t("Apply to {ch}", { ch: name })) : null,
h("button", { "data-view-ok": "", onclick: () => { lab.rows = null; render(); } }, t("Discard")))) : null;
const on = !!lab.rew, has = on && lab.rew.meas.length > 0;
const measSel = h("select", { "aria-label": t("Measurement"), disabled: !has, "data-view-ok": "", onchange: e => { lab.measId = e.target.value; } },
has ? lab.rew.meas.map(m => h("option", { value: m.id, selected: m.id === lab.measId }, m.title)) : h("option", { value: "" }, on ? t("No measurements in REW") : "–"));
const take = async () => {
try { labTake(await api("POST", "/api/rew/filters", { id: lab.measId }), measName()); }
catch (e) { toast(t("Error: ") + trMsg(e.message)); }
};
const sendFilters = async () => {
try {
await api("POST", "/api/rew/send-filters", { id: lab.measId, filters: ch.peq.map(rewFromBand).filter(x => (x.type === "PK" ? x.gaindB !== 0 : true)) });
toast(t("Filters sent to “{m}”", { m: measName() }));
} catch (e) { toast(t("Error: ") + trMsg(e.message)); }
};
const sendCurve = async () => {
try { await api("POST", "/api/rew/send-curve", rewCurve(d, kind, idx)); toast(t("Curve sent to REW as a new measurement")); labCheck(); }
catch (e) { toast(t("Error: ") + trMsg(e.message)); }
};
return [
h("div", { class: "dhead" }, h("h2", {}, "Sound Lab"),
h("div", { class: "row labstate" },
h("span", { class: "dot " + (on ? "online" : "disconnected") }),
h("span", { class: "info" }, on ? t("REW {v} · {n} measurements", { v: lab.rew.version, n: lab.rew.meas.length }) : t("REW not connected")),
h("button", { class: "small", "data-view-ok": "", onclick: labCheck }, t("Check")),
docButton(DOC_LAB))),
h("div", { class: "cards labcards" },
h("div", { class: "card wide" }, h("div", { class: "firchs" }, chans(d, "in").map((_, i) => chip("in", i)), h("span", { class: "firsep" }), chans(d, "out").map((_, i) => chip("out", i)))),
h("div", { class: "card wide" }, h("h3", {}, h("span", { class: "grow" }, name), proposed ? h("span", { class: "lablegend" }, h("i", { style: "background:#38bdf8" }), t("now"), h("i", { style: "background:#f59e0b" }), t("after applying")) : null), canvas),
h("div", { class: "card" }, h("h3", {}, t("From REW to this channel")),
on ? null : h("p", { class: "info" }, t("REW can't be reached. Start REW on the computer running this app and switch on its API (Preferences → API). The filter file works anyway.")),
h("div", { class: "row" }, measSel, h("button", { disabled: !has, "data-view-ok": "", onclick: take }, t("Take filters"))),
h("div", { class: "row" }, h("button", { "data-view-ok": "", onclick: labFromFile }, t("Load REW filter file…"))),
proposal),
h("div", { class: "card" }, h("h3", {}, t("From this channel to REW")),
h("p", { class: "info" }, t("As a measurement you can compare the channel's curve with real measurements in REW. Filters on a measurement let REW predict the result.")),
h("div", { class: "row" }, h("button", { disabled: !on, "data-view-ok": "", onclick: sendCurve }, t("Send curve as a new measurement"))),
h("div", { class: "row" }, h("button", { disabled: !has, "data-view-ok": "", onclick: sendFilters }, t("Send filters to the chosen measurement"))))),
];
}
+1 -1
View File
@@ -664,7 +664,7 @@ function viewSoundField() {
return h("div", { class: "sflayout" },
h("div", { class: "card sfmain" },
h("div", { class: "sfbar" },
h("h3", {}, "SoundField"),
h("h3", {}, "SoundField", docButton(DOC_SF)),
h("div", { class: "sfadd" }, addBtn("top12", "main", t("Main")), addBtn("sub18", "sub", "Sub"),
h("button", { class: "small", title: t("Sub with a top on a distance pole"), onclick: () => sfChange(q => {
const n = q.speakers.filter(x => x.role === "sub").length + 1, x = clamp(q.room.w / 2 + (n - 1) * 1.5, 0, q.room.w), y = Math.min(q.room.d, q.stage.d + 0.5);
+197 -5
View File
@@ -467,6 +467,12 @@ body.locked #statusbar :is(button, select):not([data-view-ok]) { cursor: not-all
.limled { flex: none; display: block; width: 34px; height: 4px; margin-top: 3px; border-radius: 1px;
background: color-mix(in srgb, var(--led-o) 16%, transparent); transition: background .08s, box-shadow .08s; }
.limled.ph { visibility: hidden; }
.limled.dot { width: 9px; height: 9px; margin: 0 8px 0 4px; border-radius: 50%; }
.limcard h3 > .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.limcard h3 .led.h { width: 96px; }
.limled.txt { width: auto; height: auto; margin: 1px 0 0; background: none; font-size: 9px; line-height: 11px; font-weight: 800; letter-spacing: .08em;
color: color-mix(in srgb, var(--led-o) 22%, transparent); transition: color .08s; }
.limled.txt.on { background: none; box-shadow: none; color: var(--led-o); text-shadow: 0 0 5px color-mix(in srgb, var(--led-o) 55%, transparent); }
.limled.on { background: var(--led-o); box-shadow: 0 0 6px var(--led-o), 0 0 2px var(--led-o); }
.limled.h { width: auto; height: auto; margin: 0; padding: 2px 6px; font-size: 10px; font-weight: 700; letter-spacing: .06em;
color: color-mix(in srgb, var(--led-o) 45%, transparent); }
@@ -670,10 +676,10 @@ button.devitem.paused, button.devitem:disabled { opacity: .45; cursor: not-allow
/* ---- settings page */
.setwrap { max-width: 1180px; margin: 0 auto; }
.setnav { position: sticky; top: var(--hdr); z-index: 9; display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 0; margin-bottom: 4px;
.setnav { position: sticky; top: var(--hdr); z-index: 9; display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 0 16px; margin-bottom: 2px;
background: linear-gradient(var(--bg) 75%, transparent); }
.setnav .chip { min-height: 32px; }
.setsec { margin: 6px 0 30px; scroll-margin-top: calc(var(--hdr) + 58px); }
.setsec { margin: 6px 0 30px; scroll-margin-top: calc(var(--hdr) + 64px); }
.setsec > header { margin: 0 2px 12px; }
.setsec > header h2 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: .01em; }
.setsec > header p { margin: 4px 0 0; color: var(--dim); font-size: 13px; max-width: 760px; }
@@ -684,7 +690,7 @@ button.devitem.paused, button.devitem:disabled { opacity: .45; cursor: not-allow
.setgrid > .card > p.info { margin: 0 0 12px; }
.setgrid > .card > :last-child { margin-top: auto; } /* buttons and switches line up at the bottom of each row */
.setgrid > .card > .actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 14px; }
.setgrid > .card > .actions button { flex: 1 1 auto; }
.setgrid > .card > .actions button { flex: 1 1 0; min-width: max-content; }
.setgrid > .card .devform { align-content: start; }
.setgrid .seg { width: 100%; }
.setgrid .seg button { min-height: 40px; }
@@ -769,7 +775,7 @@ input[type=range].haslim::-moz-range-track {
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; }
.dhead h2 { margin: 0; font-size: 20px; white-space: nowrap; }
.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; }
@@ -840,7 +846,10 @@ body.ddragging { user-select: none; -webkit-user-select: none; cursor: grabbing;
.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; }
.led > .limled.seg { flex: 1; width: auto; height: auto; min-height: 0; margin: 0; display: flex; align-items: center; justify-content: center; overflow: hidden;
border-radius: 1.5px; font-size: 6px; line-height: 1; font-weight: 800; letter-spacing: 0; color: color-mix(in srgb, var(--led-o) 30%, transparent);
background: color-mix(in srgb, var(--led-o) 8%, transparent); }
.led > .limled.seg.on { color: var(--led-o); background: color-mix(in srgb, var(--led-o) 20%, transparent); box-shadow: none; }
.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); }
@@ -881,3 +890,186 @@ canvas.dcurve { display: block; width: 100%; flex: 1 1 0; min-height: 70px; back
.guard.on .guardtrack { background: var(--accent); }
.guard.on .guardtrack i { left: 14px; }
body.locked #main input[type=range] { pointer-events: none; }
.nodsp { gap: 10px; }
.nodsp svg { width: 44px; height: 44px; fill: none; stroke: var(--dim); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.nodsp b { color: var(--text); font-size: 18px; }
.nodsp p { max-width: 420px; margin: 0 0 6px; line-height: 1.45; }
/* ---- start animation, VK-Audio */
#splash { display: none; }
#splash.show { position: fixed; inset: 0; z-index: 300; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
background: var(--bg); pointer-events: none; animation: splashout .3s ease-in 1.15s forwards; }
#splash svg { margin-bottom: 8px; fill: none; stroke: #38bdf8; stroke-width: 3; stroke-linecap: round; overflow: visible; }
#splash path { transform-box: fill-box; transform-origin: bottom; animation: splashbar .75s cubic-bezier(.3, 1.5, .5, 1) backwards; }
#splash path:nth-child(2) { animation-delay: .08s; } #splash path:nth-child(3) { animation-delay: .16s; } #splash path:nth-child(4) { animation-delay: .24s; }
#splash b { font-size: 20px; font-weight: 650; color: var(--text); animation: splashtext .4s ease-out .35s backwards; }
#splash small { font-size: 12px; letter-spacing: .14em; color: var(--dim); animation: splashtext .4s ease-out .5s backwards; }
@keyframes splashbar { from { transform: scaleY(0); } }
@keyframes splashtext { from { opacity: 0; transform: translateY(5px); } }
@keyframes splashout { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #splash.show { display: none; } }
.vkfoot { margin: 14px 0 4px; text-align: center; font-size: 10px; letter-spacing: .14em; color: var(--dim); opacity: .45; }
/* ---- note at the end of the settings */
.disclaimer { display: flex; align-items: flex-start; gap: 10px; max-width: 720px; margin: 22px auto 0; padding: 10px 14px; border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
border-radius: 10px; background: color-mix(in srgb, var(--warn) 5%, transparent); }
.disclaimer svg { flex: none; width: 16px; height: 16px; margin-top: 1px; fill: none; stroke: var(--warn); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.disclaimer p { margin: 0; font-size: 12px; line-height: 1.5; color: var(--dim); }
.disclaimer b { color: var(--text); font-weight: 600; }
/* ---- Sound Lab */
.labstate { flex-wrap: nowrap; gap: 6px; align-items: center; min-width: 0; }
.labstate .info { margin: 0 4px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
canvas.labcurve { display: block; width: 100%; height: 240px; background: var(--bg2); border-radius: 8px; }
.lablegend { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 400; color: var(--dim); text-transform: none; letter-spacing: 0; }
.lablegend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-left: 8px; }
.labcards .card > .row { margin-top: 8px; flex-wrap: wrap; }
.labcards .card > .row select { flex: 1; min-width: 150px; }
.labprop { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); }
.labprop .sub { flex: none !important; }
.rewtable { border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
.rewtable th { color: var(--dim); font-weight: 500; text-align: left; }
.rewtable th, .rewtable td { padding: 2px 14px 2px 0; }
.rewtable tr.off td { opacity: .45; }
.rewwarn { margin: 0; padding: 6px 9px; border-radius: 7px; font-size: 12px; color: var(--warn); background: color-mix(in srgb, var(--warn) 9%, transparent); }
/* ---- handbook */
.docbtn { flex: none; width: 28px; min-width: 28px; height: 28px; min-height: 28px; padding: 0; margin-left: 4px; color: var(--dim); }
.docbtn:hover { color: var(--accent); }
.docbtn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dialog:has(> .docbody) { display: flex; flex-direction: column; width: min(820px, 100%); max-height: calc(100dvh - 32px); }
.docbody { position: relative; flex: 1; min-height: 0; overflow-y: auto; margin-right: -8px; padding-right: 8px; scrollbar-width: thin; scrollbar-color: var(--line2) transparent;
font-size: 14px; line-height: 1.55; }
.docnav { position: sticky; top: 0; z-index: 1; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 0 0 10px; background: var(--panel); }
.docnav button { flex: none; }
.docbody section { padding: 16px 0; border-top: 1px solid var(--line); }
.docbody section:first-of-type { padding-top: 6px; border-top: 0; }
.docbody section:last-child { padding-bottom: 4px; }
.docbody h4 { margin: 0 0 8px; font-size: 16px; font-weight: 650; color: var(--text); }
.docbody p { margin: 0 0 10px; }
.docbody p:last-child { margin-bottom: 0; }
.docbody ol, .docbody ul { margin: 0; padding: 0; list-style: none; }
.docbody ol { counter-reset: step; }
.docbody li { position: relative; margin: 8px 0; padding-left: 32px; }
.docbody ol li { counter-increment: step; }
.docbody ol li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
font-size: 12px; font-weight: 700; color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.docbody ul li::before { content: ""; position: absolute; left: 8px; top: 9px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.docui { padding: 0 5px; border-radius: 4px; font-weight: 600; white-space: nowrap; background: var(--panel3); }
.doctip { margin: 12px 0 0 !important; padding: 9px 12px; border-left: 3px solid var(--accent); border-radius: 0 8px 8px 0; color: var(--dim); background: var(--panel2); }
.docbody figure { margin: 12px 0; }
.docbody figure img { display: block; width: auto; max-width: 100%; max-height: 480px; height: auto; margin: 0 auto; border: 1px solid var(--line); border-radius: 10px; }
.docbody figcaption { margin-top: 6px; text-align: center; font-size: 12px; color: var(--dim); }
@media (max-width: 480px) { .dialog:has(> .docbody) { max-height: 92dvh; } .docui { white-space: normal; } }
/* ---- locked with "only show dashboard" */
body.dashonly #viewtabs, body.dashonly #devtabs, body.dashonly #btn-settings, body.dashonly #statusbar { display: none; }
body.dashonly #main { margin-left: 0; }
body.dashonly #btn-muteall { margin-left: auto; }
body.dashonly .dlink { cursor: default; }
.limled.gainlim { margin: 0 2px 0 auto; font-size: 10px; }
.limled.barlim { margin: 0 2px; font-size: 10px; }
/* ---- routing: a soft pulse runs down from the input into the crosspoint, then out along the output */
.xp.on .node { position: relative; z-index: 1; }
.xp.on::before, .xp.on::after { content: ""; position: absolute; pointer-events: none; --pulse: color-mix(in srgb, var(--cc) 35%, #fff); opacity: 0; }
.xp.on::before { top: 0; left: calc(50% - 1.5px); width: 3px; height: 50%;
background: linear-gradient(transparent, var(--pulse), transparent) 0 0 / 100% 16px no-repeat; animation: xpdown 2.8s linear infinite; }
.xp.on::after { top: calc(50% - 1.5px); left: 0; right: 0; height: 3px;
background: linear-gradient(90deg, transparent, var(--pulse), transparent) 50% 0 / 16px 100% no-repeat,
linear-gradient(90deg, transparent, var(--pulse), transparent) 50% 0 / 16px 100% no-repeat; animation: xpout 2.8s linear infinite; }
@keyframes xpdown {
0% { background-position: 0 -16px; opacity: 0; } 8% { opacity: .9; }
35% { background-position: 0 100%; opacity: .9; } 40%, 100% { background-position: 0 100%; opacity: 0; }
}
@keyframes xpout {
0%, 35% { background-position: 50% 0, 50% 0; opacity: 0; } 42% { opacity: .9; }
85% { opacity: .5; } 92%, 100% { background-position: 0% 0, 100% 0; opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .xp.on::before, .xp.on::after { animation: none; } }
/* level of a connection inside its point */
.xp.on .node { width: 36px; height: 36px; border-width: 2px; transform: none; background: color-mix(in srgb, var(--cc) 62%, #0b0c0f); border-color: var(--cc); }
.xp.on small { position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; justify-content: center; pointer-events: none;
font-size: 10px; font-weight: 700; letter-spacing: -.02em; color: #fff; }
/* routing switched: the point pops in or sinks away, a soft ring spreads once */
.xp.fx .node { position: relative; }
.xp.fx .node::after { content: ""; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--cc); opacity: 0; pointer-events: none; animation: xpring .5s ease-out; }
.xp.fx.on .node { animation: xpin .28s cubic-bezier(.3, 1.4, .5, 1); }
.xp.fx:not(.on) .node { animation: xpoff .3s ease-out; }
.xp.fx.on small { animation: xptext .3s ease-out; }
@keyframes xpring { from { transform: scale(1); opacity: .55; } to { transform: scale(1.8); opacity: 0; } }
@keyframes xpin { from { transform: scale(.6); } }
@keyframes xpoff { from { transform: scale(1.45); background: color-mix(in srgb, var(--cc) 45%, var(--bg)); border-color: var(--cc); } }
@keyframes xptext { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .xp.fx .node, .xp.fx .node::after, .xp.fx.on small { animation: none; } }
.lockopt { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
/* ---- DJ Brake setting */
.djurl { margin-top: 8px; align-items: center; flex-wrap: nowrap; }
.djurl code { flex: 1; min-width: 0; padding: 5px 8px; border-radius: 6px; background: var(--bg2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.djwarn { color: var(--warn); }
.djurl button { flex: none; width: auto; }
.djlim { margin: 12px 0 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.djdev { margin-top: 8px; }
.djdev > small { display: block; margin-bottom: 4px; color: var(--dim); }
.djchs { display: flex; flex-wrap: wrap; gap: 6px; }
.djch { display: flex; flex-direction: column; align-items: center; min-width: 58px; padding: 5px 8px; line-height: 1.2; }
.djch small { font-size: 10px; color: var(--dim); }
.djch.out { border-color: var(--warn); color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); text-decoration: line-through; }
.djch.out small { color: inherit; }
.djlim label.chk { display: flex; align-items: flex-start; gap: 8px; margin-top: 8px; }
.djlim label.chk input { flex: none; margin: 3px 0 0; }
.row.djurl button.small { flex: 0 0 auto; width: auto; padding-inline: 14px; }
.row.djurl code { flex: 1 1 auto; }
/* ---- UI pass: controls of one kind line up and have one size */
.kv { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.kv > span { flex: 1; min-width: 0; }
.kvc { flex: 0 0 180px; display: flex; gap: 6px; align-items: stretch; }
.kvc button { flex: 1; }
.kvc input.short { flex: 0 0 76px !important; }
.setgrid > .card > div.info { margin: 0 2px 10px; }
.setgrid > .card > .remote-urls { margin-top: 10px; }
label.chk { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
label.chk input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); }
.paramgrid { display: grid; gap: 2px 24px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.card:has(> .lkgrid) { display: flex; flex-direction: column; container-type: inline-size; }
.lkgrid { grid-template-columns: repeat(2, 1fr); }
@container (min-width: 280px) { .lkgrid { grid-template-columns: repeat(4, 1fr); } }
.lkch { min-width: 0; padding-inline: 4px; }
.lkactions { margin-top: auto; padding-top: 10px; }
.labcards .card > .row > button:only-child { flex: 1 1 100%; }
@media (max-width: 1150px) { .firsep { flex-basis: 100%; width: auto; height: 0; margin: 0; } }
/* phone: the limiter display must stay readable at arm's length */
@media (max-width: 480px) {
.limled.txt { font-size: 11px; line-height: 13px; }
.limled.gainlim, .limled.barlim { font-size: 11px; }
.limled.dot { width: 11px; height: 11px; }
.led > .limled.seg { color: transparent; }
.led > .limled.seg.on { color: transparent; background: var(--led-o); }
}
@media (max-width: 600px) { .cards .card > h3 { flex-wrap: wrap; row-gap: 6px; height: auto; } .cards .card > h3 > * { min-width: 0; } }
.docui { padding: 0 4px; }
html { touch-action: pan-x pan-y; }
.dialog:has(> .resetbody) { width: min(520px, 100%); padding: 22px; }
.dialog:has(> .resetbody) > h2 { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 19px; }
.dialog:has(> .resetbody) > h2::before { content: "!"; flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-size: 19px; font-weight: 800;
color: #fca5a5; background: color-mix(in srgb, #ef4444 18%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, #ef4444 45%, transparent); }
.resetlead { margin: 0 0 14px; color: var(--dim); }
.resetlists { display: grid; grid-template-columns: 1.25fr 1fr; gap: 10px; }
.resetlist { padding: 12px 14px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); }
.resetlist > b { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 650; }
.resetlist ul { margin: 0; padding: 0; list-style: none; font-size: 13px; line-height: 1.35; color: var(--dim); }
.resetlist li { position: relative; margin-top: 6px; padding-left: 20px; }
.resetlist li::before { position: absolute; left: 0; top: 0; width: 14px; text-align: center; font-weight: 800; }
.resetlist.gone > b { color: #fca5a5; }
.resetlist.gone li::before { content: "×"; color: #f87171; }
.resetlist.stays { border-color: color-mix(in srgb, var(--ok, #22c55e) 35%, var(--line)); }
.resetlist.stays > b { color: #86efac; }
.resetlist.stays li { color: var(--text); }
.resetlist.stays li::before { content: "✓"; color: #4ade80; }
.resetwarn { margin: 12px 0 0; padding: 9px 12px; border-radius: 10px; font-size: 13px; color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); }
.resetcheck { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); text-align: center; }
.resetcheck > span { display: block; margin-bottom: 10px; font-size: 13px; color: var(--dim); }
.resetrow { display: flex; align-items: center; justify-content: center; gap: 12px; }
.resetletters { display: flex; gap: 6px; user-select: none; -webkit-user-select: none; }
.resetletters i { display: grid; place-items: center; width: 42px; height: 48px; border-radius: 10px; font: 700 23px ui-monospace, Menlo, Consolas, monospace; color: var(--text); background: var(--panel3); border: 1px solid var(--line2); }
.resetarrow { color: var(--dim); font-size: 18px; }
input.resetcode { width: 90px; height: 48px; padding: 0 0 0 .3em; border-radius: 10px; text-align: center; font: 700 23px ui-monospace, Menlo, Consolas, monospace; letter-spacing: .3em; text-transform: uppercase; }
.dialog:has(> .resetbody) > .dlg-actions { margin-top: 18px; }
.dialog:has(> .resetbody) > .dlg-actions button { flex: 1 1 0; }
.dialog:has(> .resetbody) > .dlg-actions button:disabled { color: var(--dim); background: var(--panel2); border-color: var(--line); opacity: 1; }
@media (max-width: 480px) { .resetlists { grid-template-columns: 1fr; } }
.dialog input.resetcode { flex: none; margin: 0; }
+92
View File
@@ -206,6 +206,98 @@ def test_fir_model():
assert st["outputs"][0]["fir"]["type"] == 1 and st["outputs"][0]["fir"]["name"] == "ABC"
def test_dj_brake_light():
import server, tempfile
from types import SimpleNamespace
with tempfile.TemporaryDirectory() as d:
app = server.App(Path(d) / "c.json")
out = {"mute": False}
app.devices["x"] = SimpleNamespace(id="x", demo=True, state={"outputs": [out, {"mute": False}]}, status="online")
note = lambda t, *limit: app.dj_note({"device": "x", "out": [0.1, 0.1], "limit": list(limit)}, now=t)
note(10.0, False, False)
assert app.dj_state(10.0)["ready"] and not app.dj_state(10.0)["on"]
# on with the limiter, and one more second afterwards
note(100.0, True, False)
assert app.dj_state(100.0)["on"] and app.dj_state(100.9)["on"] and not app.dj_state(101.1)["on"]
# a limiter left out doesn't count, the others do
app.dj_ignore = {"x": [0]}
note(200.0, True, False)
assert not app.dj_state(200.0)["on"]
note(210.0, False, True)
assert app.dj_state(210.0)["on"]
# neither does a muted output, and with nothing left to watch the page says so
app.dj_ignore = {}
out["mute"] = True
note(300.0, True, False)
assert not app.dj_state(300.0)["on"] and app.dj_state(300.0)["ready"]
app.dj_ignore = {"x": [1]}
note(310.0, True, True)
assert not app.dj_state(310.0)["on"] and not app.dj_state(310.0)["ready"]
# only these three things leave here
assert set(app.dj_state(1.0)) == {"on", "ready", "hint"}
def test_reset_config():
import asyncio, json, server, tempfile
with tempfile.TemporaryDirectory() as d:
path = Path(d) / "c.json"
app = server.App(path)
app.load()
app.set_pin("9999", save=False)
app.djbrake, app.lang, app.dj_ignore = True, "de", {"x": [0]}
app.dashboard = {"modules": []}
app.app_token = "t"
app.app_sessions, app.sessions = {"a"}, {"a": 9e12, "b": 9e12}
app.save()
app.mute_all["active"] = True
try:
asyncio.run(app.reset_config())
raise AssertionError("mute all must block the reset")
except ValueError:
assert app.djbrake
app.mute_all["active"] = False
app.remote["enabled"] = False
asyncio.run(app.reset_config())
assert not app.djbrake and app.lang == "" and app.dashboard is None and app.dj_ignore == {} and app.check_pin("1234")
assert app.app_token == "t" and app.app_sessions == {"a"} and set(app.sessions) == {"a"}
assert json.loads(path.with_name("config.before-reset.json").read_text())["djbrake"] is True
def test_looks_follow_presets():
from dsp.device import Device
d = Device("x", "x", "127.0.0.1")
d.state = {"preset_name": "A"}
d.colors, d.linknames = {"out0": "#111111"}, {"out:0,1": "Tops"}
d.sync_look()
d.state = {"preset_name": "B"} # has no look of its own: starts without
d.sync_look()
assert d.colors == {} and d.linknames == {}
d.colors, d.linknames = {"out0": "#222222"}, {"out:0,1": "Subs"}
d.remember_look()
d.state = {"preset_name": "A"}
d.sync_look()
assert d.colors == {"out0": "#111111"} and d.linknames == {"out:0,1": "Tops"}
d.state = {"preset_name": "B"}
d.sync_look()
assert d.colors == {"out0": "#222222"} and d.linknames == {"out:0,1": "Subs"}
assert "looks" not in d.snapshot()
# the first preset ever seen keeps what is there
e = Device("y", "y", "127.0.0.1", colors={"in0": "#333333"})
e.state = {"preset_name": "First"}
e.sync_look()
assert e.colors == {"in0": "#333333"} and "First" in e.looks
# a DSP whose memory image keeps the old name after loading a preset: the listed name counts
e.state = {"preset_name": "First"}
e.recalled, e.recalled_image = "Other", None
e.sync_look()
assert e.look_name == "Other" and e.colors == {}
e.sync_look()
assert e.look_name == "Other"
e.state = {"preset_name": "Third"} # loaded on the device itself
e.sync_look()
assert e.look_name == "Third" and e.recalled == ""
if __name__ == "__main__":
for name, fn in list(globals().items()):
if name.startswith("test_"):
+277
View File
@@ -0,0 +1,277 @@
"""Finds out how a real DSP's output meter relates to its limiter threshold and output gain.
Play steady music into the DSP, close every other control software and run:
python tools/dsp_measure.py --usb
python tools/dsp_measure.py --host 192.168.1.101
It only ever lowers one output's gain (by 6 dB) and limiter threshold, never raises anything above where it was, stores
nothing in a preset slot and puts both back at the end, also on Ctrl+C. A preset export is written first as a backup.
Takes about two minutes. The result goes to dsp-measure-<time>.json.
"""
import argparse
import asyncio
import json
import math
import signal
import statistics
import sys
import time
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from dsp import preset # noqa: E402
from dsp import protocol as P # noqa: E402
from dsp.device import Device # noqa: E402
SIGNAL_MIN_DB = -50.0
THRESHOLD_FLOOR = 60 # raw, -60 dB: below that something is wrong
def db(power: float) -> float:
return 10 * math.log10(power) if power > 1e-12 else -120.0
class Run:
def __init__(self, dev: Device):
self.dev = dev
self.polls: list[dict] = []
self.o = 0
self.ins: list[int] = []
self.gain = None # known once the output is chosen
self.thr = None
def on_event(self, ev: dict):
if ev["type"] == "meters" and self.dev.state:
self.polls.append({"t": time.monotonic(), "out": ev["out"], "in": ev["in"], "limit": ev["limit"],
"gain": self.gain, "thr": self.thr})
async def set(self, gain: int | None = None, thr: int | None = None):
if gain is not None:
self.gain = gain
self.dev.set_param("out", self.o, "gain", gain)
if thr is not None:
self.thr = thr
self.dev.set_param("out", self.o, "limit.threshold", thr)
await self.dev.flush()
def window(self, since: float) -> list[dict]:
return [p for p in self.polls if p["t"] >= since]
def level(self, polls: list[dict]) -> dict:
"""Mean power and upper percentile of the output, and the mean power of the inputs feeding it."""
out = [p["out"][self.o] for p in polls]
loud = sorted(20 * math.log10(v) if v > 0 else -120.0 for v in out) or [-120.0]
inp = [sum(p["in"][i] ** 2 for i in self.ins) for p in polls]
return {"mean_db": round(db(statistics.fmean(v * v for v in out)) if out else -120.0, 2),
"p95_db": round(loud[int(len(loud) * 0.95) - 1 if len(loud) > 1 else 0], 2), "max_db": round(loud[-1], 2),
"in_db": round(db(statistics.fmean(inp)) if inp else -120.0, 2), "polls": len(polls),
"limit_share": round(sum(bool(p["limit"][self.o]) for p in polls) / max(1, len(polls)), 2)}
async def hold(self, seconds: float, settle: float = 1.0) -> dict:
await asyncio.sleep(settle)
since = time.monotonic()
await asyncio.sleep(seconds)
return self.level(self.window(since))
async def find_limit(self, start: int, gain: int) -> dict:
"""Lowers the threshold step by step until the limiter acts, then goes back up to where it was."""
await self.set(gain=gain)
await asyncio.sleep(1.0)
raw = start
result = {"gain_db": P.gain_to_db(gain), "hit": False}
while raw >= THRESHOLD_FLOOR:
await self.set(thr=raw)
since = time.monotonic()
await asyncio.sleep(0.45)
if any(p["limit"][self.o] for p in self.window(since)):
before = self.level(self.window(since - 3.0))
result.update(hit=True, threshold_db=P.threshold_to_db(raw), before=before,
offset_p95_db=round(P.threshold_to_db(raw) - before["p95_db"], 2),
offset_max_db=round(P.threshold_to_db(raw) - before["max_db"], 2))
break
raw -= 2
await self.set(thr=self.start_thr, gain=self.start_gain)
result["flag_after_raise_s"] = await self.flag_clear()
return result
async def flag_clear(self) -> float:
"""The flag was seen staying on for 4 s after raising the threshold: the next round must not take that for a hit."""
start = time.monotonic()
await asyncio.sleep(3.0)
while time.monotonic() - start < 15:
recent = self.window(time.monotonic() - 0.8)
if recent and not any(p["limit"][self.o] for p in recent):
break
await asyncio.sleep(0.2)
on = [p["t"] for p in self.window(start) if p["limit"][self.o]]
return round(on[-1] - start, 2) if on else 0.0
def conclude(res: dict) -> list[str]:
lines = []
d = res.get("gain_test", {}).get("meter_change_db")
if d is not None:
if abs(d + 6) < 1.5:
lines.append(f"Meter is AFTER the output gain: -6 dB gain moved it by {d:+.1f} dB.")
elif abs(d) < 1.5:
lines.append(f"Meter is BEFORE the output gain: -6 dB gain moved it by {d:+.1f} dB.")
else:
lines.append(f"Meter and gain: unclear, -6 dB gain moved it by {d:+.1f} dB.")
hits = [r for r in res.get("limit_rounds", []) if r.get("hit")]
plain = [r["offset_p95_db"] for r in hits if r["gain_db"] == res["start"]["gain_db"]]
if plain:
lines.append(f"Threshold minus meter at the moment the limiter starts: {statistics.fmean(plain):+.1f} dB "
f"(rounds: {plain}, spread {max(plain) - min(plain):.1f} dB).")
low = [r for r in hits if r["gain_db"] != res["start"]["gain_db"]]
if plain and low:
# the threshold alone moves with the music between rounds, threshold minus meter doesn't
a = statistics.fmean(r["offset_max_db"] for r in hits if r["gain_db"] == res["start"]["gain_db"])
b = statistics.fmean(r["offset_max_db"] for r in low)
lines.append(f"Threshold minus loudest meter reading: {a:+.1f} dB, with -6 dB gain {b:+.1f} dB. "
+ ("About the same, so meter and limiter seem to see the same level." if abs(a - b) < 2 else "They differ: compare with another run before concluding anything."))
c = res.get("limiting")
if c:
drop = (c["limiting"]["mean_db"] - c["limiting"]["in_db"]) - (c["free"]["mean_db"] - c["free"]["in_db"])
lines.append(f"Holding the threshold 6 dB below the start of limiting changed the meter by {drop:+.1f} dB against the input: "
+ ("the meter shows the level AFTER the limiter." if drop < -3 else "too little to say whether the meter is before or after the limiter."))
lines.append(f"While limiting, threshold minus meter: p95 {c['threshold_db'] - c['limiting']['p95_db']:+.1f} dB, "
f"mean {c['threshold_db'] - c['limiting']['mean_db']:+.1f} dB.")
return lines
async def measure(run: Run, args) -> dict:
dev = run.dev
print("Listening for music ...", flush=True)
since = time.monotonic()
await asyncio.sleep(5)
polls = run.window(since)
if not polls:
raise RuntimeError("no meter readings from the DSP")
outs = dev.state["outputs"]
power = [statistics.fmean(p["out"][i] ** 2 for p in polls) for i in range(len(outs))]
if args.output:
run.o = args.output - 1
else:
run.o = max((i for i in range(len(outs)) if not outs[i]["mute"]), key=lambda i: power[i], default=0)
ch = outs[run.o]
run.ins = [i for i in range(len(dev.state["inputs"])) if ch["matrix"] >> i & 1] or list(range(len(dev.state["inputs"])))
if ch["mute"] or db(power[run.o]) < SIGNAL_MIN_DB:
raise RuntimeError(f"Out {run.o + 1} has no signal ({db(power[run.o]):.0f} dB) or is muted: play music into the DSP and run again")
run.gain = run.start_gain = ch["gain"]
run.thr = run.start_thr = ch["limit"]["threshold"]
gain6 = P.db_to_gain(P.gain_to_db(run.gain) - 6)
print(f"Using Out {run.o + 1}: gain {P.gain_to_db(run.gain):+.1f} dB, limiter threshold {P.threshold_to_db(run.thr):+.1f} dB, "
f"level {db(power[run.o]):.1f} dB", flush=True)
res = {"device": dev.info, "model": dev.model_name, "output": run.o + 1, "inputs_feeding": [i + 1 for i in run.ins],
"start": {"gain_db": P.gain_to_db(run.gain), "threshold_db": P.threshold_to_db(run.thr), "limit": ch["limit"],
"level_mean_db": round(db(power[run.o]), 2)}}
print("1/3 Output gain -6 dB, three times ...", flush=True)
rows = []
for _ in range(3):
await run.set(gain=run.start_gain)
a = await run.hold(5)
await run.set(gain=gain6)
b = await run.hold(5)
rows.append({"normal": a, "lowered": b, "change_db": round((b["mean_db"] - b["in_db"]) - (a["mean_db"] - a["in_db"]), 2)})
await run.set(gain=run.start_gain)
res["gain_test"] = {"rounds": rows, "meter_change_db": round(statistics.fmean(r["change_db"] for r in rows), 2)}
print("2/3 Lowering the limiter threshold until it acts, several rounds ...", flush=True)
rounds, start = [], run.start_thr
for gain in (run.start_gain, run.start_gain, run.start_gain, gain6, gain6):
r = await run.find_limit(start, gain)
rounds.append(r)
print(" ", {k: r.get(k) for k in ("gain_db", "hit", "threshold_db", "offset_p95_db")}, flush=True)
if r["hit"]: # no need to walk all the way down again
start = min(run.start_thr, int(r["threshold_db"] * 2 + 180) + 12)
res["limit_rounds"] = rounds
hits = [r for r in rounds if r["hit"] and r["gain_db"] == res["start"]["gain_db"]]
if hits:
print("3/3 Holding the limiter on for a moment ...", flush=True)
hit_db = statistics.fmean(r["threshold_db"] for r in hits)
raw = max(THRESHOLD_FLOOR, round((hit_db - 6) * 2 + 180))
free = await run.hold(6)
await run.set(thr=raw)
limiting = await run.hold(8)
await run.set(thr=run.start_thr)
res["limiting"] = {"threshold_db": P.threshold_to_db(raw), "free": free, "limiting": limiting}
res["conclusions"] = conclude(res)
return res
async def main(args):
run: Run | None = None
dev = Device("m", "measure", args.host or "", args.port, args.model, autoconnect=False, transport="usb" if args.usb else "tcp",
on_event=lambda ev: run.on_event(ev))
run = Run(dev)
task = asyncio.current_task()
if sys.platform != "win32":
for sig in (signal.SIGTERM, signal.SIGHUP):
asyncio.get_running_loop().add_signal_handler(sig, task.cancel)
stamp = time.strftime("%Y%m%d-%H%M%S")
outdir = Path(args.dir)
res, error = {}, ""
dev.start()
try:
for _ in range(100):
if dev.status == "online" and dev.state:
break
await asyncio.sleep(0.2)
else:
raise RuntimeError(f"DSP not reached ({dev.status}: {dev.error}). Is other control software still open?")
doc = await dev.export_preset()
backup = outdir / f"dsp-measure-{stamp}-backup.json"
backup.write_text(json.dumps(doc), encoding="utf-8")
before = json.loads(json.dumps(dev.state))
print(f"Connected: {dev.info}. Backup: {backup}", flush=True)
try:
res = await measure(run, args)
except RuntimeError as e:
error = str(e)
except asyncio.CancelledError:
error = "interrupted"
finally:
# always back to where it was, whatever happened above
if hasattr(run, "start_gain"):
await run.set(gain=run.start_gain, thr=run.start_thr)
await asyncio.sleep(0.5)
await dev.refresh()
diffs = preset.differences(before, dev.state)
res["restored"] = not diffs
if diffs:
res["not_restored"] = diffs[:20]
finally:
await dev.stop()
res["error"] = error
res["polls"] = [[round(p["t"] - run.polls[0]["t"], 2), round(db(p["out"][run.o] ** 2), 1), round(db(sum(p["in"][i] ** 2 for i in run.ins)), 1),
int(p["limit"][run.o]), None if p["gain"] is None else P.gain_to_db(p["gain"]),
None if p["thr"] is None else P.threshold_to_db(p["thr"])] for p in run.polls] if run.ins else []
out = outdir / f"dsp-measure-{stamp}.json"
out.write_text(json.dumps(res), encoding="utf-8")
print("\nResult:", out)
for line in res.get("conclusions", []):
print(" *", line)
if error:
print(" ! Stopped:", error)
print(" * Settings restored:", "yes" if res["restored"] else f"NO, import the backup: {res.get('not_restored')}")
return 0 if res["restored"] and not error else 1
if __name__ == "__main__":
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
ap.add_argument("--usb", action="store_true", help="connect over USB")
ap.add_argument("--host", help="IP address of the DSP")
ap.add_argument("--port", type=int, default=P.PORT)
ap.add_argument("--model", default="auto", help="auto, 204 or 408")
ap.add_argument("--output", type=int, help="output number to use, default: the loudest one")
ap.add_argument("--dir", default=".", help="where to write the files")
a = ap.parse_args()
if not a.usb and not a.host:
ap.error("say --usb or --host")
sys.exit(asyncio.run(main(a)))