Add a script that writes SMC-PAD pad colours and saves them on the controller.
The lamps ignore note messages, so the colours are stored in the preset and committed with the same empty write MidiSuite's Save button sends. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
12420bec93
commit
3b0920eeb2
2 files changed
+374
No files matched your search
@@ -0,0 +1,101 @@
|
||||
"""Scene colours become preset RGB writes, and the codec matches a known message."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
spec = importlib.util.spec_from_file_location("pad_colours", ROOT / "scripts" / "pad_colours.py")
|
||||
colours = importlib.util.module_from_spec(spec)
|
||||
assert spec.loader is not None
|
||||
sys.modules["pad_colours"] = colours
|
||||
spec.loader.exec_module(colours)
|
||||
|
||||
|
||||
def test_codec_matches_the_published_write():
|
||||
inner = bytes.fromhex("00592209000005000000800100000178")
|
||||
wire = bytes([0xF0, *colours.encode(inner), 0xF7])
|
||||
assert wire == bytes.fromhex("f000320949000040020000000018000000017001f7")
|
||||
assert colours.decode(wire[1:-1]) == inner
|
||||
|
||||
|
||||
def test_scene_colours_are_stored_on_the_note_36_pads():
|
||||
writes = colours.colour_writes()
|
||||
first = writes[:16]
|
||||
assert [name for name, _addr, _rgb in first] == [
|
||||
"Red",
|
||||
"Green",
|
||||
"Blue",
|
||||
"White",
|
||||
"Yellow",
|
||||
"Cyan",
|
||||
"Magenta",
|
||||
"Orange",
|
||||
"Warm",
|
||||
"Cool",
|
||||
"Pink",
|
||||
"Lime",
|
||||
"Full",
|
||||
"Half",
|
||||
"Dim50",
|
||||
"Black",
|
||||
]
|
||||
assert first[0][1:] == (1048, bytes.fromhex("f00000"))
|
||||
assert first[1][1:] == (1074, bytes.fromhex("00f000"))
|
||||
assert first[2][1:] == (1100, bytes.fromhex("0000f0"))
|
||||
assert first[3][1:] == (1126, bytes.fromhex("f0f0f0"))
|
||||
assert first[15][1:] == (1048 + 15 * 26, b"\x00\x00\x00")
|
||||
assert len(writes) == 16 * len(colours.BANKS)
|
||||
assert {address for _name, address, _rgb in writes if _name == "Red"} == {
|
||||
bank + 4 for bank in colours.BANKS
|
||||
}
|
||||
|
||||
|
||||
def test_xchc_colours_are_stored_on_pad_bank_2():
|
||||
writes = colours.colour_writes(bank=2, colours=colours.xchc_colours())
|
||||
first = [item for item in writes if item[1] < colours.BANKS[1]]
|
||||
assert [name for name, _addr, _rgb in first] == [
|
||||
"Red",
|
||||
"Orange",
|
||||
"Yellow",
|
||||
"Green",
|
||||
"Cyan",
|
||||
"Blue",
|
||||
"Violet",
|
||||
"Magenta",
|
||||
"White",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
]
|
||||
assert first[0][1:] == (1464, bytes.fromhex("f00000"))
|
||||
assert first[1][1:] == (1490, bytes.fromhex("f07800"))
|
||||
assert first[6][1:] == (1464 + 6 * 26, bytes.fromhex("7800f0"))
|
||||
assert first[8][1:] == (1464 + 8 * 26, bytes.fromhex("f0f0f0"))
|
||||
assert first[9][1:] == (1464 + 9 * 26, b"\x00\x00\x00")
|
||||
assert {address for name, address, _rgb in writes if name == "Red"} == {
|
||||
base + 16 * 26 + 4 for base in colours.BANKS
|
||||
}
|
||||
|
||||
|
||||
def test_save_is_the_empty_write_midi_suite_sends():
|
||||
inner = colours.decode(bytes(colours.save_request()[1:-1]))
|
||||
assert inner[:3] == b"\x00\x59\x22"
|
||||
length = int.from_bytes(inner[3:6], "little")
|
||||
assert inner[6:6 + length] == bytes([5, 0, 0, 0, 0, 0, 0, 0])
|
||||
assert len(colours.save_request()) == 20
|
||||
|
||||
|
||||
def test_private_port_is_not_the_master_or_qlc():
|
||||
names = [
|
||||
"SINCO:SINCO SMC-PAD-Master 20:1",
|
||||
"SINCO:SINCO SMC-PAD-Private 20:0",
|
||||
"qlcplus:__QLC__ 128:0",
|
||||
]
|
||||
assert colours.private_port(names) == "SINCO:SINCO SMC-PAD-Private 20:0"
|
||||
Reference in new issue
Block a user