Add a movers bank and Pan, Tilt, Focus and Rotate knobs to the test show.
Pause toggles bank 1 between the cans and the movers (scripts/shows/mover_bank.py). Knobs 9-12 (CC 38-41) drive all four movers' pan, tilt, focus and lens rotate, as in templeoftechno.qxw (scripts/shows/mover_position.py). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
18f0ac2dc5
commit
86d87bf8cf
3 files changed
+1673
-514
No files matched your search
@@ -0,0 +1,210 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Add mover versions of the bank 1 pads to shows/test.qxw, on notes 84–99.
|
||||
|
||||
Pause on the pad toggles bank 1 between the cans and the movers: padcontroller
|
||||
sends bank 1 (notes 36–51) as 84–99 while it is on (padcontroller/layer.py).
|
||||
Each mover pad sits on its can pad's note plus 48:
|
||||
|
||||
92 Strobe flash the movers' centre strobe
|
||||
96 Chase a stripe through the 7 rings of all four movers
|
||||
97 Reverse the same, the other way
|
||||
98 Zigzag mover by mover, M3, M1, M2, M4 (back, front, front, back)
|
||||
99 Opposing rings outwards on the left movers, inwards on the right
|
||||
|
||||
The chases take their colour from the Colour 1 (cans) pads, as the cans'
|
||||
chases take theirs from Colour 2, so they stand out. Knob 15 (CC 44), the
|
||||
movers' level, is also their peak. The movers are not sound reactive: Sound and
|
||||
Threshold (84 and 85) do nothing on their layer.
|
||||
|
||||
python3 scripts/shows/mover_bank.py
|
||||
|
||||
Run it once on a show without them; it stops if they are already there.
|
||||
QLC+ has to reopen the show to see them.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
SHOW = ROOT / "shows" / "test.qxw"
|
||||
|
||||
MOVERS_SHIFT = 48 # padcontroller/layer.py
|
||||
NOTE_BASE = 36992 # QLC+ input channel of a channel-10 note: this plus the note
|
||||
LEVEL_CC = 44 # knob 15: the Movers level slider, and the movers' peak here
|
||||
|
||||
# Fixture IDs left to right on stage: M3 back left, M1 and M2 front, M4 back right.
|
||||
M1, M2, M3, M4 = 8, 9, 17, 18
|
||||
LEFT_TO_RIGHT = (M3, M1, M2, M4)
|
||||
RINGS = 7
|
||||
BRIGHTNESS, STROBE = 8, 9
|
||||
|
||||
GROUP_RINGS, GROUP_ZIGZAG, GROUP_OPPOSING = 5, 6, 7
|
||||
F_DIMMER, F_FWD, F_HOLD, F_REV, F_ZIG, F_ZIG_HOLD, F_OPP, F_STROBE = range(57, 65)
|
||||
NO_FUNCTION = 4294967295
|
||||
|
||||
|
||||
def note(can_note: int) -> int:
|
||||
return NOTE_BASE + can_note + MOVERS_SHIFT
|
||||
|
||||
|
||||
def group(gid: int, name: str, w: int, h: int, heads: list[tuple[int, int, int, int]]) -> str:
|
||||
rows = "\n".join(f' <Head X="{x}" Y="{y}" Fixture="{f}">{head}</Head>' for x, y, f, head in heads)
|
||||
return f' <FixtureGroup ID="{gid}">\n <Name>{name}</Name>\n <Size X="{w}" Y="{h}"/>\n{rows}\n </FixtureGroup>\n'
|
||||
|
||||
|
||||
def groups() -> str:
|
||||
# Rings down Y, one mover per column.
|
||||
rings = [(x, r, f, r) for x, f in enumerate(LEFT_TO_RIGHT) for r in range(RINGS)]
|
||||
# One mover per row, its rings across.
|
||||
zigzag = [(r, y, f, r) for y, f in enumerate(LEFT_TO_RIGHT) for r in range(RINGS)]
|
||||
# Left movers' rings run outwards as the right movers' run inwards.
|
||||
opposing = [(x, y, f, y if x < 2 else RINGS - 1 - y) for x, f in enumerate(LEFT_TO_RIGHT) for y in range(RINGS)]
|
||||
return (group(GROUP_RINGS, "Movers rings", 4, RINGS, rings)
|
||||
+ group(GROUP_ZIGZAG, "Movers zigzag", RINGS, 4, zigzag)
|
||||
+ group(GROUP_OPPOSING, "Movers opposing", 4, RINGS, opposing))
|
||||
|
||||
|
||||
def scene(fid: int, name: str, values: dict[int, int], fade_out: int = 0) -> str:
|
||||
vals = ",".join(f"{c},{v}" for c, v in values.items())
|
||||
rows = "\n".join(f' <FixtureVal ID="{f}">{vals}</FixtureVal>' for f in LEFT_TO_RIGHT)
|
||||
return (f' <Function ID="{fid}" Type="Scene" Name="{name}">\n'
|
||||
f' <Speed FadeIn="0" FadeOut="{fade_out}" Duration="0"/>\n{rows}\n </Function>\n')
|
||||
|
||||
|
||||
def matrix(fid: int, name: str, gid: int, direction: str, step_ms: int) -> str:
|
||||
return f""" <Function ID="{fid}" Type="RGBMatrix" Name="{name}">
|
||||
<Speed FadeIn="0" FadeOut="500" Duration="{step_ms}"/>
|
||||
<Direction>{direction}</Direction>
|
||||
<RunOrder>SingleShot</RunOrder>
|
||||
<Algorithm Type="Script">Stripes</Algorithm>
|
||||
<MonoColor>4294967040</MonoColor>
|
||||
<ControlMode>RGB</ControlMode>
|
||||
<FixtureGroup>{gid}</FixtureGroup>
|
||||
<Property Name="orientation" Value="Vertical"/>
|
||||
</Function>
|
||||
"""
|
||||
|
||||
|
||||
def chaser(fid: int, name: str, ms: int, step: int) -> str:
|
||||
return f""" <Function ID="{fid}" Type="Chaser" Name="{name}">
|
||||
<Speed FadeIn="0" FadeOut="0" Duration="{ms}"/>
|
||||
<Direction>Forward</Direction>
|
||||
<RunOrder>SingleShot</RunOrder>
|
||||
<SpeedModes FadeIn="Common" FadeOut="Common" Duration="Common"/>
|
||||
<Step Number="0" FadeIn="0" Hold="0" FadeOut="0">{step}</Step>
|
||||
</Function>
|
||||
"""
|
||||
|
||||
|
||||
def functions() -> str:
|
||||
# Each hold keeps the movers up while its run steps through, plus the run's fade.
|
||||
return (scene(F_DIMMER, "Movers dimmer", {BRIGHTNESS: 255, STROBE: 0})
|
||||
+ matrix(F_FWD, "Movers chase forward run", GROUP_RINGS, "Forward", 200)
|
||||
+ chaser(F_HOLD, "Movers dimmer hold", RINGS * 200 + 500, F_DIMMER)
|
||||
+ matrix(F_REV, "Movers chase reverse run", GROUP_RINGS, "Backward", 200)
|
||||
+ matrix(F_ZIG, "Movers zigzag run", GROUP_ZIGZAG, "Forward", 200)
|
||||
+ chaser(F_ZIG_HOLD, "Movers zigzag hold", 4 * 200 + 500, F_DIMMER)
|
||||
+ matrix(F_OPP, "Movers opposing run", GROUP_OPPOSING, "Forward", 200)
|
||||
+ scene(F_STROBE, "Movers strobe", {BRIGHTNESS: 255, STROBE: 230}, fade_out=50))
|
||||
|
||||
|
||||
def appearance(indent: str, style: str = "None") -> str:
|
||||
return (f"{indent}<Appearance>\n{indent} <FrameStyle>{style}</FrameStyle>\n"
|
||||
f"{indent} <ForegroundColor>Default</ForegroundColor>\n{indent} <BackgroundColor>Default</BackgroundColor>\n"
|
||||
f"{indent} <BackgroundImage>None</BackgroundImage>\n{indent} <Font>Default</Font>\n{indent}</Appearance>\n")
|
||||
|
||||
|
||||
def button(wid: int, caption: str, x: int, y: int, size: int, function: int, channel: int | None,
|
||||
action: str = "Toggle", indent: str = " ") -> str:
|
||||
inp = f'{indent} <Input Universe="1" Channel="{channel}"/>\n' if channel is not None else ""
|
||||
return (f'{indent}<Button Caption="{caption}" ID="{wid}" Icon="">\n'
|
||||
f'{indent} <WindowState Visible="True" X="{x}" Y="{y}" Width="{size}" Height="{size}"/>\n'
|
||||
+ appearance(indent + " ")
|
||||
+ f'{indent} <Function ID="{function}"/>\n{indent} <Action>{action}</Action>\n'
|
||||
f'{indent} <Intensity Adjust="False">100</Intensity>\n{inp}{indent}</Button>\n')
|
||||
|
||||
|
||||
def submaster(wid: int, caption: str, x: int, y: int, h: int, cc: int, indent: str) -> str:
|
||||
return (f'{indent}<Slider Caption="{caption}" ID="{wid}" WidgetStyle="Slider" InvertedAppearance="false">\n'
|
||||
f'{indent} <WindowState Visible="True" X="{x}" Y="{y}" Width="52" Height="{h}"/>\n'
|
||||
+ appearance(indent + " ", "Sunken")
|
||||
+ f'{indent} <Input Universe="1" Channel="{cc}"/>\n'
|
||||
f'{indent} <SliderMode ValueDisplayStyle="Exact" ClickAndGoType="None">Submaster</SliderMode>\n'
|
||||
f'{indent} <Level LowLimit="0" HighLimit="255" Value="255"/>\n'
|
||||
f'{indent} <Playback>\n{indent} <Function>{NO_FUNCTION}</Function>\n{indent} </Playback>\n{indent}</Slider>\n')
|
||||
|
||||
|
||||
def frame(wid: int, caption: str, x: int, y: int, w: int, h: int, body: str, indent: str = " ",
|
||||
header: bool = True, collapsed: bool = False) -> str:
|
||||
return (f'{indent}<Frame Caption="{caption}" ID="{wid}">\n'
|
||||
+ appearance(indent + " ", "Sunken")
|
||||
+ f'{indent} <WindowState Visible="True" X="{x}" Y="{y}" Width="{w}" Height="{h}"/>\n'
|
||||
f'{indent} <AllowChildren>True</AllowChildren>\n{indent} <AllowResize>True</AllowResize>\n'
|
||||
f'{indent} <ShowHeader>{header}</ShowHeader>\n{indent} <ShowEnableButton>False</ShowEnableButton>\n'
|
||||
f'{indent} <Collapsed>{collapsed}</Collapsed>\n{indent} <Disabled>False</Disabled>\n'
|
||||
f'{body}{indent}</Frame>\n')
|
||||
|
||||
|
||||
def vc(xml: str, next_id: int) -> str:
|
||||
"""The new widgets."""
|
||||
ids = iter(range(next_id, next_id + 100))
|
||||
w = {name: next(ids) for name in (
|
||||
"bank", "fwd", "rev", "zig", "opp", "strobe", "peak",
|
||||
"runs", "fwd_run", "rev_run", "zig_run", "opp_run",
|
||||
"colours", "fwd_col", "rev_col", "zig_col", "opp_col")}
|
||||
|
||||
bank = (button(w["fwd"], "Chase", 10, 10, 90, F_HOLD, note(48))
|
||||
+ button(w["rev"], "Chase reverse", 100, 10, 90, F_HOLD, note(49))
|
||||
+ button(w["zig"], "Zigzag", 190, 10, 90, F_ZIG_HOLD, note(50))
|
||||
+ button(w["opp"], "Opposing", 280, 10, 90, F_HOLD, note(51))
|
||||
+ button(w["strobe"], "Strobe", 10, 100, 90, F_STROBE, note(44), action="Flash")
|
||||
+ submaster(w["peak"], "Peak", 378, 10, 360, LEVEL_CC, " "))
|
||||
runs = (button(w["fwd_run"], "Chase run", 10, 10, 70, F_FWD, note(48))
|
||||
+ button(w["rev_run"], "Reverse run", 80, 10, 70, F_REV, note(49))
|
||||
+ button(w["zig_run"], "Zigzag run", 150, 10, 70, F_ZIG, note(50))
|
||||
+ button(w["opp_run"], "Opposing run", 220, 10, 70, F_OPP, note(51)))
|
||||
|
||||
# The cans' Forward colour matrix follows the Colour 2 pads; these follow Colour 1, 16 notes lower.
|
||||
template = re.search(r' <Matrix Caption="Forward colour" ID="61">.*? </Matrix>\n', xml, re.S).group(0)
|
||||
|
||||
def colour_matrix(wid: int, caption: str, fid: int, x: int, y: int) -> str:
|
||||
m = template.replace('Caption="Forward colour" ID="61"', f'Caption="{caption}" ID="{wid}"')
|
||||
m = m.replace('<Function ID="43" InstantApply', f'<Function ID="{fid}" InstantApply')
|
||||
m = re.sub(r'X="\d+" Y="\d+" Width', f'X="{x}" Y="{y}" Width', m, count=1)
|
||||
return re.sub(r'Channel="(\d+)"', lambda c: f'Channel="{int(c.group(1)) - 16}"', m)
|
||||
|
||||
colours = (colour_matrix(w["fwd_col"], "Movers chase colour", F_FWD, 10, 45)
|
||||
+ colour_matrix(w["rev_col"], "Movers reverse colour", F_REV, 320, 45)
|
||||
+ colour_matrix(w["zig_col"], "Movers zigzag colour", F_ZIG, 10, 275)
|
||||
+ colour_matrix(w["opp_col"], "Movers opposing colour", F_OPP, 320, 275))
|
||||
|
||||
return (frame(w["bank"], "Movers pads", 1740, 5, 440, 380, bank, header=False)
|
||||
+ frame(w["runs"], "Movers chase runs", 1740, 400, 310, 120, runs)
|
||||
+ frame(w["colours"], "Movers chase colours", 1740, 530, 640, 510, colours, collapsed=True))
|
||||
|
||||
|
||||
def main() -> None:
|
||||
xml = SHOW.read_text()
|
||||
if "Movers chase forward run" in xml:
|
||||
raise SystemExit(f"{SHOW.relative_to(ROOT)} already has the mover pads")
|
||||
next_id = max(int(i) for i in re.findall(r' ID="(\d+)"', xml.split("<VirtualConsole>")[1])
|
||||
if int(i) != NO_FUNCTION) + 1
|
||||
widgets = vc(xml, next_id)
|
||||
|
||||
# The strobe flash is HTP so it beats the colour scenes' centre strobe of 0, as on the cans.
|
||||
for fid in LEFT_TO_RIGHT:
|
||||
xml = re.sub(rf"( <ID>{fid}</ID>\n(?: .*\n)*? <Channels>43</Channels>\n)",
|
||||
rf"\1 <ForcedHTP>{STROBE}</ForcedHTP>\n", xml, count=1)
|
||||
xml = xml.replace(' <Function ID="0" Type="Scene"', groups() + ' <Function ID="0" Type="Scene"', 1)
|
||||
xml = xml.replace(" </Engine>", functions() + " </Engine>", 1)
|
||||
|
||||
xml = xml.replace(" </Frame>\n <Properties>", widgets + " </Frame>\n <Properties>", 1)
|
||||
xml = xml.replace('<Size Width="1880" Height="950"/>', '<Size Width="2400" Height="1050"/>', 1)
|
||||
SHOW.write_text(xml)
|
||||
print(f"Added the mover pads to {SHOW.relative_to(ROOT)} (widgets from ID {next_id})")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user