diff --git a/padcontroller/layer.py b/padcontroller/layer.py index 5c67ee9..c0b96ba 100644 --- a/padcontroller/layer.py +++ b/padcontroller/layer.py @@ -38,10 +38,12 @@ reopen() presses them again when QLC+ loads the show. The movers' Wander and Ballyhoo pads (notes 96 and 97, pads 13 and 14 on the movers layer) each toggle a relative EFX around the Pan and Tilt knobs (9 and 10, -CC 38 and 39). QLC+ 4.12 leaves an EFX's last offset on the movers when it stops, -until those sliders change, so when either goes off, settle asks for the two -knobs one step off and then back (nudge() and positions()). moving holds the -notes whose EFX is on, from the presses: a guess like pump. +CC 38 and 39). They share a solo frame in QLC+, so starting one stops the other. +QLC+ 4.12 leaves an EFX's last offset on the movers when it stops, until those +sliders change, so when the one that is on goes off, settle asks for the two +knobs one step off and then back (nudge() and positions()). Swapping needs +none: the new EFX writes over the old one's offset. moving holds the note whose +EFX is on, from the presses: a guess like pump. """ from __future__ import annotations @@ -76,7 +78,7 @@ class PlayLayer: self.knobs = {cc: 127 for cc in (PEAK_CC, *SIDE_CCS)} # Pan and Tilt as last sent; QLC+ starts them at 0. self.position = {cc: 0 for cc in POSITION_CCS} - self.moving: set[int] = set() + self.moving: int | None = None self.settle = False # a relative EFX just went off: the caller sends nudge(), then positions() # set -> (channel, note sent) of the colour that is on self.colours: dict[int, tuple[int, int] | None] = {1: None, 2: None} @@ -131,9 +133,11 @@ class PlayLayer: self.threshold = not self.threshold extra = [*extra, [0xB0, SUBMASTER_CC, 0 if self.threshold else 127]] elif note in RELATIVE_NOTES and is_on: - if note in self.moving: + if note == self.moving: + self.moving = None self.settle = True - self.moving ^= {note} + else: + self.moving = note if is_on and FIRST_NOTE <= out <= LAST_NOTE + SHIFT: colour_set = 1 if out <= LAST_NOTE else 2 pressed = (channel, out) @@ -155,7 +159,7 @@ class PlayLayer: """ self.pump = False self.threshold = False - self.moving.clear() + self.moving = None out = [] for colour in self.colours.values(): if colour is not None: diff --git a/scripts/shows/mover_movement_solo.py b/scripts/shows/mover_movement_solo.py new file mode 100644 index 0000000..7e87678 --- /dev/null +++ b/scripts/shows/mover_movement_solo.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 +"""Make Wander and Ballyhoo one at a time in shows/test.qxw. + +Their two buttons go into a solo frame, Movement, where they already sit on the +top row of the movers pads, so starting one stops the other, as the colour sets +do. padcontroller/layer.py follows the same rule. + + python3 scripts/shows/mover_movement_solo.py + +Run it once on a show with Wander and Ballyhoo on the top row; it stops if the +solo 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, appearance + +SHOW = ROOT / "shows" / "test.qxw" + +BUTTONS = ("Wander", "Ballyhoo") +SIZE = 90 + + +def main() -> None: + xml = SHOW.read_text() + if 'Caption="Movement"' in xml: + raise SystemExit(f"{SHOW.relative_to(ROOT)} already has the Movement solo frame") + wid = max(int(i) for i in re.findall(r' ID="(\d+)"', xml.split("")[1]) + if int(i) != NO_FUNCTION) + 1 + + found = [re.search(rf' \n', xml, re.S).group(0) + for caption in BUTTONS] + body = "" + for i, button in enumerate(found): + xml = xml.replace(button, "", 1) + # Inside the frame each sits at its place in the row, one level deeper. + moved = re.sub(r'X="\d+" Y="\d+"', f'X="{SIZE * i}" Y="0"', button, count=1) + body += "".join(" " + line if line else line for line in moved.splitlines(keepends=True)) + + frame = (f' \n' + + appearance(" ") + + f' \n' + ' True\n True\n' + ' False\n False\n' + ' False\n False\n False\n' + + body + ' \n') + + strobe = re.search(r' + + - - diff --git a/tests/test_pad_layer.py b/tests/test_pad_layer.py index d1a2d4c..f352e1c 100644 --- a/tests/test_pad_layer.py +++ b/tests/test_pad_layer.py @@ -193,9 +193,9 @@ class PlayLayerTest(unittest.TestCase): layer.handle(PAUSE_DOWN) self.assertEqual(layer.handle([0x99, 48, 100]), [[0x99, 96, 100]]) layer.handle([0x89, 48, 0]) - self.assertEqual((layer.moving, layer.settle), ({96}, False)) + self.assertEqual((layer.moving, layer.settle), (96, False)) layer.handle([0x99, 48, 100]) - self.assertEqual((layer.moving, layer.settle), (set(), True)) + self.assertEqual((layer.moving, layer.settle), (None, True)) self.assertEqual(layer.nudge(), [[0xB0, 38, 39], [0xB0, 39, 1]]) self.assertEqual(layer.positions(), [[0xB0, 38, 40], [0xB0, 39, 0]]) @@ -203,16 +203,16 @@ class PlayLayerTest(unittest.TestCase): layer = PlayLayer() layer.handle([0x99, 48, 100]) layer.handle([0x99, 48, 100]) - self.assertEqual((layer.moving, layer.settle), (set(), False)) + self.assertEqual((layer.moving, layer.settle), (None, False)) - def test_ballyhoo_off_settles_while_wander_runs_on(self): + def test_ballyhoo_takes_over_from_wander_without_a_settle(self): layer = PlayLayer() layer.handle(PAUSE_DOWN) layer.handle([0x99, 48, 100]) self.assertEqual(layer.handle([0x99, 49, 100]), [[0x99, 97, 100]]) - self.assertEqual((layer.moving, layer.settle), ({96, 97}, False)) + self.assertEqual((layer.moving, layer.settle), (97, False)) layer.handle([0x99, 49, 100]) - self.assertEqual((layer.moving, layer.settle), ({96}, True)) + self.assertEqual((layer.moving, layer.settle), (None, True)) if __name__ == "__main__":