Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e7f9eaeda | ||
|
|
c19ad62b91 | ||
|
|
4a6eb2f513 | ||
|
|
63b3c17fb7 | ||
|
|
4cd771eb5c | ||
|
|
6d467d4f2d | ||
|
|
bbe8a73775 | ||
|
|
29a89af562 | ||
|
|
6d53069380 | ||
|
|
cf35a1faa1 | ||
|
|
99613327f8 | ||
|
|
a639abf216 | ||
|
|
fc0322cbc9 | ||
|
|
7932ef62c7 | ||
|
|
28624caead | ||
|
|
910cf3fc17 | ||
|
|
d6be627f32 | ||
|
|
8919f0016c | ||
|
|
e56524a8cd | ||
|
|
3ce0334aea | ||
|
|
2fbb5e7424 | ||
|
|
5c391d932c | ||
|
|
a75b803264 | ||
|
|
5f0f893810 | ||
|
|
f043e1a261 | ||
|
|
9203cab4df | ||
|
|
a754021381 | ||
|
|
14ca3aec4b | ||
|
|
144f62f240 | ||
|
|
a02e5dd53e | ||
|
|
9e2636c6d6 | ||
|
|
fe24b620bf | ||
|
|
3a9059d420 | ||
|
|
763a8781f4 | ||
|
|
9c6d2d6e35 | ||
|
|
43def4480c | ||
|
|
24674fb8c0 | ||
|
|
682e734257 | ||
|
|
967191f2f7 | ||
|
|
936d7f64a9 | ||
|
|
b82a6b90c6 | ||
|
|
2ea9fa32bc | ||
|
|
5597fae3f3 | ||
|
|
f7d5e22bb0 | ||
|
|
86ee492ec3 | ||
|
|
0a1f282c63 | ||
|
|
4b33fc2665 |
No files matched your search
@@ -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}
|
||||
]
|
||||
}
|
||||
@@ -12,4 +12,4 @@ __pycache__/
|
||||
.DS_Store
|
||||
|
||||
# personal Claude Code settings
|
||||
.claude/settings.local.json
|
||||
.claude/
|
||||
@@ -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.
|
||||
@@ -45,6 +45,27 @@ pi_writer.py → pi_image.py (cloud-init SD card, installs server.py as a system
|
||||
* **Max level** – `Device.maxgain` (raw gain per channel, app-side) and `Device.gain_cap`: every gain the server sets
|
||||
(API, test fader, copy) is capped at max(limit, current value), so a DSP turned up on the device can only go down
|
||||
until it is below the limit again. The client mirrors this in `gainCap` (faders, sliders, `setParam`).
|
||||
* **Link group names** – `Device.linknames` (app-side, like the colours), keyed by kind and members (`"out:0,1"`), so a
|
||||
changed group starts without a name. The mixer draws them as brackets in row 1 of the `.strips` grid (`linkBands`).
|
||||
* **FIR tab** (`viewFir`, only `d.fir`) – outputs: `0x4B` type/window/cut-offs/taps index, the DSP calculates the filter;
|
||||
the curve is the app's own windowed sinc. Files: `Device.upload_fir` (`0x5B` name, `0x4E` packets of 12 floats). The DSP
|
||||
can't send coefficients back, so the curve of a file only exists in the session (`S.firCoef`).
|
||||
* **Dashboard** (`static/dashboard.js`, stored as `dashboard` in `config.json`, API `/api/dashboard`, `clean_dashboard`) –
|
||||
grid of 12 columns and rows of 40 px, modules in `DASH_MODULES` with `body(m, d)` and `min`/`max` `[columns, rows]`. Must stay read-only: no `setParam` or POST to a device
|
||||
there, browsing (channel, band) is session state (`dashBrowse`). A new module type also goes into `DASH_TYPES` in `server.py`.
|
||||
* **Read-only switch** (`S.guard`, `viewOnly()` in `app.js`) – web UI on phones and touch devices starts read-only, reusing
|
||||
the swallowing of the app lock. A safety catch per browser tab only: not stored, the server doesn't know it. Mute all stays.
|
||||
* **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
|
||||
@@ -94,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`).
|
||||
|
||||
@@ -107,7 +130,14 @@ and the DSP's own mirroring inside groups, limiter-active bit mask, preset impor
|
||||
|
||||
Not verified yet – ask for a log (`python server.py -v`) from real hardware before changing protocol code here:
|
||||
|
||||
* **DSP 408 on real hardware** (layout and frames match published captures, limiter bits for Out 5–8 assumed)
|
||||
* **Beta models** `206` and `408fir` – never seen on real hardware. Never auto-detected (`detect_model`, a FIR device
|
||||
must not pass as a 408); the only hint is the note in the add-device form, afterwards they work like the others.
|
||||
`206`: same protocol and layout as the 204/408 are only assumed (no control software looked at), also the USB ID.
|
||||
`408fir`: own layout and commands derived from its control software (`Model.fir`, `_parse_fir`, `_fir_command`), simulator
|
||||
only. Not done: dynamic EQs (kept untouched), saving coefficients into a preset slot of the DSP (`0x5A`, format
|
||||
not worked out), where it keeps the test signal (the app remembers it). Ask testers for a preset export and a log.
|
||||
* **DSP 408 on real hardware**: 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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -186,3 +191,31 @@ Where the PEQ bypass flag is stored in the image is not known yet.
|
||||
* Send: report ID `00` + one complete frame (`10 02 … 10 03 CHK`), zero-padded to the output report length.
|
||||
* Receive: every input report holds exactly one frame starting at byte 0, length = `LEN + 8`, then padding.
|
||||
* The frames are identical to TCP; the longest (config chunk, 50 data bytes) is 60 bytes and fits a 64-byte report.
|
||||
|
||||
## FIR DSP 408 (unverified)
|
||||
|
||||
Derived from the behaviour of its control software, not yet seen on a device. Same frames; device info starts with
|
||||
`FIR408`. The memory image has 1573 bytes (32 chunks) and its own layout:
|
||||
|
||||
| Offset | Content |
|
||||
|---|---|
|
||||
| `0x010` + 138·n | Input: name 8, gate 4×u16, 3 dynamic EQs of 16 bytes, 8 PEQ bands of 6 bytes, compressor (ratio, attack, release, knee, threshold, EQ frequency as u16, 2 bytes), FIR taps u16, FIR bypass u16, gain, polarity, delay, link |
|
||||
| `0x238` + 108·n | Output: name 8, matrix u16, mix 4×u16, u16, HP frequency u16, LP frequency u16, HP slope, LP slope, HP bypass, LP bypass (bytes), FIR type, window (bytes), low Hz, high Hz, taps index (u16), 9 PEQ bands, limiter (ratio, attack, release, knee, threshold), gain, polarity, delay, link |
|
||||
| `0x598` | Mute masks: inputs u16, outputs u16 |
|
||||
| `0x59C` | Bypassed PEQ bands, u16 bit mask per channel (inputs, then outputs) |
|
||||
| `0x5B4` | FIR name per channel, 8 characters each |
|
||||
|
||||
No GEQ on this model, no master bypass commands. Slope index without the "bypass" entry (0 = BW -6). Changed commands:
|
||||
|
||||
| Cmd | Payload |
|
||||
|---|---|
|
||||
| `0x31` / `0x32` | `[ch][u16 freq][slope][1 = bypass]` |
|
||||
| `0x30` | `[ch]` ratio, attack, release, knee, threshold, EQ frequency as u16, `[EQ type][EQ bypass]` (inputs) |
|
||||
| `0x3F` | `[ch]` ratio, attack, release, knee, threshold as u16 |
|
||||
| `0x4B` | `[ch][type][window][u16 low Hz][u16 high Hz][u16 taps index]`, outputs. Type: bypass, low, high, band, external. Window: rectangle, Bartlett, Hanning, Hamming, Blackman, sine, sinc, Nuttall, Kaiser, Blackman-Nuttall, Blackman-Harris. Taps = 256 + 32·index |
|
||||
| `0x4E` | `[ch][packet][u16 total]` + up to 12 floats, most significant byte first |
|
||||
| `0x4F` | `[ch][1 = bypass]`, inputs |
|
||||
| `0x5B` | `[ch]` + 8 characters of FIR name |
|
||||
|
||||
At most 2048 coefficients per input, 1024 per output, 4096 over all channels.
|
||||
|
||||
@@ -1,83 +1,149 @@
|
||||
# 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.
|
||||
|
||||

|
||||
|
||||
> [!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
|
||||
* **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), 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.
|
||||
|
||||

|
||||
|
||||
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.
|
||||
|
||||

|
||||
|
||||
* 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.
|
||||
|
||||

|
||||
|
||||
### 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.
|
||||
|
||||

|
||||
|
||||
* **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.
|
||||
|
||||

|
||||
|
||||
### 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.
|
||||
|
||||

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