Show in the test show whether the pads are on the cans or the movers.

A Pads layer frame under the movers pads has Cans pads and Movers pads
buttons (scripts/shows/layer_indicator.py). The pad controller holds channel
16 note 0 (cans) or 1 (movers) down and the other up whenever Pause changes,
QLC+ reloads or it starts, and the Flash buttons light while their note is
held, so the lit one is the layer and a missed message can't leave them the
wrong way round. Each flashes an empty scene of its own: with one between
them, QLC+ lit both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Opus 5.5 committed 2026-10-23 15:09:49 +13:00
1 parent 467b480c76
commit c7546e5ea9
5 files changed
+142 -13

No files matched your search

+13 -3
View File
@@ -7,7 +7,10 @@ second set of buttons from the first. Play itself is not passed on.
Pause (CC 28) does the same for bank 1, but latches: the SMC-PAD sends one Pause (CC 28) does the same for bank 1, but latches: the SMC-PAD sends one
message a press, 127 and 0 on alternate presses and nothing on release, and message a press, 127 and 0 on alternate presses and nothing on release, and
bank 1 follows it. At 0, bank 1 pads 36–51 go out as they are, for the cans. bank 1 follows it. At 0, bank 1 pads 36–51 go out as they are, for the cans.
At 127, they go out as 84–99, for the movers. Pause itself is not passed on. At 127, they go out as 84–99, for the movers. Pause itself is not passed on;
instead layer_lamp() tells QLC+ which layer is on, holding channel 16 note 0
(cans) or 1 (movers) down and the other up, for the test show's Pads layer
buttons.
colours holds the last colour pad pressed in each set, as sent (52–67 for the colours holds the last colour pad pressed in each set, as sent (52–67 for the
cans, 68–83 for the movers), or None once it is pressed again: the colour cans, 68–83 for the movers), or None once it is pressed again: the colour
@@ -43,6 +46,8 @@ PAUSE_CC = 28
BANK_1_FIRST = 36 BANK_1_FIRST = 36
BANK_1_LAST = 51 BANK_1_LAST = 51
MOVERS_SHIFT = 48 # bank 1 goes out as 84–99 while Pause is on, above bank 2's held layer MOVERS_SHIFT = 48 # bank 1 goes out as 84–99 while Pause is on, above bank 2's held layer
LAMP_CHANNEL = 15 # channel 16: the Pads layer buttons in QLC+, clear of the pads and knobs
CANS_LAMP, MOVERS_LAMP = 0, 1 # their notes
KNOB_CHANNEL = 0 KNOB_CHANNEL = 0
# Wander, Ballyhoo, Circle, Sweep; Diamond, Square, Corners, Leaf; Tilt: pads 13–16, 9–12, 5 # Wander, Ballyhoo, Circle, Sweep; Diamond, Square, Corners, Leaf; Tilt: pads 13–16, 9–12, 5
RELATIVE_NOTES = (96, 97, 98, 99, 92, 93, 94, 95, 88) RELATIVE_NOTES = (96, 97, 98, 99, 92, 93, 94, 95, 88)
@@ -76,7 +81,7 @@ class PlayLayer:
return [] return []
if kind == 0xB0 and len(data) >= 3 and data[1] == PAUSE_CC: if kind == 0xB0 and len(data) >= 3 and data[1] == PAUSE_CC:
self.movers = data[2] > 0 self.movers = data[2] > 0
return [] return self.layer_lamp()
if kind == 0xB0 and len(data) >= 3 and channel == KNOB_CHANNEL and data[1] in self.position: if kind == 0xB0 and len(data) >= 3 and channel == KNOB_CHANNEL and data[1] in self.position:
self.position[data[1]] = data[2] self.position[data[1]] = data[2]
return [list(data)] return [list(data)]
@@ -119,12 +124,17 @@ class PlayLayer:
"""QLC+ has loaded the show: everything is off. Press the colours that were on.""" """QLC+ has loaded the show: everything is off. Press the colours that were on."""
self.moving = None self.moving = None
self.pattern = None self.pattern = None
out = [] out = self.layer_lamp()
for colour in self.colours.values(): for colour in self.colours.values():
if colour is not None: if colour is not None:
out += tap(*colour) out += tap(*colour)
return out return out
def layer_lamp(self) -> list[list[int]]:
"""The active layer's lamp note held down and the other's let go."""
on, off = (MOVERS_LAMP, CANS_LAMP) if self.movers else (CANS_LAMP, MOVERS_LAMP)
return [[0x80 | LAMP_CHANNEL, off, 0], [0x90 | LAMP_CHANNEL, on, 127]]
def pattern_tap(self) -> list[list[int]]: def pattern_tap(self) -> list[list[int]]:
"""A tap of the can pattern that is on, to toggle it; nothing once none is.""" """A tap of the can pattern that is on, to toggle it; nothing once none is."""
return [] if self.pattern is None else tap(self.pattern_channel, self.pattern) return [] if self.pattern is None else tap(self.pattern_channel, self.pattern)
+5 -2
View File
@@ -54,7 +54,7 @@ for p in glob.glob(str(ROOT / ".venv" / "lib" / "python*" / "site-packages")):
sys.path.insert(0, p) sys.path.insert(0, p)
import rtmidi import rtmidi
from padcontroller.layer import PlayLayer # noqa: E402 from padcontroller.layer import LAMP_CHANNEL, PlayLayer # noqa: E402
# The lamp colours come from the show scripts, which are not part of this package. # The lamp colours come from the show scripts, which are not part of this package.
sys.path.insert(0, str(ROOT / "scripts" / "pad")) sys.path.insert(0, str(ROOT / "scripts" / "pad"))
@@ -225,6 +225,8 @@ def main() -> None:
print(f"Virtual: {VIRTUAL_NAME} (tau={args.tau}s @ {args.rate} Hz)", flush=True) print(f"Virtual: {VIRTUAL_NAME} (tau={args.tau}s @ {args.rate} Hz)", flush=True)
print("Pass notes through (Play held shifts bank 2 up 16); smooth CC. Ctrl+C to stop.", flush=True) print("Pass notes through (Play held shifts bank 2 up 16); smooth CC. Ctrl+C to stop.", flush=True)
_, fed = ensure_links(src_name) _, fed = ensure_links(src_name)
for out in layer.layer_lamp():
midiout.send_message(out)
if not args.no_lamps: if not args.no_lamps:
set_lamps() set_lamps()
@@ -259,7 +261,8 @@ def main() -> None:
taps = layer.reopen() taps = layer.reopen()
for out in taps: for out in taps:
midiout.send_message(out) midiout.send_message(out)
print(f"QLC+ reopened: pressed {sum(out[0] & 0xF0 == 0x90 for out in taps)} colour pad(s) again", flush=True) pressed = sum(out[0] & 0xF0 == 0x90 and out[0] & 0x0F != LAMP_CHANNEL for out in taps)
print(f"QLC+ reopened: pressed {pressed} colour pad(s) again", flush=True)
# Drain inbound # Drain inbound
while True: while True:
+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env python3
"""Show in shows/test.qxw whether the pad's bank 1 is on the cans or the movers.
Pause on the pad latches bank 1 onto the cans or the movers, but only
padcontroller knows which is on (padcontroller/layer.py). It now says so on
MIDI channel 16: note 0 held down for the cans and note 1 for the movers, the
other released. Two Flash buttons in a Pads layer frame, under the movers
pads frame, light while their note is held, so whichever is lit is the layer
the pads are on. Flash rather than Toggle, so each message sets the state outright and a
missed one can't leave them the wrong way round. Each flashes an empty scene
of its own: QLC+ lights every button whose function is flashing, so with one
scene between them both would light.
python3 scripts/shows/layer_indicator.py
Run it once; it stops if the frame is already there. QLC+ has to reopen the
show to see it.
"""
from __future__ import annotations
import re
from mover_bank import NO_FUNCTION, ROOT, button, frame
SHOW = ROOT / "shows" / "test.qxw"
LAYER_NOTE_BASE = 15 * 4096 + 128 # QLC+ input channel of a channel-16 note: this plus the note
CANS_NOTE, MOVERS_NOTE = 0, 1 # padcontroller/layer.py
SIZE = 90
def main() -> None:
xml = SHOW.read_text()
if 'Caption="Pads layer"' in xml:
raise SystemExit(f"{SHOW.relative_to(ROOT)} already has the pads layer indicator")
fid = max(int(i) for i in re.findall(r'<Function ID="(\d+)" Type', xml)) + 1
wid = max(int(i) for i in re.findall(r' ID="(\d+)"', xml.split("<VirtualConsole>")[1]) if int(i) != NO_FUNCTION) + 1
layers = (("Cans pads", CANS_NOTE), ("Movers pads", MOVERS_NOTE))
scenes = "".join(f' <Function ID="{fid + k}" Type="Scene" Name="{caption} lamp">\n'
' <Speed FadeIn="0" FadeOut="0" Duration="0"/>\n </Function>\n'
for k, (caption, _) in enumerate(layers))
buttons = "".join(button(wid + 1 + k, caption, 10 + k * SIZE, 10, SIZE, fid + k, LAYER_NOTE_BASE + note, "Flash")
for k, (caption, note) in enumerate(layers))
widget = frame(wid, "Pads layer", 470, 700, 2 * SIZE + 20, SIZE + 20, buttons, header=False)
anchor = ' <Frame Caption="Movers position" ID="106">' # after the movers pads in the console
if anchor not in xml:
raise SystemExit("Couldn't find the Movers position frame")
xml = xml.replace(anchor, widget + anchor, 1)
xml = xml.replace(" </Engine>", scenes + " </Engine>", 1)
SHOW.write_text(xml)
print(f"Added the pads layer indicator to {SHOW.relative_to(ROOT)} (widgets from ID {wid})")
if __name__ == "__main__":
main()
+50
View File
@@ -1607,6 +1607,12 @@
<SpeedModes FadeIn="Common" FadeOut="Common" Duration="Common"/> <SpeedModes FadeIn="Common" FadeOut="Common" Duration="Common"/>
<Step Number="0" FadeIn="0" Hold="0" FadeOut="0">53</Step> <Step Number="0" FadeIn="0" Hold="0" FadeOut="0">53</Step>
</Function> </Function>
<Function ID="112" Type="Scene" Name="Cans pads lamp">
<Speed FadeIn="0" FadeOut="0" Duration="0"/>
</Function>
<Function ID="113" Type="Scene" Name="Movers pads lamp">
<Speed FadeIn="0" FadeOut="0" Duration="0"/>
</Function>
</Engine> </Engine>
<VirtualConsole> <VirtualConsole>
<Frame Caption=""> <Frame Caption="">
@@ -3891,6 +3897,50 @@
</Playback> </Playback>
</Slider> </Slider>
</Frame> </Frame>
<Frame Caption="Pads layer" ID="129">
<Appearance>
<FrameStyle>Sunken</FrameStyle>
<ForegroundColor>Default</ForegroundColor>
<BackgroundColor>Default</BackgroundColor>
<BackgroundImage>None</BackgroundImage>
<Font>Default</Font>
</Appearance>
<WindowState Visible="True" X="470" Y="700" Width="200" Height="110"/>
<AllowChildren>True</AllowChildren>
<AllowResize>True</AllowResize>
<ShowHeader>False</ShowHeader>
<ShowEnableButton>False</ShowEnableButton>
<Collapsed>False</Collapsed>
<Disabled>False</Disabled>
<Button Caption="Cans pads" ID="130" Icon="">
<WindowState Visible="True" X="10" Y="10" Width="90" Height="90"/>
<Appearance>
<FrameStyle>None</FrameStyle>
<ForegroundColor>Default</ForegroundColor>
<BackgroundColor>Default</BackgroundColor>
<BackgroundImage>None</BackgroundImage>
<Font>Default</Font>
</Appearance>
<Function ID="112"/>
<Action>Flash</Action>
<Intensity Adjust="False">100</Intensity>
<Input Universe="1" Channel="61568"/>
</Button>
<Button Caption="Movers pads" ID="131" Icon="">
<WindowState Visible="True" X="100" Y="10" Width="90" Height="90"/>
<Appearance>
<FrameStyle>None</FrameStyle>
<ForegroundColor>Default</ForegroundColor>
<BackgroundColor>Default</BackgroundColor>
<BackgroundImage>None</BackgroundImage>
<Font>Default</Font>
</Appearance>
<Function ID="113"/>
<Action>Flash</Action>
<Intensity Adjust="False">100</Intensity>
<Input Universe="1" Channel="61569"/>
</Button>
</Frame>
<Frame Caption="Movers position" ID="106"> <Frame Caption="Movers position" ID="106">
<Appearance> <Appearance>
<FrameStyle>Sunken</FrameStyle> <FrameStyle>Sunken</FrameStyle>
+17 -8
View File
@@ -11,6 +11,8 @@ PLAY_UP = [0xB0, 27, 0]
# The pad latches Pause: one message a press, 127 and 0 on alternate presses. # The pad latches Pause: one message a press, 127 and 0 on alternate presses.
PAUSE_ON = [0xB0, 28, 127] PAUSE_ON = [0xB0, 28, 127]
PAUSE_OFF = [0xB0, 28, 0] PAUSE_OFF = [0xB0, 28, 0]
CANS_LIT = [[0x8F, 1, 0], [0x9F, 0, 127]] # channel 16: note 0 down, 1 up
MOVERS_LIT = [[0x8F, 0, 0], [0x9F, 1, 127]]
class PlayLayerTest(unittest.TestCase): class PlayLayerTest(unittest.TestCase):
@@ -80,16 +82,16 @@ class PlayLayerTest(unittest.TestCase):
layer.handle(PLAY_DOWN) layer.handle(PLAY_DOWN)
layer.handle([0x99, 66, 100]) layer.handle([0x99, 66, 100])
layer.handle(PLAY_UP) layer.handle(PLAY_UP)
self.assertEqual(layer.reopen(), [[0x99, 54, 127], [0x89, 54, 0], [0x99, 82, 127], [0x89, 82, 0]]) self.assertEqual(layer.reopen(), CANS_LIT + [[0x99, 54, 127], [0x89, 54, 0], [0x99, 82, 127], [0x89, 82, 0]])
self.assertEqual(layer.colours, {1: (9, 54), 2: (9, 82)}) # still on, for the next reopen self.assertEqual(layer.colours, {1: (9, 54), 2: (9, 82)}) # still on, for the next reopen
def test_pause_toggles_bank_1_to_the_movers(self): def test_pause_toggles_bank_1_to_the_movers(self):
layer = PlayLayer() layer = PlayLayer()
self.assertEqual(layer.handle(PAUSE_ON), []) self.assertEqual(layer.handle(PAUSE_ON), MOVERS_LIT)
self.assertEqual(layer.handle([0x99, 40, 100]), [[0x99, 88, 100]]) self.assertEqual(layer.handle([0x99, 40, 100]), [[0x99, 88, 100]])
self.assertEqual(layer.handle([0x99, 51, 100]), [[0x99, 99, 100]]) self.assertEqual(layer.handle([0x99, 51, 100]), [[0x99, 99, 100]])
self.assertEqual(layer.handle([0x99, 52, 100]), [[0x99, 52, 100]]) self.assertEqual(layer.handle([0x99, 52, 100]), [[0x99, 52, 100]])
self.assertEqual(layer.handle(PAUSE_OFF), []) self.assertEqual(layer.handle(PAUSE_OFF), CANS_LIT)
self.assertEqual(layer.handle([0x99, 44, 100]), [[0x99, 44, 100]]) self.assertEqual(layer.handle([0x99, 44, 100]), [[0x99, 44, 100]])
def test_pads_1_and_2_move_up_on_the_movers_layer(self): def test_pads_1_and_2_move_up_on_the_movers_layer(self):
@@ -107,15 +109,22 @@ class PlayLayerTest(unittest.TestCase):
layer.handle(PAUSE_OFF) layer.handle(PAUSE_OFF)
self.assertEqual(layer.handle([0x89, 48, 0]), [[0x89, 96, 0]]) self.assertEqual(layer.handle([0x89, 48, 0]), [[0x89, 96, 0]])
def test_reopen_with_no_colours_sends_nothing(self): def test_reopen_with_no_colours_only_lights_the_layer(self):
self.assertEqual(PlayLayer().reopen(), []) self.assertEqual(PlayLayer().reopen(), CANS_LIT)
def test_pause_lights_the_layer_it_moves_to(self):
layer = PlayLayer()
self.assertEqual(layer.layer_lamp(), CANS_LIT)
self.assertEqual(layer.handle(PAUSE_ON), MOVERS_LIT)
self.assertEqual(layer.handle(PAUSE_OFF), CANS_LIT)
self.assertEqual(layer.reopen(), CANS_LIT)
def test_pause_follows_the_pads_latch(self): def test_pause_follows_the_pads_latch(self):
layer = PlayLayer() layer = PlayLayer()
layer.handle(PAUSE_OFF) # already on the cans: stays there self.assertEqual(layer.handle(PAUSE_OFF), CANS_LIT) # already on the cans: stays there
self.assertFalse(layer.movers) self.assertFalse(layer.movers)
layer.handle(PAUSE_ON) self.assertEqual(layer.handle(PAUSE_ON), MOVERS_LIT)
layer.handle(PAUSE_ON) # a repeat changes nothing self.assertEqual(layer.handle(PAUSE_ON), MOVERS_LIT) # a repeat changes nothing
self.assertTrue(layer.movers) self.assertTrue(layer.movers)
def test_wander_off_settles_pan_and_tilt(self): def test_wander_off_settles_pan_and_tilt(self):