Compare commits

...
10 Commits
Author SHA1 Message Date
jimmyandClaude Opus 5.5 72425159b5 Add a gig show: the test show sending Art-Net to the rig.
shows/gig.qxw is shows/test.qxw with its one output changed from 127.0.0.1
to the Art-Net node at 192.168.1.175, sent from the laptop's gig address
192.168.1.143 as cabaret.qxw does (scripts/shows/make_gig.py; run it again
after changing the test show). The test show stays on the simulator.
draw_test_pads.py takes a show's name, and shows/gig-pads.png is its pad
layout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 15:45:51 +13:00
jimmyandClaude Opus 5.5 873502b3ca Say on the pad layout how to reach each bank and layer.
Each panel's subtitle gives the buttons: PAD BANK and KNOB BANK pick the
banks, Pause puts pad bank 1 on the movers, and holding Play moves pad bank 2
to Colour 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 15:42:48 +13:00
jimmyandClaude Opus 5.5 9ebe3a5af1 Draw the test show's pad layout.
shows/test-pads.png shows both banks of pads on every layer (bank 1 on the
cans and, with Pause, the movers; bank 2 as Colour 1 and, with Play held,
Colour 2) and what each knob does. scripts/shows/draw_test_pads.py reads the
labels and colours from the show's virtual console, so running it again
brings the picture up to date.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 15:38:24 +13:00
jimmyandClaude Opus 5.5 c71b6da9d9 Rearrange the test show's console and square off its colour buttons.
The layout, chase colours, mover speeds and levels as saved from QLC+: the
colour frames stacked on the left with the cans and movers pads beside them.
The Colour 1 and Colour 2 buttons are 75 px squares, and the Chase runs and
Pads layer frames below Colour 2 move down to clear them
(scripts/shows/square_colours.py). The Movers speed dial comes in from
x=1820 to beside Movers position, and both speed dials are trimmed to the
dial and its time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 15:38:24 +13:00
jimmyandClaude Opus 5.5 c7546e5ea9 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>
2026-10-23 15:09:49 +13:00
jimmyandClaude Opus 5.5 467b480c76 Put the pads on the cans or movers layer from Pause's value.
The SMC-PAD latches Pause itself: one message a press, 127 and 0 on
alternate presses, nothing on release. The pad controller flipped the layer
only on 127, so every second press did nothing. Bank 1 now follows the
value: 0 is the cans, 127 the movers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 15:09:47 +13:00
jimmyandClaude Opus 5.5 31ccbab340 Make a click on a cans chase button run the whole chase in the test show.
Each chase was two buttons on one pad note: the pads frame's ran the side
dimmer hold under Peak, and the Chase runs frame's ran the stripe outside it.
The pad pressed both; a click pressed only the hold, which lit nothing. Now
the pads frame's button runs a hold of the chase's own whose step is the Sides
dimmer and a Script that starts the stripe. Peak reaches the dimmer through the
chaser and collection but not the stripe through the script, as with the pad
(scripts/shows/chase_clicks.py). The Chase runs buttons no longer listen to the
pad.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 13:57:27 +13:00
jimmyandClaude Opus 5.5 cf94c7b1ba Press the colours again when a restarted QLC+ links itself to the pad controller.
The pad controller only took a QLC+ reload as one when it had to make the
link to QLC+ itself. A restarted QLC+ often subscribes to the virtual port on
its own as it opens the show, before the next check, so the colours stayed off.
Each check now also notes the QLC+ process and port it feeds (qlc_feeds), and a
new one counts as a reload too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 13:57:22 +13:00
jimmyandClaude Opus 5.5 4fd11445e8 Add cabaret's can patterns to the test show.
Eight of make_cabaret_vc.py's Can Patterns on the cans pads 1-8, in a Can
patterns solo frame in place of the pads frame's empty Buttons 53-60:
Theater, Rainbow, Odd Even, Left Right, Scanner (with a fading tail), Fill,
Center and Pairs, laid out for the test show's cans and walking the ring round
the room (scripts/shows/can_patterns.py). Collapse and Chase Out are left out.

The masks show the Colour 1 colour; Odd Even (a checkerboard) and Left Right
swap between Colour 1 and Colour 2 through four Matrix widgets in the Chase
colours frame. All of them follow the cans' Speed dial (knob 1). Each pattern is
RGB matrices running from start to stop (rgbscripts/steps.js and swap.js, linked
into ~/.qlcplus/rgbscripts), so a chase started over one lands on top, and the
pad controller restarts the pattern that is on just after a Colour 1 press so
the new colour scene doesn't cover it.

The row of 4 (#3-#6) never animates; CLAUDE.md now says so for whatever comes
next.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 13:57:13 +13:00
jimmyandClaude Opus 5.5 e7e1cf656b Remove the sound-reactive cans from the test show.
The Sound and Threshold audio triggers go, with the Sound submaster beside the
cans' Front and Back sliders (CC 100) and the Sound peak frame with its Peak
submaster and Hit button and the Cans hit functions only Hit ran. Pads 1 and 2
are plain spare buttons again (scripts/shows/drop_sound.py). The pads frame's
own Peak (knob 6) stays: it is the chases' peak.

The pad controller drops its side of it: the Pump and Threshold modes, the
CC 100 resets, holding the side knobs at the peak and the pad lamps that showed
which mode was on. Pads 1 and 2 and knobs 5, 6 and 8 pass straight through.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 13:57:00 +13:00
20 changed files with 6624 additions and 562 deletions

No files matched your search

+9
View File
@@ -37,6 +37,15 @@ the stage view, make sure the MIDI controller is working and the simulator is on
to 127.0.0.1 only, so testing drives the simulator and never the real rig. Keep
it that way; don't point it at a 192.168.1.x node.
## Cans 3–6 are always static
The row of 4 (#3–#6, fixture IDs 2–5) never animates. Chases, patterns, loops,
strobes and side dimmer holds leave them out, so they keep the Colour 1 scene
and their own dimmer knob whatever else runs. Their colour stays HTP, unlike the
other cans. When adding an animation for the cans, build it on the other 11
(the groups `Sides` and `Strobe cans` in test.qxw already skip them) and don't
write any FixtureVal for IDs 2–5.
Tell the user what was down and what you did about it. The preview
configurations in `.claude/launch.json` run separate copies on other ports
(8770, 8766) and don't count as the services being up.
+1
View File
@@ -7,6 +7,7 @@ QLC+ show files, fixture definitions, and generators for the XCHC stage
```
fixtures/ Fixture definitions (.qxf) — install into QLC+ if needed
rgbscripts/ RGB matrix scripts; scripts/shows/can_patterns.py links them into ~/.qlcplus/rgbscripts
shows/ Workspaces to open in QLC+
xchc.qxw Main show (patterns + movers, unified VC)
simple.qxw Manual board: M1/M2 pads, shared + individual RGBW
+44 -81
View File
@@ -4,32 +4,13 @@ The SMC-PAD sends CC 27 as 127 when Play goes down and 0 when it comes up.
While it is down, pad notes 52–67 go out as 68–83, so QLC+ can tell a
second set of buttons from the first. Play itself is not passed on.
Pause (CC 28) does the same for bank 1, but toggles: each press flips it.
Off, bank 1 pads 36–51 go out as they are, for the cans. On, they go out as
84–99, for the movers. Pause itself is not passed on. The movers are not
sound reactive, so Sound and Threshold (84 and 85) do nothing on their layer.
The Sound pad (note 36) toggles QLC+'s audio triggers, which pump the cans'
Sound submaster in the Dimmers frame. Every press and release also sends CC 100
at full, so switching sound off leaves the cans at full rather than wherever
the music left them.
The Threshold pad (note 37) toggles a second audio trigger, which flashes the
cans to full on bass hits. While it is on, CC 100 is held at 0 so the cans sit
dark between hits; switching it off puts the submaster back to full.
The two are exclusive: turning one on taps the other's note first when it is
on, so QLC+ switches it off.
Knob 6 (CC 35) is the sides' peak. It goes on to the Peak submasters, which
set how bright the Threshold hits, the chases and the strobe flash. While Sound is on,
it also holds both side sliders (knobs 5 and 8, CC 34 and 37) at its value, so
the bass pumps the sides up to it; turns of knobs 5 and 8 meanwhile are kept
and put back when Sound goes off.
pump and threshold follow the two pads' presses, so the pad controller can
light whichever is on. QLC+ sends no feedback for its audio triggers, so they
are only a guess; reopen() clears them, as QLC+ starts with both off.
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
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;
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
cans, 68–83 for the movers), or None once it is pressed again: the colour
@@ -43,7 +24,16 @@ 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.
EFX is on, from the presses: only a guess, as QLC+ sends no feedback for it.
The cans' pattern pads (pads 1–8 on the cans layer: notes 36–43) each toggle a
pattern, in a solo frame like the movement pads; pattern holds the note of the
one that is on. A Colour 1 pad starts a colour scene on the cans, and the
newest function wins their colour, so the scene would cover the pattern. While
a pattern is on, a Colour 1 press sets restart_pattern, and the caller sends
pattern_tap() twice a moment later, off and on again, so the pattern restarts on
top in the new colour. Taps sent with the colour itself land in the same QLC+
tick and change nothing.
"""
from __future__ import annotations
@@ -56,31 +46,28 @@ PAUSE_CC = 28
BANK_1_FIRST = 36
BANK_1_LAST = 51
MOVERS_SHIFT = 48 # bank 1 goes out as 84–99 while Pause is on, above bank 2's held layer
SOUND_NOTE = 36
THRESHOLD_NOTE = 37
SUBMASTER_CC = 100
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
PEAK_CC = 35 # knob 6
SIDE_CCS = (34, 37) # knobs 5 and 8: Cans 9–15 and Cans 1, 2, 7, 8
# 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)
POSITION_CCS = (38, 39) # knobs 9 and 10: the movers' Pan and Tilt
PATTERN_NOTES = range(36, 44) # the can patterns: pads 1–8 on the cans layer
class PlayLayer:
def __init__(self) -> None:
self.held = False
self.movers = False # Pause toggles bank 1 between the cans and the movers
self.movers = False # Pause latched on puts bank 1 on the movers
# (channel, note as pressed) -> note sent, so a release matches its press
self.sent: dict[tuple[int, int], int] = {}
self.pump = False
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.moving: int | None = None
self.settle = False # a relative EFX just went off: the caller sends nudge(), then positions()
self.pattern: int | None = None
self.pattern_channel = 0
self.restart_pattern = False # a Colour 1 press covered the pattern: the caller sends pattern_tap() twice
# set -> (channel, note sent) of the colour that is on
self.colours: dict[int, tuple[int, int] | None] = {1: None, 2: None}
@@ -93,14 +80,8 @@ class PlayLayer:
self.held = data[2] > 0
return []
if kind == 0xB0 and len(data) >= 3 and data[1] == PAUSE_CC:
if data[2] > 0:
self.movers = not self.movers
return []
if kind == 0xB0 and len(data) >= 3 and channel == KNOB_CHANNEL and data[1] in self.knobs:
self.knobs[data[1]] = data[2]
if data[1] == PEAK_CC:
return [list(data), *self.sides()]
return [] if self.pump else [list(data)]
self.movers = data[2] > 0
return self.layer_lamp()
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)]
@@ -114,36 +95,22 @@ class PlayLayer:
else:
out = self.sent.pop(key, data[1])
note = out
before: list[list[int]] = []
extra: list[list[int]] = []
if note == SOUND_NOTE:
if is_on:
if self.threshold:
before = tap(channel, THRESHOLD_NOTE)
self.threshold = False
self.pump = not self.pump
extra = self.sides(restore=not self.pump)
# Again on release, after any spectrum frame QLC+ still had queued
extra = [*extra, [0xB0, SUBMASTER_CC, 127]]
elif note == THRESHOLD_NOTE:
if is_on:
if self.pump:
before = tap(channel, SOUND_NOTE)
self.pump = False
extra = self.sides(restore=True)
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 RELATIVE_NOTES and is_on:
if note == self.moving:
self.moving = None
self.settle = True
else:
self.moving = note
elif note in PATTERN_NOTES and is_on:
self.pattern = None if note == self.pattern else note
self.pattern_channel = channel
elif FIRST_NOTE <= note <= LAST_NOTE and is_on and self.pattern is not None:
self.restart_pattern = True
if is_on and FIRST_NOTE <= out <= LAST_NOTE + SHIFT:
colour_set = 1 if out <= LAST_NOTE else 2
pressed = (channel, out)
self.colours[colour_set] = None if self.colours[colour_set] == pressed else pressed
return [*before, [status, out, *data[2:]], *extra]
return [[status, out, *data[2:]]]
def shifted(self, note: int) -> int:
"""The note a press goes out as: bank 2 up while Play is held, bank 1 up while Pause is on."""
@@ -154,27 +121,23 @@ class PlayLayer:
return note
def reopen(self) -> list[list[int]]:
"""QLC+ has loaded the show: everything is off. Press the colours that were on.
The Sound submaster goes back to full too, as sound is off.
"""
self.pump = False
self.threshold = False
"""QLC+ has loaded the show: everything is off. Press the colours that were on."""
self.moving = None
out = []
self.pattern = None
out = self.layer_lamp()
for colour in self.colours.values():
if colour is not None:
out += tap(*colour)
return out + [[0xB0, SUBMASTER_CC, 127]]
return out
def sides(self, restore: bool = False) -> list[list[int]]:
"""The side sliders at the peak while Sound is on, or back at their own knobs."""
if restore:
return [[0xB0 | KNOB_CHANNEL, cc, self.knobs[cc]] for cc in SIDE_CCS]
if not self.pump:
return []
return [[0xB0 | KNOB_CHANNEL, cc, self.knobs[PEAK_CC]] for cc in SIDE_CCS]
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]]:
"""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)
def nudge(self) -> list[list[int]]:
"""Pan and Tilt one step off their knobs, so QLC+ writes them again."""
+44 -54
View File
@@ -6,7 +6,6 @@ immediately, and eases Control Change values toward their targets at
On start it also sets the pad lamps over USB (scripts/pad/pad_lamps.py): bank 1 off and
bank 2 in the colours from shows/test.qxw. On Bluetooth it says so and carries on.
While it runs, the Pump and Threshold pads (notes 36 and 37) light while their mode is on.
While Play is held, bank 2 notes 52–67 go out as 68–83 (see padcontroller/layer.py).
Point QLC+ MIDI input at that virtual port (midi.qxw does this via
@@ -16,8 +15,12 @@ turns up) and re-links QLC+ to the virtual port after a restart, so QLC+ can sta
QLC+ reopens its MIDI port when it loads a show, so a new link to QLC+ while
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.
That is a link the pad controller had to make, or one QLC+ made itself: a
restarted QLC+ subscribes to the virtual port on its own as it opens the show,
before the next check, so a QLC+ process or port fed that wasn't at the last
check counts too (qlc_feeds). 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 one of the movers' movement pads goes off, SETTLE_DELAY later it
nudges the Pan and Tilt knobs a step and puts them back, so QLC+ drops
@@ -39,7 +42,6 @@ import os
import re
import subprocess
import sys
import threading
import time
from dataclasses import dataclass, field
from pathlib import Path
@@ -52,16 +54,17 @@ for p in glob.glob(str(ROOT / ".venv" / "lib" / "python*" / "site-packages")):
sys.path.insert(0, p)
import rtmidi
from padcontroller.layer import SUBMASTER_CC, 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.
sys.path.insert(0, str(ROOT / "scripts" / "pad"))
from pad_lamps import set_lamps, set_sound_lamps # noqa: E402
from pad_lamps import set_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 a relative EFX before the knob nudge, and between its two steps
RESTART_DELAY = 0.1 # s after a Colour 1 press before the can pattern's off tap, and between it and the on tap
# Bluetooth first when the pad is paired, USB otherwise.
SOURCE_HINTS = (
"SMC-PAD Bluetooth",
@@ -96,6 +99,7 @@ class AlsaPort:
addr: str # "client:port"
client: str
name: str
pid: str | None = None # the client's process, for user clients
to: set[str] = field(default_factory=set)
sources: set[str] = field(default_factory=set)
@@ -103,15 +107,15 @@ class AlsaPort:
def parse_aconnect(text: str) -> list[AlsaPort]:
"""The ports in `aconnect -l` output, with who they connect to and from."""
ports: list[AlsaPort] = []
client = client_name = None
client = client_name = pid = None
for line in text.splitlines():
m = re.match(r"client (\d+): '([^']+)'", line)
m = re.match(r"client (\d+): '([^']+)'(?:.*\bpid=(\d+))?", line)
if m:
client, client_name = m.group(1), m.group(2)
client, client_name, pid = m.groups()
continue
m = re.match(r"\s+(\d+)\s+'([^']+)'", line)
if m and client is not None:
ports.append(AlsaPort(f"{client}:{m.group(1)}", client_name, m.group(2).strip()))
ports.append(AlsaPort(f"{client}:{m.group(1)}", client_name, m.group(2).strip(), pid))
continue
m = re.match(r"\s+(Connecting To|Connected From):(.*)", line)
if m and ports:
@@ -140,20 +144,31 @@ def missing_links(ports: list[AlsaPort], src_name: str | None) -> list[tuple[str
return links
def ensure_links(src_name: str | None) -> bool:
"""Make the missing links. True when one of them is to QLC+."""
def qlc_feeds(ports: list[AlsaPort]) -> set[tuple[str | None, str]]:
"""(pid, address) of each QLC+ port the pad controller's output is linked to."""
ours_out = next((p for p in ports if p.client == "padcontroller-out"), None)
if ours_out is None:
return set()
return {(p.pid, p.addr) for p in ports if p.client == "qlcplus" and p.addr in ours_out.to}
def ensure_links(src_name: str | None) -> tuple[bool, set[tuple[str | None, str]]]:
"""Make the missing links. Whether one of them was to QLC+, and the QLC+ ports fed after."""
try:
out = subprocess.check_output(["aconnect", "-l"], text=True)
except (FileNotFoundError, subprocess.CalledProcessError):
return False
return False, set()
ports = parse_aconnect(out)
qlc = {p.addr for p in ports if p.client == "qlcplus"}
qlc = {p.addr: p.pid for p in ports if p.client == "qlcplus"}
fed = qlc_feeds(ports)
to_qlc = False
for src, dst in missing_links(ports, src_name):
if subprocess.run(["aconnect", src, dst], capture_output=True).returncode == 0:
print(f"Linked {src} -> {dst}", flush=True)
to_qlc = to_qlc or dst in qlc
return to_qlc
if dst in qlc:
to_qlc = True
fed.add((qlc[dst], dst))
return to_qlc, fed
def load_colours(layer: PlayLayer) -> None:
@@ -172,33 +187,6 @@ def save_colours(layer: PlayLayer) -> None:
print(f"Colours not saved: {exc}", flush=True)
class SoundLamps:
"""Show which sound pad is on, off the MIDI loop: each write takes ~60 ms."""
def __init__(self) -> None:
self.wanted: tuple[bool, bool] | None = None
self.wake = threading.Event()
threading.Thread(target=self._run, daemon=True).start()
def show(self, pump: bool, threshold: bool) -> None:
self.wanted = (pump, threshold)
self.wake.set()
def _run(self) -> None:
shown = None
while True:
self.wake.wait()
self.wake.clear()
wanted = self.wanted
if wanted is None or wanted == shown:
continue
try:
set_sound_lamps(*wanted)
shown = wanted
except (SystemExit, Exception) as exc: # no Private port on Bluetooth
print(f"Sound lamps not set: {exc}", flush=True)
def main() -> None:
ap = argparse.ArgumentParser(description=__doc__)
ap.add_argument(
@@ -236,11 +224,11 @@ def main() -> None:
print(f"Source: {src_name}", 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)
ensure_links(src_name)
sound_lamps = None
_, fed = ensure_links(src_name)
for out in layer.layer_lamp():
midiout.send_message(out)
if not args.no_lamps:
set_lamps()
sound_lamps = SoundLamps()
dt = 1.0 / args.rate
alpha = 1.0 - math.exp(-dt / max(args.tau, 1e-4))
@@ -262,8 +250,10 @@ def main() -> None:
else:
print("Source: (pad gone, waiting)", flush=True)
src_name = best_name
if ensure_links(src_name) and now >= reopen_from:
linked, now_fed = ensure_links(src_name)
if (linked or now_fed - fed) and now >= reopen_from:
reopen_at = now + REOPEN_DELAY
fed = now_fed
next_link_check = now + 2.0
if reopen_at is not None and now >= reopen_at:
@@ -271,9 +261,8 @@ def main() -> None:
taps = layer.reopen()
for out in taps:
midiout.send_message(out)
print(f"QLC+ reopened: pressed {sum(out[0] & 0xF0 == 0x90 for out in taps)} colour pad(s) again", flush=True)
if sound_lamps:
sound_lamps.show(layer.pump, layer.threshold)
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
while True:
@@ -285,7 +274,7 @@ def main() -> None:
continue
for out in layer.handle(list(data)):
cmd = out[0] & 0xF0
if cmd == 0xB0 and len(out) >= 3 and out[1] != SUBMASTER_CC:
if cmd == 0xB0 and len(out) >= 3:
# Control Change → smooth
key = (out[0] & 0x0F, out[1])
target[key] = float(out[2])
@@ -293,13 +282,14 @@ def main() -> None:
current[key] = float(out[2])
last_sent[key] = -1
else:
# Notes, aftertouch, PC, the Sound reset (always resent), etc. → immediate
# Notes, aftertouch, PC, etc. → immediate
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)]
if layer.restart_pattern:
layer.restart_pattern = False
later += [(now + RESTART_DELAY, layer.pattern_tap), (now + 2 * RESTART_DELAY, layer.pattern_tap)]
for due in [item for item in later if now >= item[0]]:
later.remove(due)
for out in due[1]():
+68
View File
@@ -0,0 +1,68 @@
/*
Steps: play the steps written in the "steps" property, one after another.
steps is the steps separated by ";", each the pixels' colours as rrggbb hex
separated by ",", left to right and then top to bottom. Missing pixels are
off. The matrix's own colour is not used.
shows/test.qxw's can patterns use it (scripts/shows/can_patterns.py): each is
one RGB matrix running for as long as the pattern does, so a chase started
after it lands on top, where a chaser of scenes would start a newer scene
every step. With a Mask blend, grey levels dim the colour under it.
QLC+ loads it from ~/.qlcplus/rgbscripts, where can_patterns.py links it.
*/
var testAlgo;
(
function()
{
var algo = new Object;
algo.apiVersion = 2;
algo.name = "Steps";
algo.author = "qlcplus shows";
algo.acceptColors = 0;
algo.properties = new Array();
algo.steps = [[0]];
algo.text = "000000";
algo.properties.push("name:steps|type:string|display:Steps|write:setSteps|read:getSteps");
algo.setSteps = function(_steps)
{
algo.text = _steps;
algo.steps = String(_steps).split(";").map(function(step) {
return step.split(",").map(function(hex) { return parseInt(hex, 16) || 0; });
});
};
algo.getSteps = function()
{
return algo.text;
};
algo.rgbMap = function(width, height, rgb, step)
{
var pixels = algo.steps[step % algo.steps.length];
var map = new Array(height);
for (var y = 0; y < height; y++)
{
map[y] = new Array(width);
for (var x = 0; x < width; x++)
{
var i = y * width + x;
map[y][x] = i < pixels.length ? pixels[i] : 0;
}
}
return map;
};
algo.rgbMapStepCount = function(width, height)
{
return algo.steps.length;
};
testAlgo = algo;
return algo;
}
)();
+45
View File
@@ -0,0 +1,45 @@
/*
Swap: every pixel in one colour, then every pixel in the other.
Two steps, all pixels lit with the step's colour. Give the RGB matrix a start
and an end colour and QLC+ hands step 0 the start colour and step 1 the end
colour, so the matrix swaps between them; with a fade in it crossfades.
shows/test.qxw's Odd Even and Left Right cans patterns use it, two matrices
at once with their colours the other way round (scripts/shows/can_patterns.py).
QLC+ loads it from ~/.qlcplus/rgbscripts, where can_patterns.py links it.
*/
var testAlgo;
(
function()
{
var algo = new Object;
algo.apiVersion = 2;
algo.name = "Swap";
algo.author = "qlcplus shows";
algo.acceptColors = 2;
algo.properties = new Array();
algo.rgbMap = function(width, height, rgb, step)
{
var map = new Array(height);
for (var y = 0; y < height; y++)
{
map[y] = new Array(width);
for (var x = 0; x < width; x++)
map[y][x] = rgb;
}
return map;
};
algo.rgbMapStepCount = function(width, height)
{
return 2;
};
testAlgo = algo;
return algo;
}
)();
-39
View File
@@ -28,44 +28,5 @@ def set_lamps() -> None:
print(f"Lamps not set: {exc}", flush=True)
# Bank 1 pads 1 and 2 (notes 36 and 37), lit while their sound mode is on.
PUMP_RGB = (0, 255, 0)
THRESHOLD_RGB = (255, 120, 0)
def set_sound_lamps(pump: bool, threshold: bool) -> None:
"""Light the Pump and Threshold pads while their mode is on, without saving.
Writes only the pad's running copy, so the stored preset (bank 1 off) comes
back on a power cycle. Needs the USB Private port; raises when it is missing.
"""
sys.path.insert(0, str(ROOT))
sys.path.insert(0, str(ROOT / "scripts" / "pad"))
import pad_colours
import rtmidi
from padcontroller.device import transact
from padcontroller.preset import scale
from padcontroller.sysex import RAM, write_request
lamps = {0: PUMP_RGB if pump else (0, 0, 0), 1: THRESHOLD_RGB if threshold else (0, 0, 0)}
midiout = rtmidi.MidiOut(rtapi=rtmidi.API_LINUX_ALSA)
midiin = rtmidi.MidiIn(rtapi=rtmidi.API_LINUX_ALSA)
try:
# Free both clients when the Private port is missing too, or every
# sound pad press on Bluetooth leaks two and fills the sequencer.
index = midiout.get_ports().index(pad_colours.private_port(midiout.get_ports()))
midiin.open_port(index)
midiin.ignore_types(sysex=False, timing=True, active_sense=True)
midiout.open_port(index)
for base in pad_colours.bank_bases(1):
for pad, rgb in lamps.items():
address = RAM + base + pad * pad_colours.RECORD + pad_colours.RGB_AT
transact(midiout, midiin, write_request(address, bytes(scale(c) for c in rgb)))
finally:
for port in (midiout, midiin):
port.close_port()
port.delete()
if __name__ == "__main__":
set_lamps()
+363
View File
@@ -0,0 +1,363 @@
#!/usr/bin/env python3
"""Add cabaret's can patterns to shows/test.qxw, on the cans pads 1–8.
Eight of make_cabaret_vc.py's Can Patterns, laid out for the test show's
test show's cans instead of cabaret's 8. The row of 4 (#3–#6) is always
static (see CLAUDE.md): the patterns leave it out, so it keeps the Colour 1
colour whatever runs. Where cabaret walks its U (#1, #2, the row of 4, #7, #8),
these walk the other 11 cans round the room: #1, #2, #9, #11, #13, #14, #15,
#12, #10, #7, #8.
Most are masks over the Colour 1 colour (the cans' own), so they show whatever
colour is on:
40 Scanner pad 5 one can at a time round the ring, two fading behind it
41 Fill pad 6 the ring fills up and empties again
42 Center pad 7 out from the middle of the room to the back wall, and back in
43 Pairs pad 8 mirrored pairs, outside in and back out
36 Theater pad 1 every third can round the ring
Rainbow brings its own colours, as in cabaret:
37 Rainbow pad 2 a rainbow turning slowly round the ring
Where cabaret's Odd Even and Left Right trade blue and red, these trade the
Colour 1 and Colour 2 colours:
38 Odd Even pad 3 a checkerboard: alternate cans front to back down each
side, and opposite across the room, every can swapping
39 Left Right pad 4 Colour 1 on the left and Colour 2 on the right, swapping
Each is two RGB matrices with the rgbscripts/swap.js script, one per half of
the cans, swapping between the two colours the other way round. Four Matrix
widgets in the collapsed Chase colours frame give them their start and end
colours from the Colour 1 and Colour 2 pads, as the chases get theirs from
Colour 2.
The rest are RGB matrices too, with the rgbscripts/steps.js script playing
their steps, so each pattern runs as the same few functions from start to stop
and a chase started while it runs lands on top of it. (A chaser of scenes would
start a newer scene every step: newer than the chase, so a mask step would
blank the chase and a colour step cover it.) A mask pattern is a pair of Mask
matrices, one on red, green and blue and one on white, so the white in Warm,
White and Cool is masked too; Rainbow and the swaps run Can no white beside
them to take the Colour 1 white off the animated cans. For the same reason a
Colour 1 scene started after a pattern would cover it, so padcontroller/layer.py
restarts the pattern that is on just after a Colour 1 press. Both scripts are
linked into ~/.qlcplus/rgbscripts, where QLC+ looks.
All of them follow the cans' Speed dial (knob 1, CC 30) like the chases. The
dial scales its time by powers of 2, so their fades and step times are its
200 ms default times 1, 2, 4, 8 or 16, the nearest to cabaret's:
Scanner, Theater 0.4 s a step (cabaret 0.4 s)
Fill, Center 0.2 s fade + 0.2 s (0.2 s + 0.3 s)
Pairs 0.2 s fade + 0.6 s (0.2 s + 0.4 s)
Rainbow 1.6 s fade + 1.6 s (2 s + 0.5 s)
Odd Even, Left 1.6 s fade + 1.6 s (3 s + 1 s)
Right
Cabaret's Collapse and Chase Out, which only replay Center's and Scanner's
steps with a dark one after, are left out.
They only set the cans' red, green, blue and white, so the Front, Back and
Middle knobs still set how bright they are. They take the empty buttons of the
pads frame (Buttons 53–60), beside the chases, in a Can patterns solo frame
so only one runs at a time. Like the chases they sit under the pads frame's
Peak (CC 35). #14 gets its colour forced LTP, as the other animated cans
already have, so the colour patterns cover the Colour 1 scene there too.
python3 scripts/shows/can_patterns.py
Run it once; it stops if the patterns are already there. QLC+ has to reopen the
show to see them.
"""
from __future__ import annotations
import json
import math
import re
from pathlib import Path
from mover_bank import NO_FUNCTION, NOTE_BASE, ROOT, appearance, button
SHOW = ROOT / "shows" / "test.qxw"
STAGE = ROOT / "stage" / "map.json"
# Can name -> fixture ID in test.qxw
CANS = {f"#{n}": n - 1 for n in range(1, 9)} | {f"#{n}": n + 1 for n in range(9, 16)}
STATIC = ("#3", "#4", "#5", "#6") # the row of 4 never animates
ANIMATED = {n: fid for n, fid in CANS.items() if n not in STATIC}
RING = ("#1", "#2", "#9", "#11", "#13", "#14", "#15", "#12", "#10", "#7", "#8")
HTP_COLOUR = ("#14",)
F_FIRST = 80
SIZE = 90
# Note -> the empty pads frame button on that pad
EMPTY_BUTTONS = {36: 57, 37: 58, 38: 59, 39: 60, 40: 53, 41: 54, 42: 55, 43: 56}
# make_cabaret_vc.py's colours
RAINBOW_RGB = [(255, 0, 0), (255, 127, 0), (255, 255, 0), (0, 255, 0),
(0, 255, 255), (0, 0, 255), (127, 0, 255), (255, 0, 255)]
GROUP_ODD, GROUP_EVEN, GROUP_LEFT, GROUP_RIGHT, GROUP_RING = 9, 10, 11, 12, 13
SCRIPTS = (ROOT / "rgbscripts" / "swap.js", ROOT / "rgbscripts" / "steps.js")
USER_SCRIPTS = Path.home() / ".qlcplus" / "rgbscripts"
CYAN, BLUE = 4278255615, 4278190335 # the chases' starting colour; Colour 2 Blue
COLOUR_2_NOTE, COLOUR_1_NOTE = 68, 52 # first pad of each colour set
SPEED_DIAL = 111 # the cans' Speed dial, knob 1
SPEED_MS = 200 # its starting time
# Index into QLC+'s speed dial factors: (Not Sent), 0, 1/16, 1/8, 1/4, 1/2, 1, 2, 4, 8, 16
FACTORS = {SPEED_MS * 2 ** k: 6 + k for k in range(5)} # 1x to 16x
NOT_SENT = 0
SWAP_FADE_MS, SWAP_STEP_MS = 1600, 3200
SCANNER_TAIL = (110, 35) # mask levels of the cans one and two behind the lit one
def positions() -> dict[str, tuple[float, float]]:
fixtures = json.loads(STAGE.read_text())["fixtures"]
return {name: (f["x"], f["y"]) for name, f in fixtures.items() if name in ANIMATED}
def hex_rgb(rgb: tuple[int, int, int]) -> str:
return "%02x%02x%02x" % rgb
def steps_matrix(fid: int, name: str, steps: list[list[tuple[int, int, int]]], fade_in: int, step_ms: int,
run_order: str = "Loop", mode: str = "RGB", blend: str = "Normal") -> str:
"""An RGB matrix on the ring group playing steps (each the ring's colours) with rgbscripts/steps.js."""
text = ";".join(",".join(hex_rgb(c) for c in step) for step in steps)
blend_attr = f' BlendMode="{blend}"' if blend != "Normal" else ""
return f''' <Function ID="{fid}" Type="RGBMatrix" Name="{name}"{blend_attr}>
<Speed FadeIn="{fade_in}" FadeOut="0" Duration="{step_ms}"/>
<Direction>Forward</Direction>
<RunOrder>{run_order}</RunOrder>
<Algorithm Type="Script">Steps</Algorithm>
<MonoColor>{CYAN}</MonoColor>
<ControlMode>{mode}</ControlMode>
<FixtureGroup>{GROUP_RING}</FixtureGroup>
<Property Name="steps" Value="{text}"/>
</Function>
'''
def group(gid: int, name: str, cans: list[str]) -> str:
heads = "\n".join(f' <Head X="{x}" Y="0" Fixture="{ANIMATED[n]}">0</Head>' for x, n in enumerate(cans))
return f''' <FixtureGroup ID="{gid}">
<Name>{name}</Name>
<Size X="{len(cans)}" Y="1"/>
{heads}
</FixtureGroup>
'''
def swap_matrix(fid: int, name: str, gid: int, start: int, end: int) -> str:
"""Every can in its group in the start colour, then the end colour, crossfading."""
return f''' <Function ID="{fid}" Type="RGBMatrix" Name="{name}">
<Speed FadeIn="{SWAP_FADE_MS}" FadeOut="1000" Duration="{SWAP_STEP_MS}"/>
<Direction>Forward</Direction>
<RunOrder>Loop</RunOrder>
<Algorithm Type="Script">Swap</Algorithm>
<MonoColor>{start}</MonoColor>
<EndColor>{end}</EndColor>
<ControlMode>RGB</ControlMode>
<FixtureGroup>{gid}</FixtureGroup>
</Function>
'''
def collection(fid: int, name: str, steps: list[int]) -> str:
rows = "\n".join(f' <Step Number="{i}">{s}</Step>' for i, s in enumerate(steps))
return f' <Function ID="{fid}" Type="Collection" Name="{name}">\n{rows}\n </Function>\n'
def rainbow_at(t: float) -> tuple[int, int, int]:
"""RAINBOW_RGB as a wheel, t from 0 to 8, blending between neighbours."""
i = math.floor(t) % 8
a, b = RAINBOW_RGB[i], RAINBOW_RGB[(i + 1) % 8]
w = t - math.floor(t)
return tuple(round(x + (y - x) * w) for x, y in zip(a, b))
def factor(ms: int) -> int:
"""The speed dial factor that gives ms at its starting time; 0 ms is left alone."""
if ms == 0:
return NOT_SENT
if ms not in FACTORS:
raise SystemExit(f"{ms} ms is not the Speed dial's {SPEED_MS} ms times 1, 2, 4, 8 or 16")
return FACTORS[ms]
def build() -> tuple[str, str, list[tuple[str, int, int]], list[tuple[str, int, int]], list[tuple[int, int, int]]]:
"""The groups, the functions, (caption, function ID, note) for each button in pad order,
(name, matrix ID, first note of its start colour's pads) for each swap matrix, and
(function ID, fade in, step time) for each function on the Speed dial."""
pos = positions()
fid = F_FIRST
blocks: list[str] = []
patterns: dict[str, int] = {}
speeds: list[tuple[int, int, int]] = []
def add(xml_for) -> int:
nonlocal fid
blocks.append(xml_for(fid))
fid += 1
return fid - 1
def add_pattern(caption: str, matrices: list[int], fade_in: int, step_ms: int) -> None:
speeds.extend((m, fade_in, step_ms) for m in matrices if m != no_white)
patterns[caption] = add(lambda f: collection(f, f"Can {caption}", matrices))
def add_mask(caption: str, levels: list[dict[str, int]], fade_in: int, hold: int, run_order: str = "Loop") -> None:
"""A mask pattern: each step the ring's levels, 255 keeping the colour under it and 0 a hole."""
steps = [[(lv.get(n, 0),) * 3 for n in RING] for lv in levels]
rgb = add(lambda f: steps_matrix(f, f"Can {caption}", steps, fade_in, fade_in + hold, run_order, "RGB", "Mask"))
white = add(lambda f: steps_matrix(f, f"Can {caption} white", steps, fade_in, fade_in + hold, run_order,
"White", "Mask"))
add_pattern(caption, [rgb, white], fade_in, fade_in + hold)
no_white = add(lambda f: steps_matrix(f, "Can no white", [[(0, 0, 0)] * len(RING)], 0, 1000, mode="White"))
rainbow = [[rainbow_at(i * 8 / len(RING) + s) for i in range(len(RING))] for s in range(8)]
add_pattern("Rainbow", [add(lambda f: steps_matrix(f, "Can Rainbow", rainbow, 1600, 3200)), no_white], 1600, 3200)
# Odd Even and Left Right: one swap matrix per half, Colour 1 first on one and Colour 2 first on the other.
left = {n for n in ANIMATED if pos[n][0] <= 0} # #14, in the middle of the back wall, goes left
rows = sorted({y for _, y in pos.values()}, reverse=True) # front first
odd = [n for n in ANIMATED if (rows.index(pos[n][1]) + (n not in left)) % 2 == 0]
halves = {"Odd Even": ((GROUP_ODD, "Cans odd", odd), (GROUP_EVEN, "Cans even", [n for n in ANIMATED if n not in odd])),
"Left Right": ((GROUP_LEFT, "Cans left", sorted(left, key=RING.index)),
(GROUP_RIGHT, "Cans right", [n for n in RING if n not in left]))}
groups = "".join(group(gid, name, cans) for pair in halves.values() for gid, name, cans in pair)
swaps = []
for caption, ((gid_a, name_a, _), (gid_b, name_b, _)) in halves.items():
a = add(lambda f: swap_matrix(f, f"Can {caption} {name_a[5:]}", gid_a, CYAN, BLUE))
b = add(lambda f: swap_matrix(f, f"Can {caption} {name_b[5:]}", gid_b, BLUE, CYAN))
swaps += [(f"{caption} {name_a[5:]}", a, COLOUR_1_NOTE), (f"{caption} {name_b[5:]}", b, COLOUR_2_NOTE)]
add_pattern(caption, [a, b, no_white], SWAP_FADE_MS, SWAP_STEP_MS)
groups += group(GROUP_RING, "Cans ring", list(RING))
def scanner_step(i: int) -> dict[str, int]:
"""The can at i lit, and the tail behind it round the ring."""
return {RING[(i - k) % len(RING)]: level for k, level in enumerate((255, *SCANNER_TAIL))}
add_mask("Scanner", [scanner_step(i) for i in range(len(RING))], 0, 400)
add_mask("Fill", [dict.fromkeys(RING[:k], 255) for k in range(1, len(RING) + 1)], 200, 200, "PingPong")
# Rings out from the middle of the room, nearest first; the back wall comes in last.
rings = [{"#2", "#7", "#9", "#10"}, {"#1", "#8"}, set(ANIMATED)]
assert set().union(*rings) == set(ANIMATED)
center, lit = [], set()
for ring in rings:
lit |= ring
center.append(dict.fromkeys(lit, 255))
add_mask("Center", center, 200, 200, "PingPong")
# Mirrored pairs, furthest from the middle first; #14 goes with the back corners.
pairs = sorted(({n, m} for n in ANIMATED for m in ANIMATED
if pos[n][0] < 0 and pos[m][0] == -pos[n][0] and pos[m][1] == pos[n][1]),
key=lambda p: -math.hypot(*pos[min(p)]))
pairs[0] |= {"#14"}
add_mask("Pairs", [dict.fromkeys(p, 255) for p in pairs], 200, 600, "PingPong")
add_mask("Theater", [{n: 255 for i, n in enumerate(RING) if i % 3 == s} for s in range(3)], 0, 400)
order = [("Theater", 36), ("Rainbow", 37), ("Odd Even", 38), ("Left Right", 39),
("Scanner", 40), ("Fill", 41), ("Center", 42), ("Pairs", 43)]
return groups, "".join(blocks), [(caption, patterns[caption], note) for caption, note in order], swaps, speeds
def solo_frame(wid: int, x: int, y: int, buttons: str) -> str:
indent = " "
return (f'{indent}<SoloFrame Caption="Can patterns" ID="{wid}">\n'
+ appearance(indent + " ")
+ f'{indent} <WindowState Visible="True" X="{x}" Y="{y}" Width="{4 * SIZE}" Height="{2 * SIZE}"/>\n'
f'{indent} <AllowChildren>True</AllowChildren>\n{indent} <AllowResize>True</AllowResize>\n'
f'{indent} <ShowHeader>False</ShowHeader>\n{indent} <ShowEnableButton>False</ShowEnableButton>\n'
f'{indent} <Mixing>False</Mixing>\n{indent} <Collapsed>False</Collapsed>\n{indent} <Disabled>False</Disabled>\n'
f'{buttons}{indent}</SoloFrame>\n')
def colour_matrix(xml: str, wid: int, caption: str, fid: int, start_note: int, x: int, y: int) -> str:
"""A copy of the chases' Forward colour widget for a swap matrix: its start colour from the pads
from start_note, its end colour from the other colour set's."""
m = re.search(r' <Matrix Caption="Forward colour" ID="61">.*? </Matrix>\n', xml, re.S).group(0)
head = m[:m.index(" <Control ")]
head = head.replace('Caption="Forward colour" ID="61"', f'Caption="{caption}" ID="{wid}"')
head = head.replace('<Function ID="43" InstantApply', f'<Function ID="{fid}" InstantApply')
head = re.sub(r'X="\d+" Y="\d+" Width', f'X="{x}" Y="{y}" Width', head, count=1)
colours = re.findall(r'<Color>(#[0-9a-f]{6})</Color>', m)
end_note = COLOUR_1_NOTE if start_note == COLOUR_2_NOTE else COLOUR_2_NOTE
controls = "".join(
f' <Control ID="{k * 16 + i + 1}">\n <Type>{kind}</Type>\n <Color>{c}</Color>\n'
f' <Input Universe="1" Channel="{NOTE_BASE + note + i}"/>\n </Control>\n'
for k, (kind, note) in enumerate((("StartColor", start_note), ("EndColor", end_note)))
for i, c in enumerate(colours))
return head + controls + " </Matrix>\n"
def link_scripts() -> None:
USER_SCRIPTS.mkdir(parents=True, exist_ok=True)
for script in SCRIPTS:
link = USER_SCRIPTS / script.name
if not link.is_symlink() or link.resolve() != script:
link.unlink(missing_ok=True)
link.symlink_to(script)
def main() -> None:
xml = SHOW.read_text()
if "Can Scanner" in xml or "Can Rainbow" in xml:
raise SystemExit(f"{SHOW.relative_to(ROOT)} already has the can patterns")
groups, functions, specs, swaps, speeds = build()
used = {int(i) for i in re.findall(r'<Function ID="(\d+)" Type', xml)}
if used & set(range(F_FIRST, F_FIRST + functions.count("<Function "))):
raise SystemExit(f"Function IDs from {F_FIRST} are taken")
taken = {int(i) for i in re.findall(r'<Input Universe="1" Channel="(\d+)"', xml)}
if taken & {NOTE_BASE + n for _, _, n in specs}:
raise SystemExit("Some of the free cans pads are taken")
# Buttons 53–60 are the bottom two rows of the pads frame; a solo frame takes their place.
empty = re.search(r' <Button Caption="Button 53" ID="53".*? <Button Caption="Button 60" ID="60".*? </Button>\n',
xml, re.S)
if empty is None or "<Input" in empty.group(0) or empty.group(0).count("<Button ") != 8:
raise SystemExit("Buttons 53–60 are not the empty rows they were")
spots = {int(w): (int(x), int(y)) for w, x, y in re.findall(
r'<Button Caption="Button (\d+)" ID="\d+" Icon="">\n <WindowState Visible="True" X="(\d+)" Y="(\d+)"',
empty.group(0))}
left, top = min(x for x, _ in spots.values()), min(y for _, y in spots.values())
buttons = "".join(button(EMPTY_BUTTONS[note], caption, spots[EMPTY_BUTTONS[note]][0] - left,
spots[EMPTY_BUTTONS[note]][1] - top, SIZE, fid, NOTE_BASE + note, indent=" ")
for caption, fid, note in specs)
next_id = max(int(i) for i in re.findall(r' ID="(\d+)"', xml.split("<VirtualConsole>")[1])
if int(i) != NO_FUNCTION) + 1
xml = xml.replace(empty.group(0), solo_frame(next_id, left, top, buttons), 1)
# The swap matrices' colour widgets go under the Strobe 2 colour slider in the collapsed Chase colours frame.
strobe_slider = re.search(r' <Slider Caption="Strobe 2 colour" ID="105".*? </Slider>\n', xml, re.S).group(0)
widgets = "".join(colour_matrix(xml, next_id + 1 + k, f"{name} colour", fid, note, 10 + (k % 2) * 310, 735 + (k // 2) * 230)
for k, (name, fid, note) in enumerate(swaps))
xml = xml.replace(strobe_slider, strobe_slider + widgets, 1)
old = '<WindowState Visible="True" X="330" Y="910" Width="640" Height="740"/>'
if old not in xml:
raise SystemExit("Couldn't find the Chase colours frame at 740 high")
xml = xml.replace(old, old.replace('Height="740"', f'Height="{740 + 230 * ((len(swaps) + 1) // 2)}"'), 1)
for name in HTP_COLOUR:
xml, n = re.subn(rf"( <ID>{CANS[name]}</ID>\n <Name>{name}</Name>\n(?: .*\n)*? <ForcedHTP>1</ForcedHTP>\n)(?! <ForcedLTP>)",
r"\1 <ForcedLTP>2,3,4,5</ForcedLTP>\n", xml, count=1)
if n != 1:
raise SystemExit(f"Couldn't find {name}'s forced HTP strobe to put its colour LTP beside")
dial = re.search(rf' <SpeedDial Caption="Speed" ID="{SPEED_DIAL}">.*? </SpeedDial>\n', xml, re.S)
if dial is None or f"<Time>{SPEED_MS}</Time>" not in dial.group(0):
raise SystemExit(f"Couldn't find the Speed dial at {SPEED_MS} ms")
rows = "".join(f' <Function FadeIn="{factor(fade)}" FadeOut="{NOT_SENT}" Duration="{factor(step)}">{fid}</Function>\n'
for fid, fade, step in speeds)
xml = xml.replace(dial.group(0), dial.group(0).replace(" </SpeedDial>\n", rows + " </SpeedDial>\n"), 1)
xml = xml.replace(' <Function ID="0" Type="Scene"', groups + ' <Function ID="0" Type="Scene"', 1)
xml = xml.replace(" </Engine>", functions + " </Engine>", 1)
SHOW.write_text(xml)
link_scripts()
print(f"Added the can patterns to {SHOW.relative_to(ROOT)}")
if __name__ == "__main__":
main()
+106
View File
@@ -0,0 +1,106 @@
#!/usr/bin/env python3
"""Make a click on a chase button in shows/test.qxw do what its pad does.
Each cans chase was two buttons on one pad note: the pads frame's button runs
the side dimmer hold, under the frame's Peak (CC 35), and the Chase runs frame's
button runs the stripe matrix, outside it, so Peak caps the dimmers and not the
stripe's colour. The pad pressed both; a click pressed only the hold.
Now the pads frame's button runs a hold of the chase's own, which runs both.
Its one step is a collection of the Sides dimmer scene and a Script that starts
the stripe and waits. A chaser and a collection pass Peak on to what they run,
but a script doesn't, so the dimmers are capped and the stripe isn't, as with
the pad. QLC+ 4.12 stops what a script started when the script ends (it has no
stoponexit), so the script waits until the hold's step ends and the chaser stops
it; the stripe has run its course by then. The holds are on the Speed dial (knob
1) as the shared ones were. The Chase runs buttons no longer listen to the pad,
which would otherwise toggle the stripe straight back off; clicked, they still
run the stripe on its own.
python3 scripts/shows/chase_clicks.py
Run it once; it stops if the chases' own holds are already there. QLC+ has to
reopen the show to see it.
"""
from __future__ import annotations
import re
from mover_bank import ROOT
SHOW = ROOT / "shows" / "test.qxw"
SPEED_DIAL = 111 # the cans' Speed dial, knob 1
SIDES_DIMMER = 44 # the Sides dimmer scene the shared holds run
WAIT_MS = 3600000 # longer than any hold: the chaser stops the script first
# pads frame button, Chase runs button, collection, stripe matrix, shared hold
CHASES = (
("Chase forward", 45, 79, 46, 43, 45),
("Chase reverse", 46, 80, 48, 47, 45),
("Zigzag forward", 47, 81, 51, 49, 50),
("Opposing zigzag", 48, 82, 53, 52, 45),
)
def script(fid: int, name: str, start: int) -> str:
return f""" <Function ID="{fid}" Type="Script" Name="{name}">
<Speed FadeIn="0" FadeOut="0" Duration="0"/>
<Direction>Forward</Direction>
<RunOrder>SingleShot</RunOrder>
<Command>startfunction%3A{start}</Command>
<Command>wait%3A{WAIT_MS}</Command>
</Function>
"""
def main() -> None:
xml = SHOW.read_text()
if any(f'Name="{name} hold"' in xml for name, *_ in CHASES):
raise SystemExit(f"{SHOW.relative_to(ROOT)} already has the chases' own holds")
next_fid = max(int(i) for i in re.findall(r'<Function ID="(\d+)" Type', xml)) + 1
dial = re.search(rf' <SpeedDial Caption="Speed" ID="{SPEED_DIAL}">.*? </SpeedDial>\n', xml, re.S)
if dial is None:
raise SystemExit("Couldn't find the Speed dial")
new_dial = dial.group(0)
functions = ""
for k, (name, pad_button, run_button, coll, stripe, hold) in enumerate(CHASES):
sid, hid = next_fid + 2 * k, next_fid + 2 * k + 1
functions += script(sid, f"{name} start", stripe)
# The chase's own hold: the shared one, running the dimmer and the stripe's script.
shared = re.search(rf' <Function ID="{hold}" Type="Chaser" Name="[^"]*">\n.*? </Function>\n', xml, re.S).group(0)
if f">{SIDES_DIMMER}</Step>" not in shared:
raise SystemExit(f"Hold {hold} doesn't run the Sides dimmer")
own = re.sub(r'<Function ID="\d+" Type="Chaser" Name="[^"]*">',
f'<Function ID="{hid}" Type="Chaser" Name="{name} hold">', shared)
functions += own.replace(f">{SIDES_DIMMER}</Step>", f">{coll}</Step>")
row = re.search(rf' <Function FadeIn="\d+" FadeOut="\d+" Duration="\d+">{hold}</Function>\n', new_dial)
if row is None:
raise SystemExit(f"Hold {hold} isn't on the Speed dial")
new_dial = new_dial.replace(" </SpeedDial>\n", row.group(0).replace(f">{hold}<", f">{hid}<") + " </SpeedDial>\n")
old = re.search(rf' <Function ID="{coll}" Type="Collection" Name="{name}">\n.*? </Function>\n', xml, re.S)
if old is None or f">{stripe}</Step>" not in old.group(0) or f">{hold}</Step>" not in old.group(0):
raise SystemExit(f"The {name} collection is not the stripe and hold it was")
xml = xml.replace(old.group(0), f' <Function ID="{coll}" Type="Collection" Name="{name}">\n'
f' <Step Number="0">{SIDES_DIMMER}</Step>\n <Step Number="1">{sid}</Step>\n </Function>\n', 1)
btn = re.search(rf'<Button Caption="{name}" ID="{pad_button}" .*?</Button>', xml, re.S)
if btn is None or f'<Function ID="{hold}"/>' not in btn.group(0):
raise SystemExit(f"The {name} button doesn't run its hold")
xml = xml.replace(btn.group(0), btn.group(0).replace(f'<Function ID="{hold}"/>', f'<Function ID="{hid}"/>'), 1)
run = re.search(rf'<Button Caption="{name} run" ID="{run_button}" .*?</Button>', xml, re.S)
if run is None:
raise SystemExit(f"Couldn't find the {name} run button")
xml = xml.replace(run.group(0), re.sub(r'\n\s*<Input Universe="1" Channel="\d+"/>', "", run.group(0)), 1)
xml = xml.replace(dial.group(0), new_dial, 1)
xml = xml.replace(" </Engine>", functions + " </Engine>", 1)
SHOW.write_text(xml)
print(f"Chase buttons in {SHOW.relative_to(ROOT)} now run the whole chase")
if __name__ == "__main__":
main()
+188
View File
@@ -0,0 +1,188 @@
#!/usr/bin/env python3
"""Draw the SMC-PAD layout for shows/test.qxw as shows/test-pads.png, or another show's.
Every label and colour comes from the show's virtual console: a pad shows the
caption of the button on its note, and a colour pad that button's colour, so
running this again after changing the show brings the picture up to date.
Bank 1, Pause off notes 36–51 the cans layer
Bank 1, Pause on notes 84–99 the movers layer (padcontroller adds 48)
Bank 2 notes 52–67 Colour 1, the cans
Bank 2, Play held notes 68–83 Colour 2, the movers and the chases (adds 16)
Pad 1 is bottom left, as on the pad; knobs are laid out as in
shows/openmic-knobs.png. A knob shows the sliders and speed dials on its CC.
Each title says how to get there: the pad's PAD BANK and KNOB BANK buttons pick
the banks, Pause (CC 28) latches bank 1 onto the movers, and Play held moves
bank 2 to Colour 2.
python3 scripts/shows/draw_test_pads.py # shows/test.qxw -> shows/test-pads.png
python3 scripts/shows/draw_test_pads.py gig # shows/gig.qxw -> shows/gig-pads.png
It needs Inkscape to turn the drawing into a PNG.
"""
from __future__ import annotations
import html
import re
import subprocess
import sys
import tempfile
from pathlib import Path
from mover_bank import NOTE_BASE, ROOT
BG, PANEL, TEXT, MUTED, EDGE = "#1a1a1c", "#232327", "#f2f2f2", "#9a9aa4", "#3a3a42"
PAD_W, PAD_H, GAP = 150, 90, 10
KNOB_R, KNOB_DX, KNOB_DY = 40, 150, 130
KNOB_BANK_H = 70 + 2 * KNOB_R + 3 * KNOB_DY + 100 # with room for the bottom labels
# Function pads, by the frame their button is in: (fill, edge)
GROUPS = {"Can patterns": ("#3b2a55", "#b79cff"), "Movement": ("#14423f", "#6fe0d2")}
CHASE, STROBE = ("#1d3557", "#8fb8ff"), ("#4a4a50", "#ffffff")
# (title, how to get there on the pad, first note)
LAYERS = (
("Pad bank 1 · cans", "PAD BANK to bank 1, Pause off", 36),
("Pad bank 1 · movers", "PAD BANK to bank 1, Pause on", 84),
("Pad bank 2 · Colour 1", "PAD BANK to bank 2 · the cans", 52),
("Pad bank 2 · Colour 2", "PAD BANK to bank 2, hold Play · movers, chases", 68),
)
def argb(value: str) -> str | None:
"""#rrggbb from a QLC+ colour, or None for Default."""
return None if value == "Default" else "#%06x" % (int(value) & 0xFFFFFF)
def text_colour(fill: str) -> str:
r, g, b = (int(fill[i:i + 2], 16) for i in (1, 3, 5))
return "#111111" if 0.299 * r + 0.587 * g + 0.114 * b > 150 else TEXT
def buttons(vc: str) -> dict[int, tuple[str, str | None, str]]:
"""note -> (caption, background colour, the solo frame or frame it's in) for each button on a channel-10 note."""
out = {}
frames: list[tuple[int, str]] = [] # (position, caption) of each frame opening
for m in re.finditer(r'<(?:Solo)?Frame Caption="([^"]*)"', vc):
frames.append((m.start(), m.group(1)))
for m in re.finditer(r'<Button Caption="([^"]*)" ID="\d+" Icon="">(.*?)</Button>', vc, re.S):
inp = re.search(r'<Input Universe="1" Channel="(\d+)"/>', m.group(2))
if inp is None or not 0 <= int(inp.group(1)) - NOTE_BASE < 128:
continue
frame = max((f for f in frames if f[0] < m.start()), default=(0, ""))[1]
bg = re.search(r"<BackgroundColor>([^<]*)</BackgroundColor>", m.group(2))
out[int(inp.group(1)) - NOTE_BASE] = (html.unescape(m.group(1)), argb(bg.group(1)) if bg else None, frame)
return out
def knobs(vc: str) -> dict[int, list[str]]:
"""CC -> captions of the sliders and speed dials on it."""
out: dict[int, list[str]] = {}
for m in re.finditer(r'<(Slider|SpeedDial) Caption="([^"]*)" ID="\d+"(.*?)</\1>', vc, re.S):
inp = re.search(r'<Input Universe="1" Channel="(\d+)"/>', m.group(3))
if inp and int(inp.group(1)) < 128:
out.setdefault(int(inp.group(1)), []).append(html.unescape(m.group(2)))
return out
def wrap(caption: str) -> list[str]:
words, lines = caption.split(), [""]
for w in words:
if lines[-1] and len(lines[-1]) + 1 + len(w) > 11:
lines.append(w)
else:
lines[-1] = f"{lines[-1]} {w}".strip()
return lines
def pad(x: int, y: int, number: int, info: tuple[str, str | None, str] | None) -> str:
if info is None or info[0].startswith("Button "):
return (f'<rect x="{x}" y="{y}" width="{PAD_W}" height="{PAD_H}" rx="10" fill="none" stroke="{EDGE}" '
f'stroke-width="2" stroke-dasharray="6 6"/>'
f'<text x="{x + 10}" y="{y + 22}" class="num" style="fill:{MUTED}">{number}</text>')
caption, colour, frame = info
if colour:
fill, edge = colour, "#ffffff"
elif frame in GROUPS:
fill, edge = GROUPS[frame]
elif "Strobe" in caption:
fill, edge = STROBE
else:
fill, edge = CHASE
ink = text_colour(fill)
lines = wrap(caption)
first = y + PAD_H / 2 + 8 - (len(lines) - 1) * 12
label = "".join(f'<text x="{x + PAD_W / 2}" y="{first + i * 24}" class="label" style="fill:{ink}" '
f'text-anchor="middle">{html.escape(t)}</text>' for i, t in enumerate(lines))
return (f'<rect x="{x}" y="{y}" width="{PAD_W}" height="{PAD_H}" rx="10" fill="{fill}" stroke="{edge}" '
f'stroke-width="3"/><text x="{x + 10}" y="{y + 22}" class="num" style="fill:{ink}" opacity="0.7">{number}</text>'
+ label)
def grid(x: int, y: int, title: str, sub: str, base: int, info: dict, first_pad: int) -> str:
out = [f'<text x="{x}" y="{y}" class="title">{html.escape(title)}</text>',
f'<text x="{x}" y="{y + 30}" class="sub">{html.escape(sub)}</text>']
top = y + 55
for i in range(16):
col, row = i % 4, 3 - i // 4 # pad 1 bottom left
out.append(pad(x + col * (PAD_W + GAP), top + row * (PAD_H + GAP), first_pad + i, info.get(base + i)))
return "".join(out)
def knob_bank(x: int, y: int, bank: int, info: dict[int, list[str]]) -> str:
out = [f'<text x="{x}" y="{y}" class="title">Knob bank {bank}</text>',
f'<text x="{x}" y="{y + 30}" class="sub">KNOB BANK to bank {bank}</text>']
for i in range(8):
number = (bank - 1) * 8 + i + 1
cx, cy = x + KNOB_R + 20 + (i % 2) * KNOB_DX, y + 70 + KNOB_R + (3 - i // 2) * KNOB_DY
names = info.get(29 + number, [])
stroke = TEXT if names else EDGE
out.append(f'<circle cx="{cx}" cy="{cy}" r="{KNOB_R}" fill="{PANEL}" stroke="{stroke}" stroke-width="3"/>'
f'<text x="{cx}" y="{cy + 9}" class="knob" style="fill:{stroke}" text-anchor="middle">{number}</text>')
label = " / ".join(dict.fromkeys(names)) # Peak and Brightness share knob 15
if label:
out.append(f'<text x="{cx}" y="{cy + KNOB_R + 24}" class="small" text-anchor="middle">'
f'{html.escape(label)}</text>')
return "".join(out)
def main() -> None:
name = sys.argv[1] if len(sys.argv) > 1 else "test"
show, out = ROOT / "shows" / f"{name}.qxw", ROOT / "shows" / f"{name}-pads.png"
vc = show.read_text().split("<VirtualConsole>")[1]
info, knob_info = buttons(vc), knobs(vc)
panel_w = 4 * PAD_W + 3 * GAP
col2, col3 = 60 + panel_w + 70, 60 + 2 * (panel_w + 70)
row_h = 55 + 4 * PAD_H + 3 * GAP + 80
width, height = col3 + 2 * KNOB_DX + 60, max(60 + 2 * row_h, 70 + 2 * KNOB_BANK_H)
body = []
for k, (title, sub, base) in enumerate(LAYERS):
x, y = (60, col2)[k % 2], 70 + (k // 2) * row_h
body.append(grid(x, y, title, sub, base, info, 1 if base in (36, 84) else 17))
body += [knob_bank(col3, 70, 1, knob_info), knob_bank(col3, 70 + KNOB_BANK_H, 2, knob_info)]
svg = f'''<svg xmlns="http://www.w3.org/2000/svg" width="{width}" height="{height}" viewBox="0 0 {width} {height}">
<style>
text {{ font-family: "DejaVu Sans", sans-serif; fill: {TEXT}; }}
.title {{ font-size: 30px; font-weight: bold; }}
.sub {{ font-size: 20px; fill: {MUTED}; }}
.num {{ font-size: 15px; font-weight: bold; }}
.label {{ font-size: 19px; }}
.knob {{ font-size: 26px; font-weight: bold; }}
.small {{ font-size: 18px; }}
</style>
<rect width="100%" height="100%" fill="{BG}"/>
{"".join(body)}
</svg>
'''
with tempfile.TemporaryDirectory() as tmp:
src = Path(tmp) / "test-pads.svg"
src.write_text(svg)
subprocess.run(["inkscape", str(src), "--export-type=png", f"--export-filename={out}", "--export-dpi=96"],
check=True, capture_output=True)
print(f"Drew {out.relative_to(ROOT)} ({width}x{height})")
if __name__ == "__main__":
main()
+68
View File
@@ -0,0 +1,68 @@
#!/usr/bin/env python3
"""Take the sound-reactive cans out of shows/test.qxw.
Removes the Sound and Threshold audio triggers, the Sound submaster beside the
cans' Front and Back sliders (CC 100), and the Sound peak frame with its Peak
submaster and Hit button, with the Cans hit scene and chaser that only Hit ran.
The Pump and Threshold buttons on pads 1 and 2 (notes 36 and 37) were empty;
they go back to plain spare buttons like the rest of that row. The pads frame's
own Peak (CC 35) stays: it is the chases' peak.
padcontroller/layer.py drops its side of it in the same change: the two pads'
modes, the CC 100 resets and the pad lamps that showed which was on.
python3 scripts/shows/drop_sound.py
Run it once; it stops if the audio triggers are already gone. QLC+ has to
reopen the show to see it.
"""
from __future__ import annotations
import re
from mover_bank import ROOT
SHOW = ROOT / "shows" / "test.qxw"
SOUND_SLIDER_W = 55 # the Sound slider and the gap before it in the Cans frame
def cut(xml: str, pattern: str, what: str) -> str:
xml, n = re.subn(pattern, "", xml, count=1, flags=re.S)
if n != 1:
raise SystemExit(f"Couldn't find {what}")
return xml
def main() -> None:
xml = SHOW.read_text()
if "<AudioTriggers" not in xml:
raise SystemExit(f"{SHOW.relative_to(ROOT)} has no sound triggers left")
for caption in ("Sound", "Threshold"):
xml = cut(xml, rf' <AudioTriggers BarsNumber="\d+" Caption="{caption}" ID="\d+">\n.*? </AudioTriggers>\n',
f"the {caption} audio trigger")
xml = cut(xml, r' <Slider Caption="Sound" ID="66" .*? </Slider>\n', "the Sound submaster")
xml = cut(xml, r' <Frame Caption="Sound peak" ID="76">\n.*? </Frame>\n', "the Sound peak frame")
for fid, name in ((55, "Cans hit"), (56, "Cans hit 100 ms")):
xml = cut(xml, rf' <Function ID="{fid}" Type="\w+" Name="{name}">\n.*? </Function>\n', name)
# The Dimmers frame and its Cans frame lose the Sound slider's width.
for caption, wid, x, y, w, h in (("Dimmers", 68, 880, 15, 264, 250), ("Cans", 73, 70, 40, 165, 205)):
old = f'<WindowState Visible="True" X="{x}" Y="{y}" Width="{w}" Height="{h}"/>'
frame = re.search(rf'<Frame Caption="{caption}" ID="{wid}">\n(?:.*\n){{0,8}}?\s*{re.escape(old)}', xml)
if frame is None:
raise SystemExit(f"Couldn't find the {caption} frame at {w} wide")
xml = xml.replace(frame.group(0), frame.group(0).replace(f'Width="{w}"', f'Width="{w - SOUND_SLIDER_W}"'), 1)
for caption, wid in (("Pump", 57), ("Threshold", 58)):
old = f'<Button Caption="{caption}" ID="{wid}" Icon="">'
if old not in xml:
raise SystemExit(f"Couldn't find the {caption} button")
xml = xml.replace(old, f'<Button Caption="Button {wid}" ID="{wid}" Icon="">', 1)
SHOW.write_text(xml)
print(f"Took the sound pieces out of {SHOW.relative_to(ROOT)}")
if __name__ == "__main__":
main()
+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()
+42
View File
@@ -0,0 +1,42 @@
#!/usr/bin/env python3
"""Copy shows/test.qxw to shows/gig.qxw, sending Art-Net to the rig.
The test show sends Art-Net to 127.0.0.1 only, so it drives the simulator and
never the rig (see CLAUDE.md). The gig show is the same show sending from the
laptop's address on the gig network to the Art-Net node, as cabaret.qxw does.
Everything else, from the pads to the console, is the test show's, so run this
again after changing the test show.
python3 scripts/shows/make_gig.py
python3 scripts/shows/draw_test_pads.py gig # its pad layout picture
Don't open gig.qxw on a network where 192.168.1.175 is the real node unless
the rig should light up.
"""
from __future__ import annotations
from mover_bank import ROOT
TEST = ROOT / "shows" / "test.qxw"
GIG = ROOT / "shows" / "gig.qxw"
LAPTOP = "192.168.1.143" # the laptop's address on the gig network, as in cabaret.qxw
LINE = 1 # QLC+'s Art-Net line for it there
NODE = "192.168.1.175"
TEST_OUTPUT = ' <Output Plugin="ArtNet" UID="127.0.0.1" Line="4"/>\n'
GIG_OUTPUT = (f' <Output Plugin="ArtNet" UID="{LAPTOP}" Line="{LINE}">\n'
f' <PluginParameters outputIP="{NODE}" outputUni="0"/>\n'
' </Output>\n')
def main() -> None:
xml = TEST.read_text()
if xml.count(TEST_OUTPUT) != 1:
raise SystemExit(f"{TEST.relative_to(ROOT)} doesn't have its one Art-Net output to 127.0.0.1")
GIG.write_text(xml.replace(TEST_OUTPUT, GIG_OUTPUT, 1))
print(f"Copied {TEST.relative_to(ROOT)} to {GIG.relative_to(ROOT)}, sending Art-Net to {NODE}")
if __name__ == "__main__":
main()
+70
View File
@@ -0,0 +1,70 @@
#!/usr/bin/env python3
"""Make the Colour 1 and Colour 2 buttons in shows/test.qxw square.
They were 90 wide and 60 high on a 96 by 66 grid. Now they are 75 square on an
81 grid, which keeps the 4 by 4 layout and makes each frame 338 wide and 338
high. The collapsed Chase runs frame, which sat just under Colour 2, moves down
to stay under it, and the Pads layer frame under that moves down to clear it;
the rest of the console stays where it is.
python3 scripts/shows/square_colours.py
It stops if the buttons are already square. QLC+ has to reopen the show to
see it.
"""
from __future__ import annotations
import re
from mover_bank import ROOT
SHOW = ROOT / "shows" / "test.qxw"
FRAMES = ('<SoloFrame Caption="Colour 1" ID="0">', '<SoloFrame Caption="Colour 2" ID="22">')
SIZE, PITCH, MARGIN = 75, 81, 10
BOTTOM = 10 # below the last row
GAP = 5
COLLAPSED = 60 # room a collapsed frame takes, as the saved layout left it
# Below Colour 2, top to bottom: (caption, ID) of each frame pushed down to clear the one above
BELOW = (("Chase runs", 83), ("Pads layer", 129))
def main() -> None:
xml = SHOW.read_text()
for head in FRAMES:
start = xml.index(head)
end = xml.index("</SoloFrame>", start)
frame = xml[start:end]
spots = re.findall(r'( <WindowState Visible="True" X="(\d+)" Y="(\d+)" Width="(\d+)" Height="(\d+)"/>)', frame)
if len(spots) != 16:
raise SystemExit(f"{head} doesn't have its 16 buttons")
if all(w == h for _, _, _, w, h in spots):
raise SystemExit(f"The buttons in {head} are already square")
cols = sorted({int(x) for _, x, _, _, _ in spots})
rows = sorted({int(y) for _, _, y, _, _ in spots})
for line, x, y, _, _ in spots:
nx, ny = MARGIN + cols.index(int(x)) * PITCH, MARGIN + rows.index(int(y)) * PITCH
frame = frame.replace(line, f' <WindowState Visible="True" X="{nx}" Y="{ny}" Width="{SIZE}" Height="{SIZE}"/>', 1)
right = MARGIN + (len(cols) - 1) * PITCH + SIZE + MARGIN
bottom = MARGIN + (len(rows) - 1) * PITCH + SIZE + BOTTOM
frame = re.sub(r'( <WindowState Visible="True" X="\d+" Y="\d+") Width="\d+" Height="\d+"/>',
rf'\1 Width="{right}" Height="{bottom}"/>', frame, count=1)
xml = xml[:start] + frame + xml[end:]
# Push the frames under Colour 2 down to clear it, each under the last.
colour_2 = re.search(r'<SoloFrame Caption="Colour 2" ID="22">.*?<WindowState Visible="True" X="\d+" Y="(\d+)" '
r'Width="\d+" Height="(\d+)"/>', xml, re.S)
top = int(colour_2.group(1)) + int(colour_2.group(2)) + GAP
for caption, wid in BELOW:
m = re.search(rf'(<Frame Caption="{caption}" ID="{wid}">.*?<WindowState Visible="True" X="\d+" Y=")(\d+)'
rf'(" Width="\d+" Height=")(\d+)(".*?<Collapsed>)(\w+)', xml, re.S)
if m is None:
raise SystemExit(f"Couldn't find the {caption} frame")
y = max(int(m.group(2)), top)
xml = xml[:m.start(2)] + str(y) + xml[m.end(2):]
top = y + (COLLAPSED if m.group(6) == "True" else int(m.group(4))) + GAP
SHOW.write_text(xml)
print(f"Made the colour buttons in {SHOW.relative_to(ROOT)} square")
if __name__ == "__main__":
main()
Binary file not shown.

After

Width:  |  Height:  |  Size: 232 KiB

+4157
View File
File diff suppressed because it is too large. Load diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 232 KiB

+1268 -290
View File
File diff suppressed because it is too large. Load diff
+73 -97
View File
@@ -8,9 +8,11 @@ from padcontroller.layer import PlayLayer # noqa: E402
PLAY_DOWN = [0xB0, 27, 127]
PLAY_UP = [0xB0, 27, 0]
PAUSE_DOWN = [0xB0, 28, 127]
PAUSE_UP = [0xB0, 28, 0]
SIDES_FULL = [[0xB0, 34, 127], [0xB0, 37, 127]]
# The pad latches Pause: one message a press, 127 and 0 on alternate presses.
PAUSE_ON = [0xB0, 28, 127]
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):
@@ -47,88 +49,18 @@ class PlayLayerTest(unittest.TestCase):
layer.handle(PLAY_DOWN)
self.assertEqual(layer.handle([0x99, 55, 0]), [[0x99, 55, 0]])
def test_sound_pad_puts_the_submaster_back_to_full(self):
def test_pads_1_and_2_pass_straight_through(self):
layer = PlayLayer()
self.assertEqual(layer.handle([0x99, 36, 100]), [[0x99, 36, 100], *SIDES_FULL, [0xB0, 100, 127]])
self.assertEqual(layer.handle([0x89, 36, 0]), [[0x89, 36, 0], [0xB0, 100, 127]])
self.assertEqual(layer.handle([0x99, 36, 100]), [[0x99, 36, 100]])
self.assertEqual(layer.handle([0x89, 36, 0]), [[0x89, 36, 0]])
self.assertEqual(layer.handle([0x99, 37, 100]), [[0x99, 37, 100]])
def test_threshold_pad_holds_the_submaster_at_zero_while_on(self):
layer = PlayLayer()
self.assertEqual(layer.handle([0x99, 37, 100]), [[0x99, 37, 100], [0xB0, 100, 0]])
self.assertEqual(layer.handle([0x89, 37, 0]), [[0x89, 37, 0], [0xB0, 100, 0]])
self.assertEqual(layer.handle([0x99, 37, 100]), [[0x99, 37, 100], [0xB0, 100, 127]])
self.assertEqual(layer.handle([0x89, 37, 0]), [[0x89, 37, 0], [0xB0, 100, 127]])
def test_sound_pads_track_which_mode_is_on(self):
layer = PlayLayer()
layer.handle([0x99, 36, 100])
layer.handle([0x89, 36, 0])
self.assertEqual((layer.pump, layer.threshold), (True, False))
layer.handle([0x99, 36, 100])
layer.handle([0x99, 36, 0]) # note on at velocity 0 is a release
self.assertEqual((layer.pump, layer.threshold), (False, False))
def test_turning_threshold_on_switches_pump_off_first(self):
layer = PlayLayer()
layer.handle([0x99, 36, 100])
self.assertEqual(
layer.handle([0x99, 37, 100]),
[[0x99, 36, 127], [0x89, 36, 0], [0x99, 37, 100], *SIDES_FULL, [0xB0, 100, 0]],
)
self.assertEqual((layer.pump, layer.threshold), (False, True))
def test_turning_pump_on_switches_threshold_off_first(self):
layer = PlayLayer()
layer.handle([0x99, 37, 100])
self.assertEqual(
layer.handle([0x99, 36, 100]),
[[0x99, 37, 127], [0x89, 37, 0], [0x99, 36, 100], *SIDES_FULL, [0xB0, 100, 127]],
)
self.assertEqual((layer.pump, layer.threshold), (True, False))
def test_turning_a_mode_off_leaves_the_other_alone(self):
layer = PlayLayer()
layer.handle([0x99, 37, 100])
self.assertEqual(layer.handle([0x99, 37, 100]), [[0x99, 37, 100], [0xB0, 100, 127]])
self.assertEqual((layer.pump, layer.threshold), (False, False))
def test_peak_knob_goes_on_to_the_hits_submaster(self):
def test_peak_and_side_knobs_pass_straight_through(self):
layer = PlayLayer()
self.assertEqual(layer.handle([0xB0, 35, 60]), [[0xB0, 35, 60]])
def test_side_knobs_pass_through_while_sound_is_off(self):
layer = PlayLayer()
self.assertEqual(layer.handle([0xB0, 34, 90]), [[0xB0, 34, 90]])
layer.handle([0x99, 37, 100]) # Threshold keeps them: the submaster holds the sides dark
self.assertEqual(layer.handle([0xB0, 37, 80]), [[0xB0, 37, 80]])
def test_pump_holds_the_sides_at_the_peak(self):
layer = PlayLayer()
layer.handle([0xB0, 34, 90])
layer.handle([0xB0, 35, 60])
self.assertEqual(layer.handle([0x99, 36, 100]),
[[0x99, 36, 100], [0xB0, 34, 60], [0xB0, 37, 60], [0xB0, 100, 127]])
self.assertEqual(layer.handle([0xB0, 35, 40]), [[0xB0, 35, 40], [0xB0, 34, 40], [0xB0, 37, 40]])
self.assertEqual(layer.handle([0xB0, 37, 100]), []) # kept for later
def test_pump_off_puts_the_side_knobs_back(self):
layer = PlayLayer()
layer.handle([0xB0, 34, 90])
layer.handle([0xB0, 35, 60])
layer.handle([0x99, 36, 100])
layer.handle([0xB0, 37, 100])
self.assertEqual(layer.handle([0x99, 36, 100]),
[[0x99, 36, 100], [0xB0, 34, 90], [0xB0, 37, 100], [0xB0, 100, 127]])
def test_threshold_taking_over_from_pump_puts_the_side_knobs_back(self):
layer = PlayLayer()
layer.handle([0xB0, 34, 90])
layer.handle([0xB0, 35, 60])
layer.handle([0x99, 36, 100])
self.assertEqual(layer.handle([0x99, 37, 100]),
[[0x99, 36, 127], [0x89, 36, 0], [0x99, 37, 100],
[0xB0, 34, 90], [0xB0, 37, 127], [0xB0, 100, 0]])
def test_colours_remember_the_last_pad_in_each_set(self):
layer = PlayLayer()
layer.handle([0x99, 52, 100])
@@ -144,53 +76,62 @@ class PlayLayerTest(unittest.TestCase):
layer.handle([0x99, 52, 100])
self.assertEqual(layer.colours[1], None)
def test_reopen_presses_the_colours_again_and_clears_sound(self):
def test_reopen_presses_the_colours_again(self):
layer = PlayLayer()
layer.handle([0x99, 54, 100])
layer.handle(PLAY_DOWN)
layer.handle([0x99, 66, 100])
layer.handle(PLAY_UP)
layer.handle([0x99, 36, 100])
self.assertEqual(layer.reopen(), [[0x99, 54, 127], [0x89, 54, 0], [0x99, 82, 127], [0x89, 82, 0],
[0xB0, 100, 127]])
self.assertEqual((layer.pump, layer.threshold), (False, False))
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
def test_pause_toggles_bank_1_to_the_movers(self):
layer = PlayLayer()
self.assertEqual(layer.handle(PAUSE_DOWN), [])
self.assertEqual(layer.handle(PAUSE_UP), [])
self.assertEqual(layer.handle(PAUSE_ON), MOVERS_LIT)
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, 52, 100]), [[0x99, 52, 100]])
layer.handle(PAUSE_DOWN)
layer.handle(PAUSE_UP)
self.assertEqual(layer.handle(PAUSE_OFF), CANS_LIT)
self.assertEqual(layer.handle([0x99, 44, 100]), [[0x99, 44, 100]])
def test_sound_pads_do_nothing_on_the_movers_layer(self):
def test_pads_1_and_2_move_up_on_the_movers_layer(self):
layer = PlayLayer()
layer.handle(PAUSE_DOWN)
layer.handle(PAUSE_ON)
self.assertEqual(layer.handle([0x99, 36, 100]), [[0x99, 84, 100]])
self.assertEqual(layer.handle([0x89, 36, 0]), [[0x89, 84, 0]])
self.assertEqual(layer.handle([0x99, 37, 100]), [[0x99, 85, 100]])
self.assertEqual(layer.handle([0x89, 37, 0]), [[0x89, 85, 0]])
self.assertEqual((layer.pump, layer.threshold), (False, False))
def test_bank_1_release_matches_its_press_across_pause(self):
layer = PlayLayer()
layer.handle(PAUSE_DOWN)
layer.handle(PAUSE_ON)
layer.handle([0x99, 48, 100])
layer.handle(PAUSE_DOWN)
layer.handle(PAUSE_OFF)
self.assertEqual(layer.handle([0x89, 48, 0]), [[0x89, 96, 0]])
def test_reopen_with_no_colours_only_resets_the_submaster(self):
self.assertEqual(PlayLayer().reopen(), [[0xB0, 100, 127]])
def test_reopen_with_no_colours_only_lights_the_layer(self):
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):
layer = PlayLayer()
self.assertEqual(layer.handle(PAUSE_OFF), CANS_LIT) # already on the cans: stays there
self.assertFalse(layer.movers)
self.assertEqual(layer.handle(PAUSE_ON), MOVERS_LIT)
self.assertEqual(layer.handle(PAUSE_ON), MOVERS_LIT) # a repeat changes nothing
self.assertTrue(layer.movers)
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)
layer.handle(PAUSE_ON)
self.assertEqual(layer.handle([0x99, 48, 100]), [[0x99, 96, 100]])
layer.handle([0x89, 48, 0])
self.assertEqual((layer.moving, layer.settle), (96, False))
@@ -207,17 +148,52 @@ class PlayLayerTest(unittest.TestCase):
def test_ballyhoo_takes_over_from_wander_without_a_settle(self):
layer = PlayLayer()
layer.handle(PAUSE_DOWN)
layer.handle(PAUSE_ON)
layer.handle([0x99, 48, 100])
self.assertEqual(layer.handle([0x99, 49, 100]), [[0x99, 97, 100]])
self.assertEqual((layer.moving, layer.settle), (97, False))
layer.handle([0x99, 49, 100])
self.assertEqual((layer.moving, layer.settle), (None, True))
def test_colour_1_restarts_the_can_pattern_on_top(self):
layer = PlayLayer()
layer.handle([0x99, 40, 127])
self.assertEqual(layer.handle([0x99, 57, 127]), [[0x99, 57, 127]])
self.assertTrue(layer.restart_pattern)
self.assertEqual(layer.pattern_tap(), [[0x99, 40, 127], [0x89, 40, 0]])
self.assertEqual(layer.pattern, 40)
def test_colour_1_leaves_the_cans_alone_with_no_pattern(self):
layer = PlayLayer()
layer.handle([0x99, 36, 127])
layer.handle([0x99, 36, 127])
self.assertEqual(layer.handle([0x99, 57, 127]), [[0x99, 57, 127]])
self.assertFalse(layer.restart_pattern)
self.assertEqual(layer.pattern_tap(), [])
def test_a_new_pattern_takes_over_in_the_solo_frame(self):
layer = PlayLayer()
layer.handle([0x99, 40, 127])
layer.handle([0x99, 37, 127])
self.assertEqual(layer.pattern, 37)
def test_colour_2_does_not_restart_the_can_pattern(self):
layer = PlayLayer()
layer.handle([0x99, 43, 127])
layer.handle(PLAY_DOWN)
self.assertEqual(layer.handle([0x99, 57, 127]), [[0x99, 73, 127]])
self.assertFalse(layer.restart_pattern)
def test_pattern_pads_on_the_movers_layer_are_not_can_patterns(self):
layer = PlayLayer()
layer.handle(PAUSE_ON)
layer.handle([0x99, 42, 127])
self.assertIsNone(layer.pattern)
def test_every_movement_pad_settles_when_it_goes_off(self):
for pad_note, sent in ((51, 99), (44, 92), (47, 95), (40, 88)):
layer = PlayLayer()
layer.handle(PAUSE_DOWN)
layer.handle(PAUSE_ON)
self.assertEqual(layer.handle([0x99, pad_note, 100]), [[0x99, sent, 100]])
self.assertEqual((layer.moving, layer.settle), (sent, False))
layer.handle([0x99, pad_note, 100])
+21 -1
View File
@@ -8,7 +8,7 @@ from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT))
from padcontroller.midi import missing_links, parse_aconnect, pick_source # noqa: E402
from padcontroller.midi import missing_links, parse_aconnect, pick_source, qlc_feeds # noqa: E402
BOTH = [
"Midi Through:Midi Through Port-0 14:0",
@@ -71,3 +71,23 @@ def test_nothing_missing_when_linked():
text = ACONNECT.replace(" 0 'padcontroller '\n", " 0 'padcontroller '\n\tConnecting To: 131:0\n")
assert missing_links(parse_aconnect(text), "SINCO:SINCO SMC-PAD-Master 20:1") == []
assert missing_links(parse_aconnect(text), None) == []
LINKED = ACONNECT.replace(" 0 'padcontroller '\n", " 0 'padcontroller '\n\tConnecting To: 131:0\n")
def test_parse_aconnect_reads_pids():
ports = {p.addr: p for p in parse_aconnect(ACONNECT)}
assert ports["131:0"].pid == "57635"
assert ports["20:0"].pid is None # a kernel client
def test_qlc_feeds_names_the_qlc_process():
assert qlc_feeds(parse_aconnect(LINKED)) == {("57635", "131:0")}
assert qlc_feeds(parse_aconnect(ACONNECT)) == set()
def test_a_restarted_qlc_that_linked_itself_is_a_new_feed():
before = qlc_feeds(parse_aconnect(LINKED))
after = qlc_feeds(parse_aconnect(LINKED.replace("pid=57635", "pid=60001")))
assert after - before == {("60001", "131:0")}