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:
1 parent
66f988cf08
commit
ae9a20fdf8
9 files changed
+215
-50
No files matched your search
+4
-3
@@ -58,7 +58,7 @@ def _common(s: dict, c: dict) -> dict:
|
||||
"hp": _filter(s.get("hp"), c["hp"]), "lp": _filter(s.get("lp"), c["lp"]),
|
||||
"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"]))}
|
||||
"mute": bool(s.get("mute", c["mute"])), "peq_bypass": bool(s.get("peq_bypass", c.get("peq_bypass", False)))}
|
||||
|
||||
|
||||
def clean_state(model: P.Model, src: dict, base: dict) -> dict:
|
||||
@@ -70,6 +70,7 @@ def clean_state(model: P.Model, src: dict, base: dict) -> dict:
|
||||
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))),
|
||||
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 {}
|
||||
@@ -131,9 +132,9 @@ 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"] + [f"peq.{b}" for b in range(len(ch["peq"]))]
|
||||
params = ["name", "gain", "polarity", "delay", "hp", "lp", "peq_bypass"] + [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"]
|
||||
params += [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"]))]
|
||||
for p in params + ["mute"]:
|
||||
|
||||
+21
-4
@@ -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])
|
||||
|
||||
Reference in new issue
Block a user