Add phase view, channel overlays and PEQ/GEQ master bypass

- EQ curve computed as complex response: PEQ biquads (now incl. all-pass),
  crossover filters from Butterworth/Bessel/Linkwitz-Riley prototypes
- Mag/Phase switch; phase wraps at +-180 degrees like the original software
- overlay any other channel of the device in the curve (e.g. sub/top crossover)
- EQ Bypass (0x3C) for all PEQ bands, GEQ Bypass (0x49) for the inputs,
  read from the bit masks at the end of the memory image; preset import aware

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
GivouandClaude Opus 5.5 committed 2026-11-01 21:47:15 +01:00
1 parent 66f988cf08
commit ae9a20fdf8
9 files changed
+215 -50

No files matched your search

+21 -4
View File
@@ -25,6 +25,8 @@ CMD_PRESET_NAME = 0x29
CMD_PRESET_COUNT = 0x2C # answer: [time lock][4 bytes time lock data][device lock] (see device_locked)
CMD_UNLOCK = 0x2D # [0][code 4] -> answer [0][1 = unlocked, 0 = wrong code]
CMD_SET_LOCK_CODE = 0x2F # [code 4]
CMD_PEQ_BYPASS = 0x3C # [ch][1 = all PEQ bands bypassed]
CMD_GEQ_BYPASS = 0x49 # [ch][1 = GEQ bypassed] (inputs)
CMD_TEST_SIGNAL = 0x39 # [source][freq index]: 0 = analog input, 1 = pink noise, 2 = white noise, 3 = sine
CMD_METER = 0x40
@@ -322,8 +324,12 @@ def parse_state(model: Model, buf: bytes) -> dict:
"link": u16(p + 84),
"mute": bool(out_mute >> i & 1),
})
source, freq = struct.unpack_from("<HH", buf, model.test_base)
source, freq, _, peq_in, peq_out, geq_in = struct.unpack_from("<6H", buf, model.test_base)
test = {"source": source if source < len(TEST_SOURCES) else 0, "freq": freq if freq < 31 else 0}
for i, ch in enumerate(inputs):
ch["peq_bypass"], ch["geq_bypass"] = bool(peq_in >> i & 1), bool(geq_in >> i & 1)
for i, ch in enumerate(outputs):
ch["peq_bypass"] = bool(peq_out >> i & 1)
return {"preset_name": _name(buf[2:16]), "inputs": inputs, "outputs": outputs, "test": test}
@@ -369,7 +375,10 @@ def build_state_buffer(model: Model, state: dict) -> bytearray:
out_mute |= int(ch["mute"]) << i
struct.pack_into("<HH", buf, model.globals_base, in_mute, out_mute)
test = state.get("test") or {}
mask = lambda chans, key: sum(int(bool(ch.get(key))) << i for i, ch in enumerate(chans))
struct.pack_into("<HH", buf, model.test_base, test.get("source", 0), test.get("freq", 0))
struct.pack_into("<3H", buf, model.test_base + 6, mask(state["inputs"], "peq_bypass"),
mask(state["outputs"], "peq_bypass"), mask(state["inputs"], "geq_bypass"))
return buf
@@ -382,14 +391,14 @@ def default_state(model: Model) -> dict:
"name": f"In{chr(65 + i)}", "gate": {"attack": 0, "release": 99, "hold": 99, "threshold": 0},
"geq": [120] * 31, "peq": peq(8), "hp": {"freq": 0, "slope": 0},
"lp": {"freq": 300, "slope": 0}, "gain": 280, "polarity": False, "delay": 0, "mute": False,
"link": 1 << i,
"link": 1 << i, "peq_bypass": False, "geq_bypass": False,
} 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}, "peq": peq(9),
"comp": {"ratio": 0, "attack": 49, "release": 499, "knee": 0, "threshold": 220},
"limit": {"attack": 49, "release": 499, "knee": 0, "threshold": 220},
"gain": 280, "polarity": False, "delay": 0, "mute": False, "link": 1 << i,
"gain": 280, "polarity": False, "delay": 0, "mute": False, "link": 1 << i, "peq_bypass": False,
} for i in range(model.n_out)],
"test": {"source": 0, "freq": 17},
}
@@ -474,6 +483,10 @@ def param_command(model: Model, kind: str, idx: int, ch: dict, param: str) -> tu
b = ch["peq"][band]
return CMD_PEQ, bytes([c, band]) + _w(b["gain"]) + _w(b["freq"]) + bytes(
[b["q"], b["type"], int(b["bypass"])])
if top == "peq_bypass":
return CMD_PEQ_BYPASS, bytes([c, int(ch["peq_bypass"])])
if top == "geq_bypass" and kind == "in":
return CMD_GEQ_BYPASS, bytes([c, int(ch["geq_bypass"])])
if top == "geq" and kind == "in":
band = int(rest[0])
return CMD_GEQ, bytes([c, band]) + _w(ch["geq"][band])
@@ -522,7 +535,11 @@ 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_GAIN:
if cmd == CMD_PEQ_BYPASS:
ch["peq_bypass"] = bool(p[1])
elif cmd == CMD_GEQ_BYPASS:
ch["geq_bypass"] = bool(p[1])
elif cmd == CMD_GAIN:
ch["gain"] = w(1)
elif cmd == CMD_MUTE:
ch["mute"] = bool(p[1])