Add a Wander pad for the movers to the test show.
Pad 10 on the movers layer (note 93) toggles a relative EFX that drifts all four movers around the Pan and Tilt knobs: a 24 s Lissajous of about ±30° pan and ±10° tilt, each mover a quarter of the way further round, easing in over 2 s (scripts/shows/mover_wander.py). QLC+ 4.12 leaves a relative EFX's last offset on the movers when it stops, until the sliders under it change. So when Wander goes off, the pad controller nudges the Pan and Tilt knobs a step and puts them back, 0.1 s apart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f8c8cea3ef
commit
00c8c2d35d
5 files changed
+213
No files matched your search
@@ -35,6 +35,12 @@ 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
|
||||
buttons toggle in a solo frame. QLC+ does not save which buttons are on, so
|
||||
reopen() presses them again when QLC+ loads the show.
|
||||
|
||||
The movers' Wander pad (note 93, pad 10 on the movers layer) toggles a relative
|
||||
EFX around the Pan and Tilt knobs (9 and 10, CC 38 and 39). QLC+ 4.12 leaves the
|
||||
EFX's last offset on the movers when it stops, until those sliders change, so
|
||||
when Wander goes off, settle() asks for the two knobs one step off and then back
|
||||
(nudge() and positions()). wander follows the presses, a guess like pump.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -53,6 +59,8 @@ SUBMASTER_CC = 100
|
||||
KNOB_CHANNEL = 0
|
||||
PEAK_CC = 35 # knob 6
|
||||
SIDE_CCS = (34, 37) # knobs 5 and 8: Cans 9–15 and Cans 1, 2, 7, 8
|
||||
WANDER_NOTE = 93 # pad 10 on the movers layer
|
||||
POSITION_CCS = (38, 39) # knobs 9 and 10: the movers' Pan and Tilt
|
||||
|
||||
|
||||
class PlayLayer:
|
||||
@@ -65,6 +73,10 @@ class PlayLayer:
|
||||
self.threshold = False
|
||||
# Last value of each knob below, from the pad; QLC+ starts them at full.
|
||||
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.wander = False
|
||||
self.settle = False # Wander 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}
|
||||
|
||||
@@ -85,6 +97,9 @@ class PlayLayer:
|
||||
if data[1] == PEAK_CC:
|
||||
return [list(data), *self.sides()]
|
||||
return [] if self.pump else [list(data)]
|
||||
if kind == 0xB0 and len(data) >= 3 and channel == KNOB_CHANNEL and data[1] in self.position:
|
||||
self.position[data[1]] = data[2]
|
||||
return [list(data)]
|
||||
if kind not in (0x80, 0x90) or len(data) < 3:
|
||||
return [list(data)]
|
||||
key = (channel, data[1])
|
||||
@@ -114,6 +129,9 @@ class PlayLayer:
|
||||
extra = self.sides(restore=True)
|
||||
self.threshold = not self.threshold
|
||||
extra = [*extra, [0xB0, SUBMASTER_CC, 0 if self.threshold else 127]]
|
||||
elif note == WANDER_NOTE and is_on:
|
||||
self.wander = not self.wander
|
||||
self.settle = not self.wander
|
||||
if is_on and FIRST_NOTE <= out <= LAST_NOTE + SHIFT:
|
||||
colour_set = 1 if out <= LAST_NOTE else 2
|
||||
pressed = (channel, out)
|
||||
@@ -135,6 +153,7 @@ class PlayLayer:
|
||||
"""
|
||||
self.pump = False
|
||||
self.threshold = False
|
||||
self.wander = False
|
||||
out = []
|
||||
for colour in self.colours.values():
|
||||
if colour is not None:
|
||||
@@ -150,6 +169,15 @@ class PlayLayer:
|
||||
return [[0xB0 | KNOB_CHANNEL, cc, self.knobs[PEAK_CC]] for cc in SIDE_CCS]
|
||||
|
||||
|
||||
def nudge(self) -> list[list[int]]:
|
||||
"""Pan and Tilt one step off their knobs, so QLC+ writes them again."""
|
||||
return [[0xB0 | KNOB_CHANNEL, cc, v - 1 if v else 1] for cc, v in self.position.items()]
|
||||
|
||||
def positions(self) -> list[list[int]]:
|
||||
"""Pan and Tilt back at their knobs."""
|
||||
return [[0xB0 | KNOB_CHANNEL, cc, v] for cc, v in self.position.items()]
|
||||
|
||||
|
||||
def tap(channel: int, note: int) -> list[list[int]]:
|
||||
"""A press and release of note, to toggle a QLC+ button off."""
|
||||
return [[0x90 | channel, note, 127], [0x80 | channel, note, 0]]
|
||||
@@ -19,6 +19,10 @@ the pad controller runs means the show has just loaded with every button off.
|
||||
REOPEN_DELAY later it presses the last colour pads again (see PlayLayer.colours),
|
||||
which it keeps in COLOURS_FILE so they outlive a restart of the pad controller.
|
||||
|
||||
When the movers' Wander pad goes off, SETTLE_DELAY later it nudges the Pan and
|
||||
Tilt knobs a step and puts them back, so QLC+ drops the EFX's last offset
|
||||
(see PlayLayer.settle).
|
||||
|
||||
Usage:
|
||||
.venv/bin/python -m padcontroller.midi
|
||||
# optional: --tau 0.05 (seconds; lower = snappier, higher = silkier)
|
||||
@@ -39,6 +43,7 @@ import threading
|
||||
import time
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Callable
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
import glob
|
||||
@@ -56,6 +61,7 @@ from pad_lamps import set_lamps, set_sound_lamps # noqa: E402
|
||||
VIRTUAL_NAME = "padcontroller"
|
||||
COLOURS_FILE = Path(os.environ.get("XDG_STATE_HOME", Path.home() / ".local" / "state")) / "padcontroller" / "colours.json"
|
||||
REOPEN_DELAY = 1.5 # s for QLC+ to finish loading the virtual console
|
||||
SETTLE_DELAY = 0.1 # s for QLC+ to stop the Wander EFX before the knob nudge, and between its two steps
|
||||
# Bluetooth first when the pad is paired, USB otherwise.
|
||||
SOURCE_HINTS = (
|
||||
"SMC-PAD Bluetooth",
|
||||
@@ -222,6 +228,8 @@ def main() -> None:
|
||||
load_colours(layer)
|
||||
saved_colours = dict(layer.colours)
|
||||
reopen_at: float | None = None
|
||||
# (when, messages to send then), for the Wander settle
|
||||
later: list[tuple[float, Callable[[], list[list[int]]]]] = []
|
||||
# Links made this soon after start are ours being restored, with QLC+'s buttons as they were.
|
||||
reopen_from = time.monotonic() + 5.0
|
||||
|
||||
@@ -289,6 +297,13 @@ def main() -> None:
|
||||
midiout.send_message(out)
|
||||
if sound_lamps:
|
||||
sound_lamps.show(layer.pump, layer.threshold)
|
||||
if layer.settle:
|
||||
layer.settle = False
|
||||
later += [(now + SETTLE_DELAY, layer.nudge), (now + 2 * SETTLE_DELAY, layer.positions)]
|
||||
for due in [item for item in later if now >= item[0]]:
|
||||
later.remove(due)
|
||||
for out in due[1]():
|
||||
midiout.send_message(out)
|
||||
if layer.colours != saved_colours:
|
||||
save_colours(layer)
|
||||
saved_colours = dict(layer.colours)
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Add a Wander pad for the movers to shows/test.qxw, on note 93.
|
||||
|
||||
On the movers layer (Pause on), pad 10 toggles a slow relative EFX that drifts
|
||||
all four movers around wherever the Pan and Tilt knobs (9 and 10, CC 38 and 39)
|
||||
put them, so turning the knobs moves the middle of the wander:
|
||||
|
||||
93 Wander a Lissajous about ±30° of pan and ±10° of tilt, 24 s round
|
||||
|
||||
Each mover starts a quarter of the way further round, so they don't move as one.
|
||||
It fades in over 2 s, so the movers ease off the knob position. QLC+ 4.12 leaves
|
||||
a relative EFX's last offset on the movers when it stops (with or without a
|
||||
fade-out), so the pad controller nudges the two knobs when Wander goes off
|
||||
(padcontroller/layer.py).
|
||||
|
||||
python3 scripts/shows/mover_wander.py
|
||||
|
||||
Run it once on a show without it; it stops if it is already there.
|
||||
QLC+ has to reopen the show to see it.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
|
||||
from mover_bank import LEFT_TO_RIGHT, NO_FUNCTION, ROOT, button, note
|
||||
|
||||
SHOW = ROOT / "shows" / "test.qxw"
|
||||
|
||||
WIDTH, HEIGHT = 14, 10 # of 255 each way: 540° of pan, 270° of tilt
|
||||
ROUND_MS = 24000
|
||||
FADE_IN_MS = 2000
|
||||
|
||||
|
||||
def efx(fid: int) -> str:
|
||||
fixtures = "".join(f""" <Fixture>
|
||||
<ID>{f}</ID>
|
||||
<Head>0</Head>
|
||||
<Mode>0</Mode>
|
||||
<Direction>Forward</Direction>
|
||||
<StartOffset>{90 * i}</StartOffset>
|
||||
</Fixture>
|
||||
""" for i, f in enumerate(LEFT_TO_RIGHT))
|
||||
# Relative: the EFX adds its offset from 127 to the Pan and Tilt sliders' levels.
|
||||
return f""" <Function ID="{fid}" Type="EFX" Name="Movers wander">
|
||||
{fixtures} <PropagationMode>Parallel</PropagationMode>
|
||||
<Speed FadeIn="{FADE_IN_MS}" FadeOut="0" Duration="{ROUND_MS}"/>
|
||||
<Direction>Forward</Direction>
|
||||
<RunOrder>Loop</RunOrder>
|
||||
<Algorithm>Lissajous</Algorithm>
|
||||
<Width>{WIDTH}</Width>
|
||||
<Height>{HEIGHT}</Height>
|
||||
<Rotation>0</Rotation>
|
||||
<StartOffset>0</StartOffset>
|
||||
<IsRelative>1</IsRelative>
|
||||
<Axis Name="X">
|
||||
<Offset>127</Offset>
|
||||
<Frequency>3</Frequency>
|
||||
<Phase>90</Phase>
|
||||
</Axis>
|
||||
<Axis Name="Y">
|
||||
<Offset>127</Offset>
|
||||
<Frequency>2</Frequency>
|
||||
<Phase>0</Phase>
|
||||
</Axis>
|
||||
</Function>
|
||||
"""
|
||||
|
||||
|
||||
def main() -> None:
|
||||
xml = SHOW.read_text()
|
||||
if 'Name="Movers wander"' in xml:
|
||||
raise SystemExit(f"{SHOW.relative_to(ROOT)} already has the movers wander")
|
||||
engine, console = xml.split("<VirtualConsole>")
|
||||
fid = max(int(i) for i in re.findall(r'<Function ID="(\d+)" Type', engine)) + 1
|
||||
wid = max(int(i) for i in re.findall(r' ID="(\d+)"', console) if int(i) != NO_FUNCTION) + 1
|
||||
|
||||
xml = xml.replace(" </Engine>", efx(fid) + " </Engine>", 1)
|
||||
# Beside the movers' Strobe, where Strobe 2 sits on the cans' layer.
|
||||
strobe = re.search(r' <Button Caption="Strobe" ID="89" Icon="">\n.*? </Button>\n', xml, re.S).group(0)
|
||||
xml = xml.replace(strobe, strobe + button(wid, "Wander", 100, 100, 90, fid, note(45)), 1)
|
||||
SHOW.write_text(xml)
|
||||
print(f"Added the movers wander to {SHOW.relative_to(ROOT)} (function {fid}, widget {wid})")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1027,6 +1027,56 @@
|
||||
<ControlMode>RGB</ControlMode>
|
||||
<FixtureGroup>8</FixtureGroup>
|
||||
</Function>
|
||||
<Function ID="69" Type="EFX" Name="Movers wander">
|
||||
<Fixture>
|
||||
<ID>17</ID>
|
||||
<Head>0</Head>
|
||||
<Mode>0</Mode>
|
||||
<Direction>Forward</Direction>
|
||||
<StartOffset>0</StartOffset>
|
||||
</Fixture>
|
||||
<Fixture>
|
||||
<ID>8</ID>
|
||||
<Head>0</Head>
|
||||
<Mode>0</Mode>
|
||||
<Direction>Forward</Direction>
|
||||
<StartOffset>90</StartOffset>
|
||||
</Fixture>
|
||||
<Fixture>
|
||||
<ID>9</ID>
|
||||
<Head>0</Head>
|
||||
<Mode>0</Mode>
|
||||
<Direction>Forward</Direction>
|
||||
<StartOffset>180</StartOffset>
|
||||
</Fixture>
|
||||
<Fixture>
|
||||
<ID>18</ID>
|
||||
<Head>0</Head>
|
||||
<Mode>0</Mode>
|
||||
<Direction>Forward</Direction>
|
||||
<StartOffset>270</StartOffset>
|
||||
</Fixture>
|
||||
<PropagationMode>Parallel</PropagationMode>
|
||||
<Speed FadeIn="2000" FadeOut="0" Duration="24000"/>
|
||||
<Direction>Forward</Direction>
|
||||
<RunOrder>Loop</RunOrder>
|
||||
<Algorithm>Lissajous</Algorithm>
|
||||
<Width>14</Width>
|
||||
<Height>10</Height>
|
||||
<Rotation>0</Rotation>
|
||||
<StartOffset>0</StartOffset>
|
||||
<IsRelative>1</IsRelative>
|
||||
<Axis Name="X">
|
||||
<Offset>127</Offset>
|
||||
<Frequency>3</Frequency>
|
||||
<Phase>90</Phase>
|
||||
</Axis>
|
||||
<Axis Name="Y">
|
||||
<Offset>127</Offset>
|
||||
<Frequency>2</Frequency>
|
||||
<Phase>0</Phase>
|
||||
</Axis>
|
||||
</Function>
|
||||
</Engine>
|
||||
<VirtualConsole>
|
||||
<Frame Caption="">
|
||||
@@ -2597,6 +2647,20 @@
|
||||
<Intensity Adjust="False">100</Intensity>
|
||||
<Input Universe="1" Channel="37084"/>
|
||||
</Button>
|
||||
<Button Caption="Wander" ID="112" Icon="">
|
||||
<WindowState Visible="True" X="100" Y="100" Width="90" Height="90"/>
|
||||
<Appearance>
|
||||
<FrameStyle>None</FrameStyle>
|
||||
<ForegroundColor>Default</ForegroundColor>
|
||||
<BackgroundColor>Default</BackgroundColor>
|
||||
<BackgroundImage>None</BackgroundImage>
|
||||
<Font>Default</Font>
|
||||
</Appearance>
|
||||
<Function ID="69"/>
|
||||
<Action>Toggle</Action>
|
||||
<Intensity Adjust="False">100</Intensity>
|
||||
<Input Universe="1" Channel="37085"/>
|
||||
</Button>
|
||||
<Slider Caption="Peak" ID="91" WidgetStyle="Slider" InvertedAppearance="false">
|
||||
<WindowState Visible="True" X="380" Y="10" Width="52" Height="360"/>
|
||||
<Appearance>
|
||||
|
||||
@@ -186,6 +186,25 @@ class PlayLayerTest(unittest.TestCase):
|
||||
def test_reopen_with_no_colours_only_resets_the_submaster(self):
|
||||
self.assertEqual(PlayLayer().reopen(), [[0xB0, 100, 127]])
|
||||
|
||||
def test_wander_off_settles_pan_and_tilt(self):
|
||||
layer = PlayLayer()
|
||||
self.assertEqual(layer.handle([0xB0, 38, 40]), [[0xB0, 38, 40]])
|
||||
layer.handle([0xB0, 39, 0])
|
||||
layer.handle(PAUSE_DOWN)
|
||||
self.assertEqual(layer.handle([0x99, 45, 100]), [[0x99, 93, 100]])
|
||||
layer.handle([0x89, 45, 0])
|
||||
self.assertEqual((layer.wander, layer.settle), (True, False))
|
||||
layer.handle([0x99, 45, 100])
|
||||
self.assertEqual((layer.wander, layer.settle), (False, True))
|
||||
self.assertEqual(layer.nudge(), [[0xB0, 38, 39], [0xB0, 39, 1]])
|
||||
self.assertEqual(layer.positions(), [[0xB0, 38, 40], [0xB0, 39, 0]])
|
||||
|
||||
def test_strobe_2_on_the_cans_layer_is_not_wander(self):
|
||||
layer = PlayLayer()
|
||||
layer.handle([0x99, 45, 100])
|
||||
layer.handle([0x99, 45, 100])
|
||||
self.assertEqual((layer.wander, layer.settle), (False, False))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user