Compare commits
13
Commits
2b0f9e2f9b
...
3b38df3dd0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b38df3dd0 | ||
|
|
f674dc9fe0 | ||
|
|
c3fe965e79 | ||
|
|
80df550916 | ||
|
|
09aab70bd6 | ||
|
|
ae186c51ea | ||
|
|
913494c0aa | ||
|
|
8caf341d30 | ||
|
|
00c8c2d35d | ||
|
|
f8c8cea3ef | ||
|
|
9c1ef6f2d4 | ||
|
|
2586ead4fa | ||
|
|
fc8abf9c99 |
No files matched your search
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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):
|
||||
|
||||
@@ -35,6 +35,15 @@ 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: a guess like pump.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -53,6 +62,9 @@ SUBMASTER_CC = 100
|
||||
KNOB_CHANNEL = 0
|
||||
PEAK_CC = 35 # knob 6
|
||||
SIDE_CCS = (34, 37) # knobs 5 and 8: Cans 9–15 and Cans 1, 2, 7, 8
|
||||
# Wander, 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
|
||||
|
||||
|
||||
class PlayLayer:
|
||||
@@ -65,6 +77,10 @@ class PlayLayer:
|
||||
self.threshold = False
|
||||
# Last value of each knob below, from the pad; QLC+ starts them at full.
|
||||
self.knobs = {cc: 127 for cc in (PEAK_CC, *SIDE_CCS)}
|
||||
# Pan and Tilt as last sent; QLC+ starts them at 0.
|
||||
self.position = {cc: 0 for cc in POSITION_CCS}
|
||||
self.moving: int | None = None
|
||||
self.settle = False # a relative EFX just went off: the caller sends nudge(), then positions()
|
||||
# set -> (channel, note sent) of the colour that is on
|
||||
self.colours: dict[int, tuple[int, int] | None] = {1: None, 2: None}
|
||||
|
||||
@@ -85,6 +101,9 @@ class PlayLayer:
|
||||
if data[1] == PEAK_CC:
|
||||
return [list(data), *self.sides()]
|
||||
return [] if self.pump else [list(data)]
|
||||
if kind == 0xB0 and len(data) >= 3 and channel == KNOB_CHANNEL and data[1] in self.position:
|
||||
self.position[data[1]] = data[2]
|
||||
return [list(data)]
|
||||
if kind not in (0x80, 0x90) or len(data) < 3:
|
||||
return [list(data)]
|
||||
key = (channel, data[1])
|
||||
@@ -114,6 +133,12 @@ class PlayLayer:
|
||||
extra = self.sides(restore=True)
|
||||
self.threshold = not self.threshold
|
||||
extra = [*extra, [0xB0, SUBMASTER_CC, 0 if self.threshold else 127]]
|
||||
elif note in RELATIVE_NOTES and is_on:
|
||||
if note == self.moving:
|
||||
self.moving = None
|
||||
self.settle = True
|
||||
else:
|
||||
self.moving = note
|
||||
if is_on and FIRST_NOTE <= out <= LAST_NOTE + SHIFT:
|
||||
colour_set = 1 if out <= LAST_NOTE else 2
|
||||
pressed = (channel, out)
|
||||
@@ -135,6 +160,7 @@ class PlayLayer:
|
||||
"""
|
||||
self.pump = False
|
||||
self.threshold = False
|
||||
self.moving = None
|
||||
out = []
|
||||
for colour in self.colours.values():
|
||||
if colour is not None:
|
||||
@@ -150,6 +176,15 @@ class PlayLayer:
|
||||
return [[0xB0 | KNOB_CHANNEL, cc, self.knobs[PEAK_CC]] for cc in SIDE_CCS]
|
||||
|
||||
|
||||
def nudge(self) -> list[list[int]]:
|
||||
"""Pan and Tilt one step off their knobs, so QLC+ writes them again."""
|
||||
return [[0xB0 | KNOB_CHANNEL, cc, v - 1 if v else 1] for cc, v in self.position.items()]
|
||||
|
||||
def positions(self) -> list[list[int]]:
|
||||
"""Pan and Tilt back at their knobs."""
|
||||
return [[0xB0 | KNOB_CHANNEL, cc, v] for cc, v in self.position.items()]
|
||||
|
||||
|
||||
def tap(channel: int, note: int) -> list[list[int]]:
|
||||
"""A press and release of note, to toggle a QLC+ button off."""
|
||||
return [[0x90 | channel, note, 127], [0x80 | channel, note, 0]]
|
||||
+20
-5
@@ -11,14 +11,18 @@ While Play is held, bank 2 notes 52–67 go out as 68–83 (see padcontroller/la
|
||||
|
||||
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.
|
||||
|
||||
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
|
||||
# optional: --tau 0.05 (seconds; lower = snappier, higher = silkier)
|
||||
@@ -39,6 +43,7 @@ import threading
|
||||
import time
|
||||
from dataclasses import dataclass, field
|
||||
from pathlib import Path
|
||||
from typing import Callable
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
import glob
|
||||
@@ -56,10 +61,11 @@ from pad_lamps import set_lamps, set_sound_lamps # noqa: E402
|
||||
VIRTUAL_NAME = "padcontroller"
|
||||
COLOURS_FILE = Path(os.environ.get("XDG_STATE_HOME", Path.home() / ".local" / "state")) / "padcontroller" / "colours.json"
|
||||
REOPEN_DELAY = 1.5 # s for QLC+ to finish loading the virtual console
|
||||
# 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
|
||||
# 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",
|
||||
@@ -222,6 +228,8 @@ def main() -> None:
|
||||
load_colours(layer)
|
||||
saved_colours = dict(layer.colours)
|
||||
reopen_at: float | None = None
|
||||
# (when, messages to send then), for the 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
|
||||
|
||||
@@ -242,7 +250,7 @@ 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
|
||||
@@ -289,6 +297,13 @@ def main() -> None:
|
||||
midiout.send_message(out)
|
||||
if sound_lamps:
|
||||
sound_lamps.show(layer.pump, layer.threshold)
|
||||
if layer.settle:
|
||||
layer.settle = False
|
||||
later += [(now + SETTLE_DELAY, layer.nudge), (now + 2 * SETTLE_DELAY, layer.positions)]
|
||||
for due in [item for item in later if now >= item[0]]:
|
||||
later.remove(due)
|
||||
for out in due[1]():
|
||||
midiout.send_message(out)
|
||||
if layer.colours != saved_colours:
|
||||
save_colours(layer)
|
||||
saved_colours = dict(layer.colours)
|
||||
|
||||
@@ -50,11 +50,13 @@ def set_sound_lamps(pump: bool, threshold: bool) -> None:
|
||||
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:
|
||||
# Free both clients when the Private port is missing too, or every
|
||||
# sound pad press on Bluetooth leaks two and fills the sequencer.
|
||||
index = midiout.get_ports().index(pad_colours.private_port(midiout.get_ports()))
|
||||
midiin.open_port(index)
|
||||
midiin.ignore_types(sysex=False, timing=True, active_sense=True)
|
||||
midiout.open_port(index)
|
||||
for base in pad_colours.bank_bases(1):
|
||||
for pad, rgb in lamps.items():
|
||||
address = RAM + base + pad * pad_colours.RECORD + pad_colours.RGB_AT
|
||||
|
||||
@@ -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()
|
||||
@@ -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()
|
||||
@@ -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()
|
||||
@@ -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()
|
||||
@@ -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()
|
||||
@@ -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()
|
||||
@@ -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()
|
||||
@@ -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()
|
||||
@@ -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()
|
||||
+668
-694
File diff suppressed because it is too large.
Load diff
@@ -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
@@ -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
|
||||
|
||||
|
||||
@@ -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
@@ -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
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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:
|
||||
|
||||
@@ -186,6 +186,43 @@ class PlayLayerTest(unittest.TestCase):
|
||||
def test_reopen_with_no_colours_only_resets_the_submaster(self):
|
||||
self.assertEqual(PlayLayer().reopen(), [[0xB0, 100, 127]])
|
||||
|
||||
def test_wander_off_settles_pan_and_tilt(self):
|
||||
layer = PlayLayer()
|
||||
self.assertEqual(layer.handle([0xB0, 38, 40]), [[0xB0, 38, 40]])
|
||||
layer.handle([0xB0, 39, 0])
|
||||
layer.handle(PAUSE_DOWN)
|
||||
self.assertEqual(layer.handle([0x99, 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_DOWN)
|
||||
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_every_movement_pad_settles_when_it_goes_off(self):
|
||||
for pad_note, sent in ((51, 99), (44, 92), (47, 95), (40, 88)):
|
||||
layer = PlayLayer()
|
||||
layer.handle(PAUSE_DOWN)
|
||||
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__":
|
||||
unittest.main()
|
||||
@@ -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():
|
||||
|
||||
+60
-12
@@ -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
|
||||
|
||||
Reference in new issue
Block a user