Looks per preset, steadier DJ Brake, no zoom on phones, simple dashboard on touch
Colours and link group names now belong to the preset (by name, the DSP has no IDs) and travel in preset files. DJ Brake: limiters are left out instead of chosen; a slowly falling peak mark, an average bar, a warning before the limit, and it learns from real hits where the limiter sits on the meter. Pinch and double tap zoom are off. On touchscreens the dashboard only offers widget settings. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
99613327f8
commit
cf35a1faa1
11 files changed
+232
-48
No files matched your search
+33
-3
@@ -22,7 +22,8 @@ class Device:
|
||||
def __init__(self, dev_id: str, name: str, host: str, port: int = P.PORT, model: str = "auto",
|
||||
addr: int = 1, autoconnect: bool = True, on_event=None, transport: str = "tcp", usb: str = "",
|
||||
lock_code: str = "", auto_unlock: bool = False, test_saved: list | None = None,
|
||||
colors: dict | None = None, maxgain: dict | None = None, linknames: dict | None = None):
|
||||
colors: dict | None = None, maxgain: dict | None = None, linknames: dict | None = None,
|
||||
looks: dict | None = None, look_name: str = ""):
|
||||
self.id = dev_id
|
||||
self.name = name
|
||||
self.host = host
|
||||
@@ -39,6 +40,11 @@ class Device:
|
||||
self.demo = False # in-process simulator of the demo mode, never saved
|
||||
self.colors: dict[str, str] = colors or {} # channel colours chosen in the app, e.g. {"in0": "#38bdf8"}
|
||||
self.linknames: dict[str, str] = linknames or {} # names of link groups, e.g. {"out:0,1": "Tops"}
|
||||
# colours and group names per preset. The DSP has no IDs for presets, only slots and names, and only the name
|
||||
# is in its memory image, so that is the key. colors/linknames above always are those of look_name.
|
||||
self.looks: dict[str, dict] = looks or {}
|
||||
self.look_name = look_name
|
||||
self.look_dirty = False
|
||||
self.maxgain: dict[str, int] = maxgain or {} # software limit of the gain fader per channel (raw), e.g. {"out0": 260}
|
||||
# audio test: output gains from before the test (restored when it ends) and the test fader level
|
||||
self.test_saved: list[int] | None = test_saved if isinstance(test_saved, list) else None
|
||||
@@ -75,11 +81,13 @@ class Device:
|
||||
"model": self.model_key, "addr": self.addr, "autoconnect": self.autoconnect,
|
||||
"transport": self.transport, "usb": self.usb,
|
||||
"lock_code": self.lock_code, "auto_unlock": self.auto_unlock, "test_saved": self.test_saved,
|
||||
"colors": self.colors, "maxgain": self.maxgain, "linknames": self.linknames}
|
||||
"colors": self.colors, "maxgain": self.maxgain, "linknames": self.linknames,
|
||||
"looks": self.looks, "look_name": self.look_name}
|
||||
|
||||
def snapshot(self) -> dict:
|
||||
cfg = self.config()
|
||||
cfg["lock_code"] = bool(self.lock_code) # clients only learn whether a code is remembered
|
||||
del cfg["looks"], cfg["look_name"]
|
||||
cfg["test_level"] = self.test_level
|
||||
return {**cfg, "demo": self.demo, "status": self.status, "error": self.error, "info": self.info,
|
||||
"detected_model": self.model_name or None,
|
||||
@@ -245,6 +253,24 @@ 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 not seen yet starts with the current one."""
|
||||
name = (self.state or {}).get("preset_name", "").strip()
|
||||
if self.state is None or (name == self.look_name and name in self.looks):
|
||||
return
|
||||
look = self.looks.get(name)
|
||||
if look:
|
||||
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)
|
||||
@@ -259,6 +285,8 @@ 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.remember_look()
|
||||
self._emit_state()
|
||||
|
||||
@property
|
||||
@@ -268,7 +296,8 @@ class Device:
|
||||
async def export_preset(self) -> dict:
|
||||
"""The DSP's current state, read fresh from the device."""
|
||||
await self.refresh()
|
||||
return preset.export_doc(self.model_name, self.info, self.state, self.raw)
|
||||
return {**preset.export_doc(self.model_name, self.info, self.state, self.raw),
|
||||
"look": {"colors": self.colors, "linknames": self.linknames}}
|
||||
|
||||
async def import_preset(self, state: dict) -> list[str]:
|
||||
"""Put the DSP into `state` (working state only). Returns the paths that did not take."""
|
||||
@@ -440,6 +469,7 @@ class Device:
|
||||
if self.model.fir and self.state: # where this model keeps the test signal in its memory is not known
|
||||
state["test"] = self.state.get("test", state["test"])
|
||||
self.state = state
|
||||
self.sync_look()
|
||||
|
||||
async def _read_config(self) -> dict:
|
||||
model = self.model
|
||||
|
||||
Reference in new issue
Block a user