Compare commits

..
25 Commits
Author SHA1 Message Date
jimmyandClaude Opus 5.5 a985452568 Keep reading the virtual pad while the real pad is away.
The pad controller opened the pad's port as its input and closed it when the
pad went, which stopped rtmidi reading at all, so virtual pad presses never
reached QLC+ and the chases stayed on their starting blue. Its input is now a
port of its own, open for the whole run, with the pad linked into it by
aconnect (and the old link dropped when the pad moves between USB and
Bluetooth). It also starts without the pad instead of exiting.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 17:59:44 +13:00
jimmyandClaude Opus 5.5 0b06dfdccf Add a script linking the RGB scripts, fixtures and pad profile into ~/.qlcplus.
The can patterns' Steps and Swap matrices need rgbscripts/steps.js and
swap.js in ~/.qlcplus/rgbscripts. Only can_patterns.py linked them, so a
fresh checkout's patterns did nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 17:27:40 +13:00
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
jimmyandClaude Opus 5.5 3b38df3dd0 Smooth the movers' Corners in the test show.
Corners slammed the heads about 100° of pan every 0.6 s at full motor speed.
It now runs at a quarter of the speed dial like the other shapes, about 1.4 s
a corner, and its pad starts a collection with a Movers glide scene that sets
the heads' Pan/Tilt Speed to 40 while it runs, so they ease into each corner.
That channel is forced HTP on the movers, so it drops back to full speed when
Corners stops instead of QLC+ holding it for everything after
(scripts/shows/mover_corners_glide.py).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 01:47:26 +13:00
jimmyandClaude Opus 5.5 f674dc9fe0 Give the movers every EFX shape and drop their Strobe in the test show.
The movers layer loses its Strobe (pad 9): its button, its scene and the
forced-HTP strobe channel it needed. Its pad, the rest of the second row
and pad 5 take the five shapes the movers did not have yet: Diamond, Square,
Corners (SquareChoppy), Leaf, and Tilt (Line2 on tilt alone). All nine sit in
the Movement solo frame, one at a time, mirrored and relative to the knobs.
Knob 13's speed dial gives Corners an eighth of its time and the rest a
quarter (scripts/shows/mover_all_efx.py). The pad controller settles the
knobs after all nine.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 01:47:15 +13:00
jimmyandClaude Opus 5.5 c3fe965e79 Add Circle and Sweep for the movers to the test show.
They fill the movers layer's top row, pads 15 and 16 (notes 98 and 99), in
the Movement solo frame with Wander and Ballyhoo: a circle of about ±45° of
pan and ±21° of tilt, and a straight pan sweep of about ±60°, both mirrored
and relative to the knobs. Knob 13's speed dial gives them a quarter of its
time, 5.5 s a round to start with (scripts/shows/mover_more_efx.py). The pad
controller settles the knobs after them too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 01:47:05 +13:00
jimmyandClaude Opus 5.5 80df550916 Run the movers' Wander and Ballyhoo one at a time.
Their two buttons go into a Movement solo frame where they sit, so starting
one stops the other (scripts/shows/mover_movement_solo.py). The pad
controller follows: it tracks the one that is on, and settles the knobs only
when that one goes off. Swapping needs no settle, as the new EFX writes over
the old one's offset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 01:46:45 +13:00
jimmyandClaude Opus 5.5 09aab70bd6 Put the movers' Wander and Ballyhoo speed on knob 13 in the test show.
A Movers speed dial on knob 13 (CC 42), beside the cans' Speed dial, sets
how long Wander takes to go round and gives Ballyhoo an eighth of it
(scripts/shows/mover_speed.py).

QLC+ 4.12 counts an EFX's fade-in inside every round, so Wander has been
taking 22 s and Ballyhoo 2.5 s, not 24 s and 3 s. The dial keeps those as
its starting point and runs from 62 s and 7.5 s fully left to 10 s and 1 s
fully right. The fade-ins stay, so the movers don't jump when either starts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 01:46:27 +13:00
jimmyandClaude Opus 5.5 ae186c51ea Drop the movers' chases and put Wander and Ballyhoo on the top row.
The movers layer loses its Chase, Chase reverse, Zigzag and Opposing pads,
with their runs, holds, colour matrices, fixture groups and Speed dial
entries. Wander and Ballyhoo move up to pads 13 and 14 (notes 96 and 97),
and the pad controller settles the knobs after those notes instead
(scripts/shows/mover_pads_top_row.py).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 01:46:18 +13:00
jimmyandClaude Opus 5.5 913494c0aa Add a Ballyhoo pad for the movers to the test show.
Pad 11 on the movers layer (note 94) toggles a fast figure of eight around
the Pan and Tilt knobs, like Wander: about ±85° of pan and ±26° of tilt, all
four movers together so the pairs mirror left to right and front to back
(scripts/shows/mover_ballyhoo.py).

The pad controller now settles the knobs after Ballyhoo goes off as well as
Wander, and keeps track of each separately.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 01:46:03 +13:00
jimmyandClaude Opus 5.5 8caf341d30 Point the back movers at the back wall at pan knob 0 in the test show.
M3 and M4 are mounted 90° round from M1 and M2, so at pan 0 they face the
middle. Knob 9 now drives a Pan slider for M1 and M2 over 0–212 and a Pan
back slider for M3 and M4 over 43–255 (scripts/shows/mover_pan_back.py).
The same span keeps the pairs 90° of pan apart all the way round: at knob 0
the front pair face the audience and the back pair the back wall, and the
left and right pairs point at the centre and the side walls together.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 00:49:37 +13:00
jimmyandClaude Opus 5.5 00c8c2d35d 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>
2026-10-23 00:49:33 +13:00
jimmyandClaude Opus 5.5 f8c8cea3ef Free the pad's ALSA clients when the Private port is missing.
On Bluetooth there is no Private port, so every Sound or Threshold press
opened two sequencer clients to light the lamps and left them open when the
port lookup raised. After 29 presses the sequencer was full and aconnect
could no longer open it. set_sound_lamps and Link now close both clients
on that path too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 00:49:25 +13:00
jimmyandClaude Opus 5.5 9c1ef6f2d4 Read the pad over Bluetooth first, and USB when it isn't paired.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 00:02:08 +13:00
jimmyandClaude Opus 5.5 2586ead4fa Put the chase speed on knob 1 in the test show.
A Speed dial on knob 1 (CC 30) sets the step time of the cans' and movers'
chase and zigzag runs, from 800 ms fully left to 50 ms fully right, starting
at the old 200 ms. Zigzag forward stays at half the step, and the dimmer holds
follow at 8 steps so they stretch with the run. The 500 ms trail is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 00:02:08 +13:00
jimmyandClaude Opus 5.5 fc8abf9c99 Set the movers' zeros and pan directions, swap M1/M2's patch, and model tilt in the simulator.
The front right mover is on DMX 1 and the front left on 45, so M1 and M2
swap addresses in the stage map and test.qxw. Measured on the rig, pan 0
faces forward on the front pair and into the middle on the back pair, back
at 85. M1 and M4 turn anticlockwise, so movers get a pan_reverse flag.

Tilt 127 now points straight down: the simulator draws a spot under the
head, and past 127 the beam flips behind the pan heading.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 22:54:14 +13:00
39 changed files with 8219 additions and 1260 deletions

No files matched your search

+6
View File
@@ -12,6 +12,12 @@
"runtimeExecutable": ".venv/bin/python",
"runtimeArgs": ["-m", "simulator", "--http", "127.0.0.1:8766", "--artnet", "127.0.0.1:6455", "--demo"],
"port": 8766
},
{
"name": "simulator-artnet",
"runtimeExecutable": ".venv/bin/python",
"runtimeArgs": ["-m", "simulator", "--http", "127.0.0.1:8767", "--artnet", "127.0.0.1:6456"],
"port": 8767
}
]
}
+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.
+9
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/install_qlcplus.sh 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
@@ -22,6 +23,14 @@ tests/ Art-Net / fixture helpers used by scripts
## Open in QLC+
On a new machine, link the RGB scripts, fixtures and pad input profile into
`~/.qlcplus` first, then (re)start QLC+. Without `rgbscripts/steps.js` and
`swap.js` the can patterns load but do nothing.
```bash
scripts/install_qlcplus.sh
```
- Full show: `shows/xchc.qxw`
- Simple RGBW + positions: `shows/simple.qxw`
+9 -5
View File
@@ -96,11 +96,15 @@ class Link:
rtmidi = load_rtmidi()
self.midiout = rtmidi.MidiOut(rtapi=rtmidi.API_LINUX_ALSA)
self.midiin = rtmidi.MidiIn(rtapi=rtmidi.API_LINUX_ALSA)
self.name = private_port(self.midiout.get_ports())
index = self.midiout.get_ports().index(self.name)
self.midiin.open_port(index)
self.midiin.ignore_types(sysex=False, timing=True, active_sense=True)
self.midiout.open_port(index)
try:
self.name = private_port(self.midiout.get_ports())
index = self.midiout.get_ports().index(self.name)
self.midiin.open_port(index)
self.midiin.ignore_types(sysex=False, timing=True, active_sense=True)
self.midiout.open_port(index)
except BaseException:
self.close()
raise
def close(self) -> None:
for port in (self.midiout, self.midiin):
+77 -79
View File
@@ -4,37 +4,36 @@ 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
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' movement pads (pads 13–16, 9–12 and 5 on the movers layer: notes
96–99, 92–95 and 88) each toggle a relative EFX around the Pan and Tilt knobs (9
and 10, CC 38 and 39). They share a solo frame in QLC+, so starting one stops the others.
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: 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
@@ -47,24 +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}
@@ -77,14 +80,11 @@ 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)]
if kind not in (0x80, 0x90) or len(data) < 3:
return [list(data)]
key = (channel, data[1])
@@ -95,30 +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]]
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."""
@@ -129,25 +121,31 @@ 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
out = []
"""QLC+ has loaded the show: everything is off. Press the colours that were on."""
self.moving = None
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."""
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]]:
+81 -79
View File
@@ -6,18 +6,25 @@ 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
patch_smc_pad.py once the pad controller is running). Every 2 s it checks the
links: it reopens the pad when it is replugged (or moves to USB when that turns
up) and re-links QLC+ to the virtual port after a restart, so QLC+ can stay open.
links: it reopens the pad when it is replugged (or moves to Bluetooth when that
turns up) and re-links QLC+ to the virtual port after a restart, so QLC+ can stay open.
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
the EFX's last offset (see PlayLayer.settle).
Usage:
.venv/bin/python -m padcontroller.midi
@@ -35,10 +42,10 @@ import os
import re
import subprocess
import sys
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
@@ -47,19 +54,21 @@ 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
# USB first when the pad is plugged in, Bluetooth otherwise.
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 = (
"SINCO SMC-PAD-Master",
"SMC-PAD Bluetooth",
"SINCO SMC-PAD-Master",
"SINCO SMC-PAD-Private",
"SINCO",
"SMC-PAD",
@@ -75,21 +84,12 @@ def pick_source(names: list[str]) -> int | None:
return None
def find_source_port(midiin: rtmidi.MidiIn) -> int:
ports = midiin.get_ports()
i = pick_source(ports)
if i is None:
raise SystemExit(
"No SMC-PAD MIDI source found. Ports:\n " + "\n ".join(ports or ["(none)"])
)
return i
@dataclass
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)
@@ -97,15 +97,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:
@@ -134,20 +134,38 @@ 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 unlink_source(src_name: str | None) -> None:
"""Take the pad's old port off padcontroller-in, so a pad moving from USB to Bluetooth isn't heard twice."""
m = re.search(r"(\d+:\d+)$", src_name or "")
if m:
subprocess.run(["aconnect", "-d", m.group(1), "padcontroller-in:0"], capture_output=True)
def load_colours(layer: PlayLayer) -> None:
@@ -166,33 +184,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(
@@ -208,9 +199,13 @@ def main() -> None:
midiin = rtmidi.MidiIn(rtapi=rtmidi.API_LINUX_ALSA, name="padcontroller-in")
midiout = rtmidi.MidiOut(rtapi=rtmidi.API_LINUX_ALSA, name="padcontroller-out")
src = find_source_port(midiin)
src_name = midiin.get_ports()[src]
midiin.open_port(src)
names = midiin.get_ports()
src = pick_source(names)
src_name = names[src] if src is not None else None
# Our own input port, with the pad linked into it by ensure_links: it keeps reading while
# the pad is away (rtmidi stops reading when an opened port closes), so the virtual pad
# still gets through.
midiin.open_virtual_port("RtMidi input")
midiin.ignore_types(timing=True, active_sense=True, sysex=True)
midiout.open_virtual_port(VIRTUAL_NAME)
@@ -222,17 +217,19 @@ def main() -> None:
load_colours(layer)
saved_colours = dict(layer.colours)
reopen_at: float | None = None
# (when, messages to send then), for the settle after a mover EFX
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
print(f"Source: {src_name}", flush=True)
print(f"Source: {src_name or '(pad gone, waiting)'}", 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))
@@ -242,20 +239,18 @@ def main() -> None:
while True:
now = time.monotonic()
if now >= next_link_check:
# Follow the pad: reopen it when it comes back, and move to USB when plugged in.
# Follow the pad: reopen it when it comes back, and move to Bluetooth when paired.
names = midiin.get_ports()
best = pick_source(names)
best_name = names[best] if best is not None else None
if best_name != src_name:
midiin.close_port()
if best is not None:
midiin.open_port(best)
print(f"Source: {best_name}", flush=True)
else:
print("Source: (pad gone, waiting)", flush=True)
unlink_source(src_name)
print(f"Source: {best_name or '(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:
@@ -263,9 +258,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:
@@ -277,7 +271,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])
@@ -285,10 +279,18 @@ 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]():
midiout.send_message(out)
if layer.colours != saved_colours:
save_colours(layer)
saved_colours = dict(layer.colours)
+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;
}
)();
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# Link this repo's RGB scripts, fixtures and input profiles into ~/.qlcplus,
# where QLC+ looks for them. The shows' can patterns use rgbscripts/steps.js
# and swap.js, so without them those matrices do nothing. Restart QLC+ after
# running this: it reads these folders at startup.
#
# scripts/install_qlcplus.sh # link what is missing; keep files that differ
# scripts/install_qlcplus.sh --force # replace files that differ with links
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
USER_DIR="$HOME/.qlcplus"
FORCE=
[[ "${1:-}" == "--force" ]] && FORCE=1
for dir in rgbscripts fixtures inputprofiles; do
mkdir -p "$USER_DIR/$dir"
for src in "$ROOT/$dir"/*; do
dest="$USER_DIR/$dir/$(basename "$src")"
if [[ -L "$dest" && "$(readlink -f "$dest")" == "$src" ]]; then
continue
fi
if [[ -e "$dest" && ! -L "$dest" ]] && ! cmp -s "$src" "$dest" && [[ -z "$FORCE" ]]; then
echo "Kept $dest: it differs from $dir/$(basename "$src"). --force replaces it." >&2
continue
fi
ln -sfn "$src" "$dest"
echo "Linked $dest"
done
done
-37
View File
@@ -28,42 +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)
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)
try:
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()
+94
View File
@@ -0,0 +1,94 @@
#!/usr/bin/env python3
"""Drop the movers' Strobe from shows/test.qxw and add the rest of QLC+'s EFX shapes.
The movers layer has no Strobe any more (pad 9, note 92): its button, its scene
and the HTP strobe channel that let it beat the colour scenes all go. Its pad and
the rest of the second row, and pad 5, take the five EFX shapes the movers did
not have yet. They join Wander, Ballyhoo, Circle and Sweep in the Movement solo
frame, now three rows deep, so still only one runs at a time:
92 Diamond pad 9 a diamond, about ±64° of pan and ±21° of tilt
93 Square pad 10 a square, about ±53° of pan and ±16° of tilt
94 Corners pad 11 SquareChoppy: jumps corner to corner of the same square
95 Leaf pad 12 a four-petal leaf, about ±53° of pan and ±26° of tilt
88 Tilt pad 5 Line2 on tilt alone, about ±26° up and down
Like the others each is a relative EFX around the Pan and Tilt knobs, with all
four movers together so the pairs mirror, fading in over 0.5 s. Knob 13's speed
dial gives Corners an eighth of its time (2.5 s a round to start with) and the
rest a quarter (5.5 s). padcontroller/layer.py settles the knobs after all nine.
python3 scripts/shows/mover_all_efx.py
Run it once on a show with Circle and Sweep and the movers' Strobe; it stops if
Diamond is already there. QLC+ has to reopen the show to see it.
"""
from __future__ import annotations
import re
from mover_bank import M1, M2, M3, M4, NO_FUNCTION, ROOT, STROBE, button, note
from mover_more_efx import SIZE, START_MS, efx
SHOW = ROOT / "shows" / "test.qxw"
# Speed dial factor indexes: (Not Sent), 0, 1/16, 1/8, 1/4, ...
TIMES_1_8, TIMES_1_4 = 3, 4
# Caption, function name, algorithm, width, height (of 255 each way), can note, column, row, dial factor
MOVES = (
("Diamond", "Movers diamond", "Diamond", 30, 20, 44, 0, 1, TIMES_1_4),
("Square", "Movers square", "Square", 25, 15, 45, 1, 1, TIMES_1_4),
("Corners", "Movers corners", "SquareChoppy", 25, 15, 46, 2, 1, TIMES_1_8),
("Leaf", "Movers leaf", "Leaf", 25, 25, 47, 3, 1, TIMES_1_4),
("Tilt", "Movers tilt", "Line2", 0, 25, 40, 0, 2, TIMES_1_4),
)
ROWS = 3
def cut(xml: str, pattern: str) -> str:
xml, n = re.subn(pattern, "", xml, count=1, flags=re.S)
assert n == 1, pattern
return xml
def main() -> None:
xml = SHOW.read_text()
if 'Name="Movers diamond"' in xml:
raise SystemExit(f"{SHOW.relative_to(ROOT)} already has the movers diamond")
strobe = int(re.search(r'<Function ID="(\d+)" Type="Scene" Name="Movers strobe">', xml).group(1))
xml = cut(xml, rf' <Function ID="{strobe}" Type="Scene" Name="Movers strobe">\n.*? </Function>\n')
# The cans' Strobe has the same caption; the movers' one is widget 89 (scripts/shows/mover_bank.py).
xml = cut(xml, r' <Button Caption="Strobe" ID="89" Icon="">\n.*? </Button>\n')
for fid in (M1, M2, M3, M4):
xml, n = re.subn(rf'( <ID>{fid}</ID>\n(?: .*\n)*?) <ForcedHTP>{STROBE}</ForcedHTP>\n', r"\1", xml, count=1)
assert n == 1, fid
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
solo = re.search(r' <SoloFrame Caption="Movement" ID="\d+">\n.*? </SoloFrame>\n', xml, re.S).group(0)
dial = re.search(r' <SpeedDial Caption="Movers speed" ID="\d+">\n.*? </SpeedDial>\n', xml, re.S).group(0)
functions, buttons, rows = "", "", ""
for i, (caption, name, algorithm, width, height, can_note, column, row, factor) in enumerate(MOVES):
start_ms = START_MS // 2 if factor == TIMES_1_8 else START_MS
functions += efx(fid + i, name, algorithm, width, height, start_ms)
buttons += button(wid + i, caption, SIZE * column, SIZE * row, SIZE, fid + i, note(can_note), indent=" ")
rows += f' <Function FadeIn="0" FadeOut="0" Duration="{factor}">{fid + i}</Function>\n'
grown = re.sub(r'(<WindowState Visible="True" X="10" Y="10" Width="\d+" Height=")\d+"', rf'\g<1>{SIZE * ROWS}"',
solo, count=1)
grown = grown.replace(" </SoloFrame>\n", buttons + " </SoloFrame>\n")
xml = xml.replace(solo, grown, 1)
xml = xml.replace(dial, dial.replace(" </SpeedDial>\n", rows + " </SpeedDial>\n"), 1)
xml = xml.replace(" </Engine>", functions + " </Engine>", 1)
SHOW.write_text(xml)
print(f"Dropped the movers' Strobe and added {len(MOVES)} shapes to {SHOW.relative_to(ROOT)} "
f"(functions {fid}–{fid + len(MOVES) - 1}, widgets {wid}–{wid + len(MOVES) - 1})")
if __name__ == "__main__":
main()
+87
View File
@@ -0,0 +1,87 @@
#!/usr/bin/env python3
"""Add a Ballyhoo pad for the movers to shows/test.qxw, on note 94.
On the movers layer (Pause on), pad 11 toggles a fast, wide figure of eight
around wherever the Pan and Tilt knobs (9 and 10, CC 38 and 39) put the movers,
as Wander does:
94 Ballyhoo an Eight about ±85° of pan and ±26° of tilt, 2.5 s round
All four start together. M1 and M4 turn the other way to M2 and M3, so the
same move mirrors left to right and front to back, and the beams sweep out
and cross in the middle together. It fades in over 0.5 s, which QLC+ counts inside each 3 s round. When it goes off,
the pad controller nudges the two knobs so QLC+ drops its last offset
(padcontroller/layer.py).
python3 scripts/shows/mover_ballyhoo.py
Run it once on a show with Wander and without Ballyhoo; it stops if Ballyhoo
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 = 40, 24 # of 255 each way: 540° of pan, 270° of tilt
ROUND_MS = 3000
FADE_IN_MS = 500
def efx(fid: int) -> str:
fixtures = "".join(f""" <Fixture>
<ID>{f}</ID>
<Head>0</Head>
<Mode>0</Mode>
<Direction>Forward</Direction>
<StartOffset>0</StartOffset>
</Fixture>
""" for f in 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 ballyhoo">
{fixtures} <PropagationMode>Parallel</PropagationMode>
<Speed FadeIn="{FADE_IN_MS}" FadeOut="0" Duration="{ROUND_MS}"/>
<Direction>Forward</Direction>
<RunOrder>Loop</RunOrder>
<Algorithm>Eight</Algorithm>
<Width>{WIDTH}</Width>
<Height>{HEIGHT}</Height>
<Rotation>0</Rotation>
<StartOffset>0</StartOffset>
<IsRelative>1</IsRelative>
<Axis Name="X">
<Offset>127</Offset>
<Frequency>1</Frequency>
<Phase>0</Phase>
</Axis>
<Axis Name="Y">
<Offset>127</Offset>
<Frequency>1</Frequency>
<Phase>0</Phase>
</Axis>
</Function>
"""
def main() -> None:
xml = SHOW.read_text()
if 'Name="Movers ballyhoo"' in xml:
raise SystemExit(f"{SHOW.relative_to(ROOT)} already has the movers ballyhoo")
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 Wander, on the pad after it.
wander = re.search(r' <Button Caption="Wander" ID="\d+" Icon="">\n.*? </Button>\n', xml, re.S).group(0)
xml = xml.replace(wander, wander + button(wid, "Ballyhoo", 190, 100, 90, fid, note(46)), 1)
SHOW.write_text(xml)
print(f"Added the movers ballyhoo to {SHOW.relative_to(ROOT)} (function {fid}, widget {wid})")
if __name__ == "__main__":
main()
+64
View File
@@ -0,0 +1,64 @@
#!/usr/bin/env python3
"""Smooth the movers' Corners in shows/test.qxw.
Corners (pad 11 on the movers layer) jumps the heads corner to corner of a
square. At full motor speed each jump is a slam of about 100° of pan, and at an
eighth of the speed dial the next comes 0.6 s later. Now it runs at a quarter,
like the other shapes (about 1.4 s a corner, 5.5 s a round to start with), and
its pad starts a collection of the EFX and a Movers glide scene that sets the
heads' Pan/Tilt Speed to GLIDE while it runs (0 is fastest, 255 slowest), so
they ease into each corner and settle there before the next. The channel is
forced HTP on the movers, so like a dimmer it drops back to 0, full speed, when
Corners stops; left LTP, QLC+ would hold it at GLIDE for everything after.
python3 scripts/shows/mover_corners_glide.py
Run it once on a show with Corners; it stops if the glide is already there.
QLC+ has to reopen the show to see it.
"""
from __future__ import annotations
import re
from mover_bank import M1, M2, M3, M4, ROOT, scene
from mover_more_efx import START_MS
SHOW = ROOT / "shows" / "test.qxw"
PAN_TILT_SPEED = 4 # mover channel
GLIDE = 40
TIMES_1_4 = 4 # speed dial factor index: (Not Sent), 0, 1/16, 1/8, 1/4, ...
def main() -> None:
xml = SHOW.read_text()
if 'Name="Movers glide"' in xml:
raise SystemExit(f"{SHOW.relative_to(ROOT)} already has the movers glide")
engine = xml.split("<VirtualConsole>")[0]
corners = int(re.search(r'<Function ID="(\d+)" Type="EFX" Name="Movers corners">', engine).group(1))
glide = max(int(i) for i in re.findall(r'<Function ID="(\d+)" Type', engine)) + 1
collection = glide + 1
xml, n = re.subn(rf'(<Function ID="{corners}" Type="EFX" Name="Movers corners">\n.*?<Speed FadeIn="\d+" FadeOut="0" Duration=")\d+"',
rf'\g<1>{START_MS}"', xml, count=1, flags=re.S)
assert n == 1
xml, n = re.subn(rf'(<Function FadeIn="0" FadeOut="0" Duration=")\d+(">{corners}</Function>)', rf"\g<1>{TIMES_1_4}\2", xml)
assert n == 1
functions = (scene(glide, "Movers glide", {PAN_TILT_SPEED: GLIDE})
+ f' <Function ID="{collection}" Type="Collection" Name="Movers corners glide">\n'
f' <Step Number="0">{corners}</Step>\n <Step Number="1">{glide}</Step>\n </Function>\n')
xml = xml.replace(" </Engine>", functions + " </Engine>", 1)
for fid in (M1, M2, M3, M4):
xml, n = re.subn(rf'( <ID>{fid}</ID>\n(?: .*\n)*? <Channels>43</Channels>\n)',
rf"\1 <ForcedHTP>{PAN_TILT_SPEED}</ForcedHTP>\n", xml, count=1)
assert n == 1, fid
xml, n = re.subn(r'(<Button Caption="Corners" ID="\d+" Icon="">\n.*?<Function ID=")\d+"', rf'\g<1>{collection}"',
xml, count=1, flags=re.S)
assert n == 1
SHOW.write_text(xml)
print(f"Corners in {SHOW.relative_to(ROOT)} now glides (scene {glide}, collection {collection})")
if __name__ == "__main__":
main()
+102
View File
@@ -0,0 +1,102 @@
#!/usr/bin/env python3
"""Add Circle and Sweep for the movers to shows/test.qxw, on notes 98 and 99.
They fill the top row of the movers layer after Wander and Ballyhoo, in the same
Movement solo frame, so only one of the four runs at a time. Like them, each is
a relative EFX around wherever the Pan and Tilt knobs (9 and 10) put the movers:
98 Circle pad 15 a circle about ±45° of pan and ±21° of tilt
99 Sweep pad 16 a straight pan sweep, about ±60° side to side
All four movers start together, so the pairs mirror left to right and front to
back as in Ballyhoo. Each fades in over 0.5 s. Knob 13's Movers speed dial gives
them a quarter of its time, less the fade-in that QLC+ counts in each round:
5.5 s a round to start with, from 15.5 s fully left to 2.5 s fully right.
padcontroller/layer.py settles the knobs after them too.
python3 scripts/shows/mover_more_efx.py
Run it once on a show with the Movement solo frame and the Movers speed dial;
it stops if Circle 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"
FADE_IN_MS = 500
START_MS = 6000 # a quarter of the speed dial's starting 24 s
TIMES_1_4 = 4 # speed dial factor index: (Not Sent), 0, 1/16, 1/8, 1/4, ...
SIZE = 90
# Caption, function name, algorithm, width, height (of 255 each way), can note, column
MOVES = (
("Circle", "Movers circle", "Circle", 21, 20, 50, 2),
("Sweep", "Movers sweep", "Line", 28, 0, 51, 3),
)
def efx(fid: int, name: str, algorithm: str, width: int, height: int, start_ms: int = START_MS) -> str:
fixtures = "".join(f""" <Fixture>
<ID>{f}</ID>
<Head>0</Head>
<Mode>0</Mode>
<Direction>Forward</Direction>
<StartOffset>0</StartOffset>
</Fixture>
""" for f in LEFT_TO_RIGHT)
axes = "".join(f""" <Axis Name="{axis}">
<Offset>127</Offset>
<Frequency>1</Frequency>
<Phase>0</Phase>
</Axis>
""" for axis in "XY")
# Relative: the EFX adds its offset from 127 to the Pan and Tilt sliders' levels.
return f""" <Function ID="{fid}" Type="EFX" Name="{name}">
{fixtures} <PropagationMode>Parallel</PropagationMode>
<Speed FadeIn="{FADE_IN_MS}" FadeOut="0" Duration="{start_ms}"/>
<Direction>Forward</Direction>
<RunOrder>Loop</RunOrder>
<Algorithm>{algorithm}</Algorithm>
<Width>{width}</Width>
<Height>{height}</Height>
<Rotation>0</Rotation>
<StartOffset>0</StartOffset>
<IsRelative>1</IsRelative>
{axes} </Function>
"""
def main() -> None:
xml = SHOW.read_text()
if 'Name="Movers circle"' in xml:
raise SystemExit(f"{SHOW.relative_to(ROOT)} already has the movers circle")
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
solo = re.search(r' <SoloFrame Caption="Movement" ID="\d+">\n.*? </SoloFrame>\n', xml, re.S).group(0)
dial = re.search(r' <SpeedDial Caption="Movers speed" ID="\d+">\n.*? </SpeedDial>\n', xml, re.S).group(0)
functions, buttons, rows = "", "", ""
for i, (caption, name, algorithm, width, height, can_note, column) in enumerate(MOVES):
functions += efx(fid + i, name, algorithm, width, height)
buttons += button(wid + i, caption, SIZE * column, 0, SIZE, fid + i, note(can_note), indent=" ")
rows += f' <Function FadeIn="0" FadeOut="0" Duration="{TIMES_1_4}">{fid + i}</Function>\n'
columns = 2 + len(MOVES)
grown = re.sub(r'(<WindowState Visible="True" X="10" Y="10" Width=")\d+"', rf'\g<1>{SIZE * columns}"', solo, count=1)
grown = grown.replace(" </SoloFrame>\n", buttons + " </SoloFrame>\n")
xml = xml.replace(solo, grown, 1)
xml = xml.replace(dial, dial.replace(" </SpeedDial>\n", rows + " </SpeedDial>\n"), 1)
xml = xml.replace(" </Engine>", functions + " </Engine>", 1)
SHOW.write_text(xml)
print(f"Added Circle and Sweep to {SHOW.relative_to(ROOT)} (functions {fid}–{fid + len(MOVES) - 1}, "
f"widgets {wid}–{wid + len(MOVES) - 1})")
if __name__ == "__main__":
main()
+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env python3
"""Make Wander and Ballyhoo one at a time in shows/test.qxw.
Their two buttons go into a solo frame, Movement, where they already sit on the
top row of the movers pads, so starting one stops the other, as the colour sets
do. padcontroller/layer.py follows the same rule.
python3 scripts/shows/mover_movement_solo.py
Run it once on a show with Wander and Ballyhoo on the top row; it stops if the
solo frame is already there. QLC+ has to reopen the show to see it.
"""
from __future__ import annotations
import re
from mover_bank import NO_FUNCTION, ROOT, appearance
SHOW = ROOT / "shows" / "test.qxw"
BUTTONS = ("Wander", "Ballyhoo")
SIZE = 90
def main() -> None:
xml = SHOW.read_text()
if 'Caption="Movement"' in xml:
raise SystemExit(f"{SHOW.relative_to(ROOT)} already has the Movement solo frame")
wid = max(int(i) for i in re.findall(r' ID="(\d+)"', xml.split("<VirtualConsole>")[1])
if int(i) != NO_FUNCTION) + 1
found = [re.search(rf' <Button Caption="{caption}" ID="\d+" Icon="">\n.*? </Button>\n', xml, re.S).group(0)
for caption in BUTTONS]
body = ""
for i, button in enumerate(found):
xml = xml.replace(button, "", 1)
# Inside the frame each sits at its place in the row, one level deeper.
moved = re.sub(r'X="\d+" Y="\d+"', f'X="{SIZE * i}" Y="0"', button, count=1)
body += "".join(" " + line if line else line for line in moved.splitlines(keepends=True))
frame = (f' <SoloFrame Caption="Movement" ID="{wid}">\n'
+ appearance(" ")
+ f' <WindowState Visible="True" X="10" Y="10" Width="{SIZE * len(BUTTONS)}" Height="{SIZE}"/>\n'
' <AllowChildren>True</AllowChildren>\n <AllowResize>True</AllowResize>\n'
' <ShowHeader>False</ShowHeader>\n <ShowEnableButton>False</ShowEnableButton>\n'
' <Mixing>False</Mixing>\n <Collapsed>False</Collapsed>\n <Disabled>False</Disabled>\n'
+ body + ' </SoloFrame>\n')
strobe = re.search(r' <Button Caption="Strobe" ID="89" Icon="">\n', xml).group(0)
xml = xml.replace(strobe, frame + strobe, 1)
SHOW.write_text(xml)
print(f"Put Wander and Ballyhoo in the Movement solo frame in {SHOW.relative_to(ROOT)} (widget {wid})")
if __name__ == "__main__":
main()
+71
View File
@@ -0,0 +1,71 @@
#!/usr/bin/env python3
"""Drop the movers' chases from shows/test.qxw and put Wander and Ballyhoo on the top row.
The movers layer loses its Chase, Chase reverse, Zigzag and Opposing pads
(notes 96–99), their runs, holds, colour matrices and fixture groups, and their
place on the Speed dial. Wander and Ballyhoo move up from notes 93 and 94 to
the first two pads of the top row:
96 Wander pad 13 on the movers layer
97 Ballyhoo pad 14 on the movers layer
The movers' Strobe (92) and Peak stay. padcontroller/layer.py settles the knobs
after notes 96 and 97.
python3 scripts/shows/mover_pads_top_row.py
Run it once on a show with the mover chases; it stops if they are gone.
QLC+ has to reopen the show to see it.
"""
from __future__ import annotations
import re
from mover_bank import (F_DIMMER, F_OPP, GROUP_OPPOSING, GROUP_RINGS, GROUP_ZIGZAG, ROOT, note)
SHOW = ROOT / "shows" / "test.qxw"
CHASE_FUNCTIONS = range(F_DIMMER, F_OPP + 1) # 57–63
CHASE_GROUPS = (GROUP_RINGS, GROUP_ZIGZAG, GROUP_OPPOSING)
CHASE_PADS = ("Chase", "Chase reverse", "Zigzag", "Opposing")
TOP_ROW = (("Wander", 10, note(48)), ("Ballyhoo", 100, note(49)))
def cut(xml: str, pattern: str) -> str:
xml, n = re.subn(pattern, "", xml, count=1, flags=re.S)
assert n == 1, pattern
return xml
def main() -> None:
xml = SHOW.read_text()
if 'Name="Movers chase forward run"' not in xml:
raise SystemExit(f"{SHOW.relative_to(ROOT)} has no mover chases")
for fid in CHASE_FUNCTIONS:
xml = cut(xml, rf' <Function ID="{fid}" Type=.*?\n </Function>\n')
xml = re.sub(rf' <Function FadeIn="0" FadeOut="0" Duration="\d+">{fid}</Function>\n', "", xml)
for gid in CHASE_GROUPS:
xml = cut(xml, rf' <FixtureGroup ID="{gid}">\n.*? </FixtureGroup>\n')
pads = re.search(r' <Frame Caption="Movers pads" ID="\d+">\n.*?\n </Frame>\n', xml, re.S).group(0)
kept = pads
for caption in CHASE_PADS:
kept = cut(kept, rf' <Button Caption="{caption}" ID="\d+" Icon="">\n.*? </Button>\n')
for caption, x, channel in TOP_ROW:
kept, n = re.subn(rf'( <Button Caption="{caption}" ID="\d+" Icon="">\n <WindowState Visible="True" X=")\d+" Y="\d+"'
rf'(.*?<Input Universe="1" Channel=")\d+"',
rf'\g<1>{x}" Y="10"\g<2>{channel}"', kept, count=1, flags=re.S)
assert n == 1, caption
xml = xml.replace(pads, kept, 1)
for caption in ("Movers chase runs", "Movers chase colours"):
xml = cut(xml, rf' <Frame Caption="{caption}" ID="\d+">\n.*?\n </Frame>\n')
assert not re.search(rf'(?:Function ID="|>)(?:{"|".join(map(str, CHASE_FUNCTIONS))})(?:"|<)', xml)
SHOW.write_text(xml)
print(f"Dropped the mover chases from {SHOW.relative_to(ROOT)}; Wander and Ballyhoo are on notes 96 and 97")
if __name__ == "__main__":
main()
+70
View File
@@ -0,0 +1,70 @@
#!/usr/bin/env python3
"""Split the movers' Pan slider in shows/test.qxw so the back pair face the back wall at knob 0.
M3 and M4 are mounted 90° round from M1 and M2: at pan 0 the front pair face
the audience and the back pair face the middle. Knob 9 (CC 38) now drives two
sliders over the same span of 212 steps, so the pairs keep that 90° of pan
(about 43 steps of 540°) between them all the way round:
Pan M1, M2 0–212
Pan back M3, M4 43–255
At knob 0 the front pair face the audience and the back pair the back wall.
Turning it, the left pair (M1, M3) and the right pair (M2, M4) point at the
centre together and at the side walls together.
python3 scripts/shows/mover_pan_back.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 M1, M2, M3, M4, NO_FUNCTION, ROOT
SHOW = ROOT / "shows" / "test.qxw"
BACK_OFFSET = 43 # 90° of pan, of 540° over 256 steps
ORDER = ("Brightness", "Pan", "Pan back", "Tilt", "Focus", "Rotate")
def main() -> None:
xml = SHOW.read_text()
if 'Caption="Pan back"' in xml:
raise SystemExit(f"{SHOW.relative_to(ROOT)} already has the back movers' pan")
wid = max(int(i) for i in re.findall(r' ID="(\d+)"', xml.split("<VirtualConsole>")[1])
if int(i) != NO_FUNCTION) + 1
start = xml.index('<Frame Caption="Movers position"')
end = xml.index("</Frame>", start)
frame = xml[start:end]
pan = re.search(r' <Slider Caption="Pan" ID="\d+".*? </Slider>\n', frame, re.S).group(0)
level = re.search(r'<Level LowLimit="0" HighLimit="255" Value="\d+">', pan).group(0)
def rows(*fixtures: int) -> str:
return "".join(f' <Channel Fixture="{f}">0</Channel>\n' for f in fixtures)
channels = rows(M1, M2, M3, M4)
assert channels in pan
front = (pan.replace(level, f'<Level LowLimit="0" HighLimit="{255 - BACK_OFFSET}" Value="0">')
.replace(channels, rows(M1, M2)))
back = (re.sub(r'Caption="Pan" ID="\d+"', f'Caption="Pan back" ID="{wid}"', pan)
.replace(level, f'<Level LowLimit="{BACK_OFFSET}" HighLimit="255" Value="{BACK_OFFSET}">')
.replace(channels, rows(M3, M4)))
frame = frame.replace(pan, front + back)
# Six sliders 58 apart fit the frame as it is.
for i, caption in enumerate(ORDER):
frame, n = re.subn(rf'(<Slider Caption="{caption}" ID="\d+"[^>]*>\n\s*<WindowState Visible="True" X=")\d+"',
rf'\g<1>{5 + 58 * i}"', frame)
assert n == 1, caption
SHOW.write_text(xml[:start] + frame + xml[end:])
print(f"Split the movers' Pan in {SHOW.relative_to(ROOT)} (Pan back is widget {wid})")
if __name__ == "__main__":
main()
+64
View File
@@ -0,0 +1,64 @@
#!/usr/bin/env python3
"""Add a Movers speed dial on knob 13 to shows/test.qxw.
Knob 13 (CC 42) sets how long Wander and Ballyhoo take to go round, as knob 1
does for the cans' chases. Wander gets the dial's time and Ballyhoo an eighth of
it. QLC+ 4.12 counts an EFX's fade-in inside every round, not just the first, so
a round takes that less its fade-in (2 s for Wander, 0.5 s for Ballyhoo):
Knob fully left 62 s Wander, 7.5 s Ballyhoo
Starting value 22 s Wander, 2.5 s Ballyhoo (as before the dial)
Knob fully right 10 s Wander, 1 s Ballyhoo
The fade-ins stay, so the movers don't jump when either starts. The dial sits
beside the cans' Speed dial.
python3 scripts/shows/mover_speed.py
Run it once on a show with Wander and Ballyhoo; it stops if the dial is already there.
QLC+ has to reopen the show to see it.
"""
from __future__ import annotations
import re
from mover_bank import NO_FUNCTION, ROOT, appearance
SHOW = ROOT / "shows" / "test.qxw"
SPEED_CC = 42 # knob 13
SLOWEST_MS, FASTEST_MS, START_MS = 64000, 12000, 24000
# Index into QLC+'s speed dial factors: (Not Sent), 0, 1/16, 1/8, 1/4, 1/2, 1, 2, 4, 8, 16
TIMES_1, TIMES_1_8 = 6, 3
NOT_SENT = 0
def main() -> None:
xml = SHOW.read_text()
if 'Caption="Movers speed"' in xml:
raise SystemExit(f"{SHOW.relative_to(ROOT)} already has the movers speed dial")
engine, console = xml.split("<VirtualConsole>")
wid = max(int(i) for i in re.findall(r' ID="(\d+)"', console) if int(i) != NO_FUNCTION) + 1
def function(name: str) -> int:
return int(re.search(rf'<Function ID="(\d+)" Type="EFX" Name="{name}">', engine).group(1))
rows = "".join(f' <Function FadeIn="{NOT_SENT}" FadeOut="{NOT_SENT}" Duration="{factor}">{function(name)}</Function>\n'
for name, factor in (("Movers wander", TIMES_1), ("Movers ballyhoo", TIMES_1_8)))
dial = (f' <SpeedDial Caption="Movers speed" ID="{wid}">\n'
' <WindowState Visible="True" X="1820" Y="10" Width="110" Height="240"/>\n'
+ appearance(" ", "Sunken")
+ f' <AbsoluteValue Minimum="{SLOWEST_MS}" Maximum="{FASTEST_MS}">\n'
f' <Input Universe="1" Channel="{SPEED_CC}"/>\n'
' </AbsoluteValue>\n'
f' <Time>{START_MS}</Time>\n'
+ rows + ' </SpeedDial>\n')
xml = xml.replace(" </Frame>\n <Properties>", dial + " </Frame>\n <Properties>", 1)
SHOW.write_text(xml)
print(f"Added the movers speed dial to {SHOW.relative_to(ROOT)} (widget {wid}, knob 13)")
if __name__ == "__main__":
main()
+88
View File
@@ -0,0 +1,88 @@
#!/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, 22 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+ counts the
fade-in inside each 24 s round, which leaves 22 s. 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()
+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

+1888 -936
View File
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -83,7 +83,7 @@ def _demo_frame(fixtures: list[Fixture], elapsed: float) -> bytearray:
for index, fixture in enumerate(movers):
pan = int(32768 + math.sin(elapsed * 0.6 + index * math.pi) * 9000)
pan = max(0, min(65535, pan))
tilt = 42000
tilt = 20000
_put(frame, fixture, "Pan", (pan >> 8) & 0xFF)
_put(frame, fixture, "Pan Fine", pan & 0xFF)
_put(frame, fixture, "Tilt", (tilt >> 8) & 0xFF)
+12 -2
View File
@@ -6,6 +6,7 @@ such as Dimmer, Red, Pan, and Zoom select the slots.
from __future__ import annotations
import math
import re
from simulator.stage import Fixture, Stage
@@ -13,6 +14,10 @@ from simulator.stage import Fixture, Stage
_PIXEL = re.compile(r"^(red|green|blue|white) (\d+)$", re.IGNORECASE)
PAN_DEGREES = 540.0
# Tilt 127 is straight down. 0 leans along the pan heading, 255 away from it.
TILT_DEGREES = 270.0
# Plan reach of a beam at or above horizontal.
BEAM_MAX_M = 4.7
ZOOM_MIN = 5.0
ZOOM_MAX = 45.0
@@ -378,8 +383,10 @@ def _decode_mover_named(channels: list[int], names: list[str]) -> dict:
pan_speed = _value(channels, names, "Pan/Tilt Speed")
pan_deg = (pan - 32768) / 65536.0 * PAN_DEGREES
zoom_deg = ZOOM_MIN + (zoom / 255.0) * (ZOOM_MAX - ZOOM_MIN)
# Long enough to read on the plan at tilt zero. Tilt stretches the throw.
beam_m = 2.2 + (tilt / 65535.0) * 2.5
tilt_deg = (tilt - 32768) / 65536.0 * TILT_DEGREES
# Reach along the pan heading on the plan. Negative points behind it.
lean = max(-90.0, min(90.0, -tilt_deg))
beam_m = BEAM_MAX_M * math.sin(math.radians(lean))
return {
"r": red,
"g": green,
@@ -393,6 +400,7 @@ def _decode_mover_named(channels: list[int], names: list[str]) -> dict:
"speed_hz": speed,
"dynamic": dynamic_name,
"pan_deg": round(pan_deg, 2),
"tilt_deg": round(tilt_deg, 2),
"zoom_deg": round(zoom_deg, 2),
"beam_m": round(beam_m, 3),
"pixels": tinted,
@@ -422,6 +430,8 @@ def view_fixture(fixture: Fixture, universes: dict[int, bytes]) -> dict:
viewed = decode_mover(channels)
else:
viewed = decode_can(channels)
if fixture.pan_reverse and "pan_deg" in viewed:
viewed["pan_deg"] = -viewed["pan_deg"]
viewed["patched"] = True
return viewed
+3
View File
@@ -36,6 +36,7 @@ class Fixture:
channel_names: list[str] = field(default_factory=list)
direction: float = 0.0 # cans: beam heading, degrees clockwise from +Y
zero: float = 0.0 # movers: heading at pan centre, same degrees
pan_reverse: bool = False # movers: rising pan turns the head anticlockwise
@property
def dmx(self) -> int | None:
@@ -61,6 +62,7 @@ class Fixture:
"channel_names": self.channel_names,
"direction": self.direction,
"zero": self.zero,
"pan_reverse": self.pan_reverse,
}
@@ -144,6 +146,7 @@ def load_stage(path: Path) -> Stage:
channel_names=channel_names,
direction=float(raw.get("direction") or 0),
zero=float(raw.get("zero") or 0),
pan_reverse=bool(raw.get("pan_reverse", False)),
)
)
return Stage(
+32 -3
View File
@@ -293,17 +293,24 @@ function drawGlow(sx, sy, fixture, color) {
function drawBeam(sx, sy, fixture, live, color, fixed) {
const level = (color.r + color.g + color.b) / 255;
const length = fixed ? fixed.beam : Math.max(live.beam_m || 0, fixture.kind === "mover" ? 2.2 : 0);
if (live.patched === false || level <= 0.02 || !length) return;
if (live.patched === false || level <= 0.02) return;
const aim = fixed || aimed(fixture.id, live, fixture.zero);
// Mover reach is signed: below zero the head has tilted past straight down.
const reach = fixed ? fixed.beam : fixture.kind === "mover" ? aim.beam : live.beam_m || 0;
// DMX focus 0 is a wide wash. Focus 255 holds the zoom angle.
// Fixed beams pass spread directly, 0 tight and 1 wide.
const spread = fixed ? fixed.focus : 1 - (live.focus || 0);
const zoom = fixed ? fixed.zoom : live.zoom_deg || 8;
const tight = zoom / 2;
const wide = Math.max(tight, 40);
const rad = aim.pan * Math.PI / 180;
const half = (tight + (wide - tight) * spread) * Math.PI / 180;
if (fixture.kind === "mover" && Math.abs(reach) < SPOT_M) {
drawSpot(sx, sy, fixture, aim.pan, reach, half, color, spread);
return;
}
const length = Math.abs(reach);
if (!length) return;
const rad = (aim.pan + (reach < 0 ? 180 : 0)) * Math.PI / 180;
const tip = [fixture.x + Math.sin(rad) * length, fixture.y + Math.cos(rad) * length];
const left = [fixture.x + Math.sin(rad - half) * length, fixture.y + Math.cos(rad - half) * length];
const right = [fixture.x + Math.sin(rad + half) * length, fixture.y + Math.cos(rad + half) * length];
@@ -320,6 +327,27 @@ function drawBeam(sx, sy, fixture, live, color, fixed) {
ctx.fill();
}
// Below this plan reach a mover is pointing near straight down.
const SPOT_M = 0.5;
// Throw to the floor for the spot under a mover.
const DROP_M = 2.5;
function drawSpot(sx, sy, fixture, pan, reach, half, color, spread) {
const rad = pan * Math.PI / 180;
const cx = sx(fixture.x + Math.sin(rad) * reach);
const cy = sy(fixture.y + Math.cos(rad) * reach);
const radius = Math.max(4, Math.abs(sx(DROP_M * Math.tan(half)) - sx(0)));
const gradient = ctx.createRadialGradient(cx, cy, 0, cx, cy, radius);
const alpha = 0.85 * (1 - spread * 0.35);
gradient.addColorStop(0, `rgba(${color.r},${color.g},${color.b},${alpha})`);
gradient.addColorStop(0.7, `rgba(${color.r},${color.g},${color.b},${alpha * 0.6})`);
gradient.addColorStop(1, `rgba(${color.r},${color.g},${color.b},0)`);
ctx.fillStyle = gradient;
ctx.beginPath();
ctx.arc(cx, cy, radius, 0, Math.PI * 2);
ctx.fill();
}
function lensRotation(live) {
if (live.spin_dps) return ((performance.now() / 1000) * live.spin_dps * Math.PI) / 180;
return ((live.lens_deg || 0) * Math.PI) / 180;
@@ -443,6 +471,7 @@ function updateDetail() {
if (live.reset) bits.push("reset");
if (fixture.kind === "mover" && live.pan_deg != null) {
bits.push(`pan ${live.pan_deg.toFixed(0)}°`);
if (live.tilt_deg != null) bits.push(`tilt ${live.tilt_deg.toFixed(0)}°`);
bits.push(`zoom ${(live.zoom_deg || 0).toFixed(0)}°`);
if (live.spin_dps) bits.push(`lens ${live.spin_dps > 0 ? "CW" : "CCW"}`);
else if (live.lens_deg) bits.push(`lens ${live.lens_deg.toFixed(0)}°`);
+7 -5
View File
@@ -113,9 +113,10 @@
"kind": "mover",
"def": "Small Eye 7 Mover",
"universe": 0,
"address": 0,
"address": 44,
"channels": 43,
"zero": 0
"zero": 90,
"pan_reverse": true
},
"M2": {
"x": 0.3,
@@ -124,9 +125,9 @@
"kind": "mover",
"def": "Small Eye 7 Mover",
"universe": 0,
"address": 44,
"address": 0,
"channels": 43,
"zero": 0
"zero": -90
},
"#9": {
"x": -3.5,
@@ -234,7 +235,8 @@
"address": 300,
"channels": 43,
"note": "Back right, between #14 and #15",
"zero": 0
"zero": 0,
"pan_reverse": true
}
}
}
+1 -1
View File
@@ -21,7 +21,7 @@ class ChataigneExportTest(unittest.TestCase):
self.stage = json.loads((ROOT / self.show["stage"]).read_text())
def test_channels_are_one_based_dmx(self) -> None:
levels = make_chataigne.absolute_levels(self.show, self.stage, {"#1": {"0": 255, "2": 10}, "M1": {"8": 7}})
levels = make_chataigne.absolute_levels(self.show, self.stage, {"#1": {"0": 255, "2": 10}, "M2": {"8": 7}})
self.assertEqual(levels, {88: 255, 90: 10, 9: 7})
def test_groups_hold_pads_and_sliders(self) -> None:
+107 -94
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,47 +76,128 @@ 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_ON)
self.assertEqual(layer.handle([0x99, 48, 100]), [[0x99, 96, 100]])
layer.handle([0x89, 48, 0])
self.assertEqual((layer.moving, layer.settle), (96, False))
layer.handle([0x99, 48, 100])
self.assertEqual((layer.moving, layer.settle), (None, True))
self.assertEqual(layer.nudge(), [[0xB0, 38, 39], [0xB0, 39, 1]])
self.assertEqual(layer.positions(), [[0xB0, 38, 40], [0xB0, 39, 0]])
def test_chase_on_the_cans_layer_is_not_wander(self):
layer = PlayLayer()
layer.handle([0x99, 48, 100])
layer.handle([0x99, 48, 100])
self.assertEqual((layer.moving, layer.settle), (None, False))
def test_ballyhoo_takes_over_from_wander_without_a_settle(self):
layer = PlayLayer()
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_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])
self.assertEqual((layer.moving, layer.settle), (None, True))
if __name__ == "__main__":
+26 -6
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",
@@ -35,13 +35,13 @@ client 131: 'qlcplus' [type=user,pid=57635]
"""
def test_usb_wins_over_bluetooth():
assert BOTH[pick_source(BOTH)] == "SINCO:SINCO SMC-PAD-Master 20:1"
def test_bluetooth_wins_over_usb():
assert BOTH[pick_source(BOTH)] == "SMC-PAD:SMC-PAD Bluetooth 128:0"
def test_bluetooth_when_unplugged():
names = [n for n in BOTH if "SINCO" not in n]
assert names[pick_source(names)] == "SMC-PAD:SMC-PAD Bluetooth 128:0"
def test_usb_when_not_paired():
names = [n for n in BOTH if "Bluetooth" not in n]
assert names[pick_source(names)] == "SINCO:SINCO SMC-PAD-Master 20:1"
def test_no_pad_and_never_our_own_port():
@@ -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")}
+60 -12
View File
@@ -42,9 +42,9 @@ def test_xchc_patch_matches_the_stage_map():
assert by_id["#1"].address == 87
assert by_id["#1"].dmx == 88
assert by_id["#8"].address == 143
assert by_id["M1"].address == 0
assert by_id["M1"].dmx == 1
assert by_id["M2"].address == 44
assert by_id["M1"].address == 44
assert by_id["M1"].dmx == 45
assert by_id["M2"].address == 0
assert by_id["M1"].channels == 43
assert by_id["#3"].kind == "can"
assert stage.output_ip == "192.168.1.228"
@@ -54,14 +54,16 @@ def test_xchc_patch_matches_the_stage_map():
assert by_id["#13"].x == -3.5 and by_id["#15"].x == 3.5
assert by_id["#14"].x == 0.0 and by_id["#14"].y == -7.65
assert by_id["#1"].address == 87 and by_id["#9"].address == 151
assert by_id["#15"].address == 199 and by_id["M1"].address == 0
assert by_id["M2"].address == 44 and by_id["#15"].channels == 8
assert by_id["#15"].address == 199 and by_id["M2"].address == 0
assert by_id["M1"].address == 44 and by_id["#15"].channels == 8
assert by_id["M3"].address == 257 and by_id["M3"].channels == 43
assert by_id["M3"].x == -1.75 and by_id["M3"].y == -7.65
assert by_id["M4"].address == 300 and by_id["M4"].x == 1.75
assert by_id["#1"].direction == 71 and by_id["#8"].direction == -72
assert by_id["#3"].direction == 0 and by_id["#14"].direction == -179
assert by_id["M1"].zero == 0 and by_id["M4"].zero == 0
assert by_id["M2"].zero == -90 and by_id["M4"].zero == 0
assert by_id["M1"].zero == 90 and by_id["M1"].pan_reverse and not by_id["M2"].pan_reverse
assert by_id["M4"].pan_reverse and not by_id["M3"].pan_reverse
assert stage.warnings == []
@@ -94,16 +96,25 @@ def test_can_macro_functions():
def test_mover_home_points_at_the_audience():
channels = [0] * 43
channels[0] = 128 # pan coarse, fine 0 → 32768, the centre of 540°
channels[2] = 160
channels[2] = 64
channels[8] = 255
channels[10] = 255 # red on the first pixel
viewed = decode_mover(channels)
assert viewed["pan_deg"] == 0
assert viewed["r"] == 255
assert viewed["beam_m"] > 2
parked = [0] * 43
parked[8] = 255
assert decode_mover(parked)["beam_m"] >= 2.2
def test_mover_tilt_goes_through_straight_down():
def reach(tilt):
channels = [0] * 43
channels[2] = tilt
return decode_mover(channels)["beam_m"]
assert reach(0) == 4.7 # forward and up
assert abs(reach(127)) < 0.2 # a spot under the head
assert reach(255) < -4.6 # behind the pan heading
assert reach(64) > 0 > reach(192)
assert lens_spin(0) == 0
assert lens_spin(160) < 0
assert lens_spin(230) > 0
@@ -173,6 +184,43 @@ def test_map_definition_selects_the_channels():
assert live["pan_deg"] == 0
def test_front_movers_face_forward_at_pan_zero_and_back_at_85():
stage = load_stage(ROOT / "stage" / "map.json")
by_id = {fixture.id: fixture for fixture in stage.fixtures}
def heading(pan):
frame = bytearray(512)
for mover in (by_id["M1"], by_id["M2"]):
frame[mover.address + mover.channel_names.index("Pan")] = pan
live = view_stage(stage, {0: bytes(frame)})
return {key: wrap_degrees(by_id[key].zero + live[key]["pan_deg"]) for key in ("M1", "M2")}
assert heading(0) == {"M1": 0, "M2": 0}
back = heading(85)
assert abs(abs(back["M1"]) - 180) <= 2 and abs(abs(back["M2"]) - 180) <= 2
# M2 turns clockwise and M1 anticlockwise.
assert heading(20)["M2"] > 0 > heading(20)["M1"]
def test_back_movers_face_the_middle_at_pan_zero():
stage = load_stage(ROOT / "stage" / "map.json")
by_id = {fixture.id: fixture for fixture in stage.fixtures}
def heading(pan):
frame = bytearray(512)
for mover in (by_id["M3"], by_id["M4"]):
frame[mover.address + mover.channel_names.index("Pan")] = pan
live = view_stage(stage, {0: bytes(frame)})
return {key: wrap_degrees(by_id[key].zero + live[key]["pan_deg"]) for key in ("M3", "M4")}
# M3 is on the left (-X) so the middle is +X, 90°. M4 mirrors it.
assert heading(0) == {"M3": 90, "M4": -90}
back = heading(85)
assert abs(back["M3"] + 90) <= 2 and abs(back["M4"] - 90) <= 2
# M3 turns clockwise and M4 anticlockwise, so both swing toward the back wall first.
assert heading(20)["M3"] > 90 and heading(20)["M4"] < -90
def test_view_reads_universe_bytes():
stage = load_stage(ROOT / "stage" / "map.json")
apply_show(stage, ROOT / "shows" / "xchc.qxw")
@@ -203,7 +251,7 @@ def test_http_state_follows_artnet():
with urlopen(f"http://127.0.0.1:{port}/api/state") as response:
payload = json.load(response)
assert payload["packets"] == 1
assert payload["fixtures"]["M1"]["r"] == 255
assert payload["fixtures"]["M2"]["r"] == 255
with urlopen(f"http://127.0.0.1:{port}/api/stage") as response:
described = json.load(response)
assert described["fixtures"][0]["x"] == -3.5
@@ -224,7 +272,7 @@ def test_heading_is_stored_in_the_map(tmp_path):
assert saved["fixtures"]["#1"]["direction"] == 45
assert saved["fixtures"]["#2"]["direction"] == before["#2"]["direction"]
assert saved["fixtures"]["M1"]["zero"] == -30
assert saved["fixtures"]["M2"]["zero"] == 0
assert saved["fixtures"]["M2"]["zero"] == -90
again = load_stage(target)
by_id = {fixture.id: fixture for fixture in again.fixtures}
assert by_id["#1"].direction == 45