Merge dev into main: the pad controller, simulator, Chataigne export and test show.

Keep main's Temple of Techno show over dev's older copy from the first venue
workspaces commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Opus 5.5 committed 2026-10-22 20:00:21 +13:00
commit 72c227b153
106 files changed
+33054 -420

No files matched your search

+152
View File
@@ -0,0 +1,152 @@
#!/usr/bin/env python3
"""Add two sets of 16 colour scenes and their buttons to shows/test.show.json.
Colour 1 paints all 15 cans and colour 2 the four movers, so one colour
for each can be on at once. Each set is a solo frame and every scene
fades in and out over FADE_MS. Bank 2 (notes 52–67) picks colour 1.
Holding Play picks set B: the pad controller turns those notes into 68–83 while
Play is down. Bank 1 is kept for animations.
python3 scripts/shows/colour_sets.py && python3 -m showfile write shows/test.show.json -o shows/test.qxw
The sliders are Playback sliders over five scenes per set (Dim, R, G, B, W),
so they never override a channel. Knobs 1–5 move colour 1's sliders and knobs
6–10 colour 2's. Run the pad controller with --lock-knobs to make them work only
after the Custom pad is pressed; any other pad sends them back to zero (see
padcontroller/layer.py).
"""
from __future__ import annotations
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
SPEC = ROOT / "shows" / "test.show.json"
FADE_MS = 1000
DIMMER, RED, GREEN, BLUE, WHITE = 0, 2, 3, 4, 5
PAD_BANK_2_FIRST_NOTE = 52
HELD_FIRST_NOTE = 68 # padcontroller/layer.py sends bank 2 here while Play is held
PROFILE = "M-VAVE SMC-PAD"
OMNI = 16 # QLC+ MIDI plugin channel that accepts every MIDI channel
PAD_MIDI_CH = 9 # the pads send notes on channel 10
KNOB_FIRST_CC = 30 # pad knob 1; colour 2's sliders follow colour 1's
PAD_PORT = "padcontroller" # padcontroller/midi.py; it applies the Play layer
# name, r, g, b, w. Bottom row first, four to a row. The cans have a white emitter, so the whites use it.
COLOURS = (
("Red", 255, 0, 0, 0),
("Orange", 255, 127, 0, 0),
("Yellow", 255, 255, 0, 0),
("Lime", 127, 255, 0, 0),
("Green", 0, 255, 0, 0),
("Spring", 0, 255, 127, 0),
("Cyan", 0, 255, 255, 0),
("Azure", 0, 127, 255, 0),
("Blue", 0, 0, 255, 0),
("Violet", 127, 0, 255, 0),
("Magenta", 255, 0, 255, 0),
("Pink", 255, 40, 120, 0),
("Warm", 255, 120, 40, 120),
("White", 0, 0, 0, 255),
("Cool", 80, 120, 255, 120),
)
# The top-right pad is the custom colour. Its button shows this swatch, but
# its scene is dark: the sliders next to it mix the colour from five scenes.
# Its pad lamp stays off.
CUSTOM = (("Custom", 255, 60, 0, 0),)
CANS = [f"#{n}" for n in range(1, 16)]
MOVERS = ["M1", "M2", "M3", "M4"]
# Mover channels: 8 is centre brightness, 9 centre strobe, then seven R G B W groups from 10.
MOVER_BRIGHTNESS, MOVER_STROBE, MOVER_GROUPS, MOVER_FIRST_COLOUR = 8, 9, 7, 10
def swatch(r: int, g: int, b: int, w: int) -> list[int]:
return [min(255, r + w), min(255, g + w), min(255, b + w)]
# Mixer beside each grid: caption, can channel, offset in a mover colour group (None is brightness).
SLIDERS = (
("Dim", DIMMER, None, [255, 255, 255]),
("R", RED, 0, [255, 0, 0]),
("G", GREEN, 1, [0, 255, 0]),
("B", BLUE, 2, [0, 0, 255]),
("W", WHITE, 3, [255, 255, 255]),
)
def component(cans: list[str], movers: list[str], can_channel: int, offset: int | None) -> dict:
"""One channel kind of this set at full, for a Playback slider to scale."""
values = {can: {can_channel: 255} for can in cans}
for mover in movers:
if offset is None:
values[mover] = {MOVER_BRIGHTNESS: 255}
else:
values[mover] = {MOVER_FIRST_COLOUR + group * 4 + offset: 255 for group in range(MOVER_GROUPS)}
return values
def custom_off(cans: list[str], movers: list[str]) -> dict:
"""The Custom pad's own scene: dark, so the sliders' scenes set the colour."""
values = {can: {DIMMER: 0} for can in cans}
values.update({mover: {MOVER_BRIGHTNESS: 0} for mover in movers})
return values
def sliders(label: str, first_cc: int) -> list[dict]:
"""Playback sliders. Each scales its own scene, so nothing is overridden."""
return [{
"type": "slider", "caption": caption, "function": f"custom_{label}_{caption}",
"x": 400 + index * 52, "y": 10, "w": 48, "h": 200, "fg": fg,
"input": {"universe": 1, "cc": [0, first_cc + index]},
} for index, (caption, _can, _offset, fg) in enumerate(SLIDERS)]
def main() -> None:
spec = json.loads(SPEC.read_text())
spec["universes"][1]["input"] = {"plugin": "MIDI", "uid": PAD_PORT, "profile": PROFILE, "channel": OMNI, "line": 0}
functions, frames = [], []
for si, (label, cans, movers) in enumerate((("1", CANS, []), ("2", [], MOVERS))):
buttons = []
for i, (name, r, g, b, w) in enumerate(COLOURS + CUSTOM):
key = f"colour_{label}_{i + 1}"
on = 255
values = {can: {DIMMER: on, RED: r, GREEN: g, BLUE: b, WHITE: w} for can in cans}
for mover in movers:
values[mover] = {MOVER_BRIGHTNESS: on, MOVER_STROBE: 0}
for group in range(MOVER_GROUPS):
first = MOVER_FIRST_COLOUR + group * 4
values[mover].update({first: r, first + 1: g, first + 2: b, first + 3: w})
if name == CUSTOM[0][0]:
values = custom_off(cans, movers)
functions.append({
"key": key, "type": "scene", "name": f"{label} {name}",
"fade_in": FADE_MS, "fade_out": FADE_MS, "values": values,
})
sw = swatch(r, g, b, w)
dark = sum(sw) > 380
button = {
"type": "button", "caption": name, "function": key,
# 4 wide like the pads: the first four colours are the bottom row.
"x": 10 + (i % 4) * 96, "y": 10 + (3 - i // 4) * 66, "w": 90, "h": 60,
"bg": sw,
"fg": [0, 0, 0] if dark else [255, 255, 255],
}
button["input"] = {"universe": 1, "note": [PAD_MIDI_CH, (HELD_FIRST_NOTE if si else PAD_BANK_2_FIRST_NOTE) + i]}
buttons.append(button)
for caption, can_channel, offset, _fg in SLIDERS:
functions.append({
"key": f"custom_{label}_{caption}", "type": "scene", "name": f"{label} Custom {caption}",
"values": component(cans, movers, can_channel, offset),
})
frames.append({
"type": "solo", "caption": f"Colour {label}", "x": 10, "y": 10 + si * 310,
"w": 400 + len(SLIDERS) * 52, "h": 300, "children": buttons + sliders(label, KNOB_FIRST_CC + si * len(SLIDERS)),
})
spec["functions"] = functions
spec["vc"] = frames
SPEC.write_text(json.dumps(spec, indent=2) + "\n")
if __name__ == "__main__":
main()
File diff suppressed because it is too large. Load diff
+366
View File
@@ -0,0 +1,366 @@
#!/usr/bin/env python3
"""Rewrite xchc pattern scenes so the U of cans + centre movers act as one.
Building 7 m wide. Coordinates in metres:
X = 0 at centre line, +X to the right
Y = 0 at the row of 4, +Y toward audience (in front of the 4)
Audience
1 8 ← wall-mounted sides @ 2.4 m in front of the 4
2 M1 M2 7 ← wall-mounted sides @ 1.2 m; movers @ 1.1 m, ±0.3 m
3 — 4 — 5 — 6 ← row of 4 at ±0.6 m and ±1.8 m from centre
Building 7 m → side walls at ±3.5 m. #1,#2 left wall; #7,#8 right wall.
#1 front left. Movers 1.1 m in front of the row of 4, 0.3 m off centre.
"""
from __future__ import annotations
import re
from pathlib import Path
CANS = list(range(8))
MOVERS = (8, 9)
WALL = 3.5 # building half-width
# Fixture ID → (x_m, y_m) — Y=0 = row of 4; +Y toward audience
LAYOUT_M = {
0: (-WALL, 2.4), # #1 front left — left wall
1: (-WALL, 1.2), # #2 — left wall
2: (-1.8, 0.0), # #3 row of 4
3: (-0.6, 0.0), # #4 row of 4
4: (0.6, 0.0), # #5 row of 4
5: (1.8, 0.0), # #6 row of 4
6: (WALL, 1.2), # #7 — right wall
7: (WALL, 2.4), # #8 front right — right wall
8: (-0.3, 1.1), # Small Eye #1 — 0.3 m off centre, 1.1 m in front of row of 4
9: (0.3, 1.1), # Small Eye #2 — 0.3 m off centre, 1.1 m in front of row of 4
}
# Walk U: #1 → #2 → along row of 4 L→R → #7 → #8
U_WALK = [0, 1, 2, 3, 4, 5, 6, 7]
LEFT_SIDE = {0, 1}
RIGHT_SIDE = {6, 7}
ROW4 = {2, 3, 4, 5}
RINGS = [
{8, 9},
{8, 9, 3, 4}, # movers + centre of row of 4
{8, 9, *ROW4},
{8, 9, *CANS},
]
LEFT = LEFT_SIDE | {2, 3, 8}
RIGHT = RIGHT_SIDE | {4, 5, 9}
GRID_W = 7.0
GRID_H = 3.2
X_ORIGIN = -3.5
def m_to_grid(x_m: float, y_m: float) -> tuple[float, float]:
gx = round(x_m - X_ORIGIN, 2)
# Row of 4 (y=0) toward top; audience / front sides toward bottom
gy = round(y_m, 2)
return gx, gy
COLORS = {
"Red": (255, 0, 0),
"Orange": (255, 127, 0),
"Yellow": (255, 255, 0),
"Green": (0, 255, 0),
"Cyan": (0, 255, 255),
"Blue": (0, 0, 255),
"Violet": (127, 0, 255),
"Magenta": (255, 0, 255),
"White": (255, 255, 255),
}
RAINBOW = [
(255, 0, 0),
(255, 127, 0),
(255, 255, 0),
(0, 255, 0),
(0, 255, 255),
(0, 0, 255),
(127, 0, 255),
(255, 0, 255),
]
def can_channels(r: int, g: int, b: int, *, white: int = 0, on: bool = True) -> str:
if not on:
return "0,0,1,0,2,0,3,0,4,0,5,0,6,0,7,0"
if white:
return f"1,0,2,0,3,0,4,0,5,{white},6,0,7,0"
return f"1,0,2,{r},3,{g},4,{b},5,0,6,0,7,0"
def mover_channels(r: int, g: int, b: int, *, on: bool = True, dim: int = 255) -> str:
if not on or (r == g == b == 0):
dim = 0
r = g = b = 0
parts = [
0, 128, 2, 80, 4, 0, 5, 0, 6, 191, 7, 70, 8, dim, 9, 0,
10, r, 11, g, 12, b, 13, 0,
]
for pixel in range(1, 7):
base = 10 + pixel * 4
parts.extend([base, 0, base + 1, 0, base + 2, 0, base + 3, 0])
return ",".join(str(x) for x in parts)
def fixture_vals(
lit: dict[int, tuple[int, int, int] | None], *, white_ids: set[int] | None = None
) -> str:
white_ids = white_ids or set()
lines = []
for fid in list(CANS) + list(MOVERS):
rgb = lit.get(fid)
if rgb is None:
ch = (
mover_channels(0, 0, 0, on=False)
if fid in MOVERS
else can_channels(0, 0, 0, on=False)
)
lines.append(f' <FixtureVal ID="{fid}">{ch}</FixtureVal>')
continue
r, g, b = rgb
if fid in MOVERS:
ch = mover_channels(r, g, b)
elif fid in white_ids:
ch = can_channels(0, 0, 0, white=255)
else:
ch = can_channels(r, g, b)
lines.append(f' <FixtureVal ID="{fid}">{ch}</FixtureVal>')
return "\n".join(lines)
def scene(
fid: int,
name: str,
lit: dict,
*,
white_ids: set[int] | None = None,
fade: int = 0,
) -> str:
return f""" <Function ID="{fid}" Type="Scene" Name="{name}">
<Speed FadeIn="{fade}" FadeOut="0" Duration="{fade}" />
{fixture_vals(lit, white_ids=white_ids)}
</Function>"""
def replace_function(text: str, function_id: int, new_xml: str) -> str:
pattern = re.compile(
rf' <Function ID="{function_id}"[\s\S]*?</Function>\n',
re.MULTILINE,
)
if not pattern.search(text):
raise SystemExit(f"Function ID {function_id} not found")
return pattern.sub(new_xml.rstrip() + "\n", text, count=1)
def all_color(rgb: tuple[int, int, int]) -> dict:
lit = {i: rgb for i in CANS}
lit[8] = rgb
lit[9] = rgb
return lit
def monitor_xml() -> str:
items = []
for fid, (xm, ym) in LAYOUT_M.items():
gx, gy = m_to_grid(xm, ym)
items.append(f' <FxItem ID="{fid}" XPos="{gx}" YPos="{gy}" />')
return f""" <Monitor DisplayMode="1" ShowLabels="1">
<Font>Arial,12,-1,5,50,0,0,0,0,0</Font>
<ChannelStyle>0</ChannelStyle>
<ValueStyle>0</ValueStyle>
<Grid Width="{GRID_W}" Height="{GRID_H}" Depth="5" Units="0" />
{chr(10).join(items)}
</Monitor>"""
def main():
path = Path(__file__).resolve().parents[2] / "shows" / "xchc.qxw"
text = path.read_text()
for i, (name, rgb) in enumerate(COLORS.items()):
white_ids = set(CANS) if name == "White" else None
text = replace_function(text, i, scene(i, name, all_color(rgb), white_ids=white_ids))
for step in range(8):
lit = {}
for ci, can in enumerate(U_WALK):
lit[can] = RAINBOW[(ci + step) % 8]
lit[8] = RAINBOW[(3 + step) % 8]
lit[9] = RAINBOW[(4 + step) % 8]
text = replace_function(text, 10 + step, scene(10 + step, f"Rainbow {step + 1}", lit))
blue, red = (0, 0, 255), (255, 0, 0)
odd_blue, odd_red = {}, {}
for i in CANS:
if i % 2 == 0:
odd_blue[i], odd_red[i] = blue, red
else:
odd_blue[i], odd_red[i] = red, blue
odd_blue[8], odd_blue[9] = blue, red
odd_red[8], odd_red[9] = red, blue
text = replace_function(text, 20, scene(20, "Odd Blue Even Red", odd_blue))
text = replace_function(text, 21, scene(21, "Odd Red Even Blue", odd_red))
off = {i: None for i in list(CANS) + list(MOVERS)}
text = replace_function(text, 23, scene(23, "Test Off", off))
text = replace_function(text, 72, scene(72, "Soft Blackout", off, fade=4000))
for i, can in enumerate(U_WALK):
lit = {fid: None for fid in list(CANS) + list(MOVERS)}
lit[can] = (255, 255, 255)
text = replace_function(
text, 33 + i, scene(33 + i, f"Scanner {i + 1}", lit, white_ids={can})
)
for mid, name, ids in ((99, "Scanner Movers", {8, 9}), (100, "Scanner Off", set())):
lit = {fid: None for fid in list(CANS) + list(MOVERS)}
for m in ids:
lit[m] = (255, 255, 255)
block = scene(mid, name, lit)
if f'Function ID="{mid}"' in text:
text = replace_function(text, mid, block)
else:
text = text.replace(
' <Function ID="41" Type="Chaser" Name="Scanner">',
block + '\n <Function ID="41" Type="Chaser" Name="Scanner">',
1,
)
scanner_steps = "\n".join(
f' <Step Number="{i}" FadeIn="0" Hold="400" FadeOut="0">{sid}</Step>'
for i, sid in enumerate([*range(33, 41), 99, 100])
)
text = replace_function(
text,
41,
f""" <Function ID="41" Type="Chaser" Name="Scanner">
<Speed FadeIn="0" FadeOut="0" Duration="400" />
<Direction>Forward</Direction>
<RunOrder>Loop</RunOrder>
<SpeedModes FadeIn="Common" FadeOut="Common" Duration="Common" />
{scanner_steps}
</Function>""",
)
for n in range(1, 9):
lit = {fid: None for fid in list(CANS) + list(MOVERS)}
for can in U_WALK[:n]:
lit[can] = (255, 255, 255)
if n >= 3:
lit[8] = lit[9] = (255, 255, 255)
white = {c for c in U_WALK[:n]}
text = replace_function(
text, 41 + n, scene(41 + n, f"Fill {n}", lit, white_ids=white)
)
for i, ring in enumerate(RINGS):
lit = {fid: None for fid in list(CANS) + list(MOVERS)}
white = {f for f in ring if f in CANS}
for fid in ring:
lit[fid] = (255, 255, 255)
text = replace_function(
text, 51 + i, scene(51 + i, f"Center {i + 1}", lit, white_ids=white)
)
for i, (ids, name) in enumerate(
[
({0, 7}, "Pairs 1"),
({1, 6}, "Pairs 2"),
({2, 5}, "Pairs 3"),
({3, 4, 8, 9}, "Pairs 4"),
]
):
lit = {fid: None for fid in list(CANS) + list(MOVERS)}
white = {f for f in ids if f in CANS}
for fid in ids:
lit[fid] = (255, 255, 255)
text = replace_function(text, 56 + i, scene(56 + i, name, lit, white_ids=white))
lbrr = {fid: None for fid in list(CANS) + list(MOVERS)}
lrbr = {fid: None for fid in list(CANS) + list(MOVERS)}
for fid in LEFT:
lbrr[fid], lrbr[fid] = (0, 0, 255), (255, 0, 0)
for fid in RIGHT:
lbrr[fid], lrbr[fid] = (255, 0, 0), (0, 0, 255)
text = replace_function(text, 61, scene(61, "Left Blue Right Red", lbrr))
text = replace_function(text, 62, scene(62, "Left Red Right Blue", lrbr))
for step in range(3):
lit = {fid: None for fid in list(CANS) + list(MOVERS)}
white = set()
for can in CANS:
if can % 3 == step:
lit[can] = (255, 255, 255)
white.add(can)
if step == 0:
lit[8] = (255, 255, 255)
elif step == 1:
lit[9] = (255, 255, 255)
else:
lit[8] = lit[9] = (255, 200, 140)
text = replace_function(
text, 64 + step, scene(64 + step, f"Theater {step + 1}", lit, white_ids=white)
)
collapse_steps = "\n".join(
f' <Step Number="{i}" FadeIn="200" Hold="300" FadeOut="0">{sid}</Step>'
for i, sid in enumerate([54, 53, 52, 51, 23])
)
text = replace_function(
text,
68,
f""" <Function ID="68" Type="Chaser" Name="Collapse In">
<Speed FadeIn="200" FadeOut="0" Duration="500" />
<Direction>Forward</Direction>
<RunOrder>SingleShot</RunOrder>
<SpeedModes FadeIn="Common" FadeOut="Common" Duration="Common" />
{collapse_steps}
</Function>""",
)
chase_steps = "\n".join(
f' <Step Number="{i}" FadeIn="0" Hold="300" FadeOut="0">{sid}</Step>'
for i, sid in enumerate([*range(33, 41), 99, 23])
)
text = replace_function(
text,
69,
f""" <Function ID="69" Type="Chaser" Name="Chase Out">
<Speed FadeIn="0" FadeOut="0" Duration="400" />
<Direction>Forward</Direction>
<RunOrder>SingleShot</RunOrder>
<SpeedModes FadeIn="Common" FadeOut="Common" Duration="Common" />
{chase_steps}
</Function>""",
)
text = replace_function(
text, 70, scene(70, "Home Soft", all_color((255, 180, 80)), fade=2500)
)
text = re.sub(
r' <Monitor DisplayMode="1" ShowLabels="1">[\s\S]*?</Monitor>',
lambda _m: monitor_xml(),
text,
count=1,
)
text = text.replace("<Name>BCC145 Line</Name>", "<Name>BCC145 U</Name>", 1)
path.write_text(text)
print("Updated", path)
print("Y=0 row of 4; +Y toward audience (in front of the 4)")
for fid in sorted(LAYOUT_M):
x, y = LAYOUT_M[fid]
label = f"Can #{fid + 1}" if fid < 8 else f"Mover #{fid - 7}"
print(f" {label:10} x={x:+.1f} y={y:.1f}")
if __name__ == "__main__":
main()
File diff suppressed because it is too large. Load diff
+325
View File
@@ -0,0 +1,325 @@
#!/usr/bin/env python3
"""Write a Chataigne project from a show spec.
python3 scripts/shows/make_chataigne.py shows/test.show.json chataigne/test
Writes <out>/<name>.noisette and <out>/<name>.js. The script holds the scenes and
the pad and slider mapping, and sends DMX through the project's DMX module, named Lights, and a copy to Preview. Solo
frames and scene fades follow what QLC+ does with the same spec.
"""
from __future__ import annotations
import argparse
import json
import struct
import zlib
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
TEMPLATE = ROOT / "chataigne" / "show.template.js"
def absolute_levels(show: dict, stage: dict, values: dict[str, dict[str, int]]) -> dict[int, int]:
"""Map a scene's fixture channels to 1-based DMX channels in the output universe."""
levels: dict[int, int] = {}
for key, channels in values.items():
fixture = stage["fixtures"][key]
for offset, level in channels.items():
levels[int(fixture["address"]) + int(offset) + 1] = int(level)
return levels
SCALE = 1.25
MARGIN = 10
BUTTON = 28
def clear_png() -> bytes:
"""A 4x4 fully transparent PNG, for a trigger that should show what is behind it."""
def chunk(kind: bytes, data: bytes) -> bytes:
body = kind + data
return struct.pack(">I", len(data)) + body + struct.pack(">I", zlib.crc32(body))
rows = b"".join(b"\x00" + b"\x00" * 16 for _ in range(4))
return (
b"\x89PNG\r\n\x1a\n"
+ chunk(b"IHDR", struct.pack(">IIBBBBB", 4, 4, 8, 6, 0, 0, 0))
+ chunk(b"IDAT", zlib.compress(rows))
+ chunk(b"IEND", b"")
)
def script_path(name: str) -> str:
"""Chataigne names the script after its file and the module after its title."""
return f"/modules/pad/scripts/{name}/params/"
def ident(prefix: str, number: int, name: str) -> str:
"""A control name Chataigne keeps as written: letters and digits, lower-case first."""
return f"{prefix}{number}" + "".join(c for c in name if c.isalnum())
def collect(show: dict, stage: dict) -> dict:
functions = {f["key"]: f for f in show["functions"]}
groups: dict[str, dict] = {}
for number, frame in enumerate(show["vc"], 1):
pads, sliders = [], []
for widget in frame.get("children", []):
kind = widget["type"]
function = functions[widget["function"]]
binding = widget.get("input") or {}
levels = absolute_levels(show, stage, function["values"])
if kind == "button" and "note" in binding:
pads.append({
"id": ident("c", number, widget["caption"]),
"box": box(frame, widget),
"bg": widget.get("bg", [60, 60, 60]),
"fg": widget.get("fg", [255, 255, 255]),
"note": binding["note"][1],
"name": widget["caption"],
"fade": [function.get("fade_in") or 0, function.get("fade_out") or 0],
"levels": levels,
})
elif kind == "slider" and "cc" in binding:
sliders.append({
"id": ident("s", number, widget["caption"]),
"box": box(frame, widget),
"fg": widget.get("fg", [255, 255, 255]),
"cc": binding["cc"][1],
"name": widget["caption"],
"levels": levels,
})
if pads or sliders:
groups[frame["caption"]] = {
"name": frame["caption"],
"now": f"now{number}",
"box": box(frame, {"x": 0, "y": -30, "w": frame["w"], "h": 26}),
"pads": pads,
"sliders": sliders,
}
return groups
def box(frame: dict, widget: dict) -> list[int]:
"""x, y, w, h of a widget on the dashboard. Frames sit side by side, as on the virtual console."""
return [round((frame["x"] + widget["x"]) * SCALE), round((frame["y"] + widget["y"]) * SCALE + 40),
round(widget["w"] * SCALE), round(widget["h"] * SCALE)]
def colour(rgb: list[int]) -> int:
"""A Chataigne colour value: ARGB as a signed 32-bit int."""
argb = (255 << 24) | (rgb[0] << 16) | (rgb[1] << 8) | rgb[2]
return argb - (1 << 32) if argb >= 1 << 31 else argb
def js_levels(levels: dict[int, int]) -> str:
return "[" + ",".join(f"{ch},{level}" for ch, level in sorted(levels.items())) + "]"
def render_data(groups: dict) -> str:
lines = ["var GROUPS = ["]
for caption, group in groups.items():
lines.append(" {")
lines.append(f" name: {json.dumps(caption)},")
lines.append(f" now: {json.dumps(group['now'])},")
lines.append(" pads: [")
for pad in group["pads"]:
lines.append(
f" {{id: {json.dumps(pad['id'])}, rgb: {json.dumps([round(c / 255, 3) for c in pad['bg']])}, note: {pad['note']}, name: {json.dumps(pad['name'])}, "
f"fadeIn: {pad['fade'][0]}, fadeOut: {pad['fade'][1]}, levels: {js_levels(pad['levels'])}}},"
)
lines.append(" ],")
lines.append(" sliders: [")
for slider in group["sliders"]:
lines.append(
f" {{id: {json.dumps(slider['id'])}, cc: {slider['cc']}, name: {json.dumps(slider['name'])}, levels: {js_levels(slider['levels'])}}},"
)
lines.append(" ]")
lines.append(" },")
lines.append("];")
return "\n".join(lines)
def dashboard_item(index: int, kind: str, target: str, box: list[int], label: str, colours: dict[str, list[int]]) -> dict:
parameters = [
{"value": [float(box[0]), float(box[1])], "controlAddress": "/viewUIPosition"},
{"value": [float(box[2]), float(box[3])], "controlAddress": "/viewUISize"},
{"value": target, "controlAddress": "/target"},
{"value": label, "controlAddress": "/customText", "enabled": True},
]
for address, rgb in colours.items():
parameters.append({"value": colour(rgb), "controlAddress": address, "enabled": True})
return {
"parameters": parameters,
"niceName": f"Item {index}",
"type": kind,
"ghostAddress": target,
"controllable": target,
}
def dashboard(groups: dict, name: str, view: tuple[int, int], overlay: str | None) -> dict:
"""A dashboard with a tile and button per pad, a slider per knob, and what each group is showing."""
items = []
for group in groups.values():
items.append(dashboard_item(
len(items) + 1, "DashboardParameterItem", script_path(name) + group["now"],
group["box"], group["name"], {},
))
for pad in group["pads"]:
x, y, w, h = pad["box"]
# Triggers draw grey whatever colour they are given, but a colour control always paints.
# The tile carries the colour and name; the trigger on it is a transparent image that takes the press.
small = overlay is None
tile = dashboard_item(
len(items) + 1, "DashboardParameterItem", script_path(name) + pad["id"] + "Lamp",
[x, y, w, h - BUTTON - 2 if small else h], pad["name"], {"/textColor": [255, 255, 255]},
)
tile["parameters"] += [
{"value": True, "controlAddress": "/readOnly"},
{"value": False, "controlAddress": "/showValue"},
]
items.append(tile)
press = dashboard_item(
len(items) + 1, "DashboardTriggerItem", script_path(name) + pad["id"],
[x, y + h - BUTTON, w, BUTTON] if small else [x, y, w, h], "Select" if small else "",
{"/backgroundColor": pad["bg"], "/textColor": pad["fg"]},
)
if overlay:
# A custom label that is a single space: with none, the trigger draws its own name.
press["parameters"][3].update({"value": " ", "enabled": True})
press["parameters"].append({"value": False, "controlAddress": "/showLabel"})
press["parameters"].append({"value": overlay, "controlAddress": "/customImage", "enabled": True})
items.append(press)
for slider in group["sliders"]:
items.append(dashboard_item(
len(items) + 1, "DashboardParameterItem", script_path(name) + slider["id"], slider["box"], slider["name"],
{"/foregroundColor": slider["fg"]},
))
# Dashboard coordinates start at the middle of the view, so move the board to its top left.
left = min(i["parameters"][0]["value"][0] for i in items)
top = min(i["parameters"][0]["value"][1] for i in items)
for i in items:
position = i["parameters"][0]["value"]
position[0] += MARGIN - view[0] / 2 - left
position[1] += MARGIN - view[1] / 2 - top
return {
"parameters": [{"value": False, "controlAddress": "/editMode"}],
"items": [
{
"niceName": "Board",
"type": "BaseItem",
"itemManager": {
# The web page puts the middle of the canvas at 0, 0, so the canvas has to be the view's size
# for the board to start at its top left.
"parameters": [{"value": [float(view[0]), float(view[1])], "controlAddress": "/canvasSize", "enabled": True}],
"items": items,
"viewOffset": [0, 0],
"viewZoom": 1.0,
},
}
],
"viewOffset": [0, 0],
"viewZoom": 1.0,
}
def dmx_module(name: str, host: str, universe: int, interface: str | None) -> dict:
device: dict = {"containers": {"output": {"parameters": [{"value": host, "controlAddress": "/remoteHost"}]}}}
if interface:
device["parameters"] = [{"value": interface, "controlAddress": "/networkInterface"}]
return {
"niceName": name,
"type": "DMX",
"params": {
"parameters": [
{"value": "Art-Net", "controlAddress": "/dmxType"},
{"value": 40, "controlAddress": "/sendRate"},
],
"containers": {
"artNet": {"containers": {"output": {"parameters": [{"value": host, "controlAddress": "/remoteHost"}]}}},
"outputUniverses": {
"items": [
{
"niceName": "Universe",
"parameters": [
{"value": 0, "controlAddress": "/net"},
{"value": 0, "controlAddress": "/subnet"},
{"value": universe, "controlAddress": "/universe"},
],
}
]
}
},
},
"device": device,
}
def project(
script: str, host: str, universe: int, interface: str, groups: dict, preview: str | None, pad: str, view: tuple[int, int], overlay: str | None
) -> dict:
"""A Chataigne project: a DMX module on Art-Net and a MIDI module that runs the show script."""
dmx = [dmx_module("Lights", host, universe, interface)]
if preview:
dmx.append(dmx_module("Preview", preview, universe, None))
midi = {
"niceName": "Pad",
"type": "MIDI",
"params": {"parameters": [{"value": [pad, ""], "inputName": pad, "controlAddress": "/devices"}]},
"scripts": {
"items": [{"niceName": "Show", "parameters": [{"value": script, "controlAddress": "/filePath"}]}]
},
}
return {
"metaData": {"version": "1.10.4"},
"projectSettings": {
"containers": {
"dashboardSettings": {
"parameters": [
{"value": True, "controlAddress": "/enableDashboardServer"},
{"value": 9999, "hexMode": False, "controlAddress": "/serverPort"},
]
}
}
},
"dashboardManager": dashboard(groups, Path(script).stem, view, overlay),
"modules": {"viewOffset": [0, 0], "viewZoom": 1.0, "items": [*dmx, midi]},
}
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("show", type=Path)
parser.add_argument("out", type=Path, help="directory to write into")
parser.add_argument("--host", help="Art-Net destination (default: from the show's output universe)")
parser.add_argument("--pad", default="SINCO SMC-PAD-Master", help="MIDI input the pad arrives on (Bluetooth: SMC-PAD Bluetooth)")
parser.add_argument("--view", default="1574x953", help="dashboard panel size in pixels, for the top-left placement")
parser.add_argument("--small-buttons", action="store_true", help="a grey Select button under each tile, instead of the whole tile pressing")
parser.add_argument("--preview", default="127.0.0.1", help="second Art-Net destination for the simulator; empty for none")
args = parser.parse_args()
show = json.loads(args.show.read_text())
stage = json.loads((ROOT / show["stage"]).read_text())
output = next(u["output"] for u in show["universes"] if u.get("output", {}).get("plugin") == "ArtNet")
name = args.show.name.removesuffix(".show.json")
groups = collect(show, stage)
source = TEMPLATE.read_text().replace("/*__DATA__*/", render_data(groups))
args.out.mkdir(parents=True, exist_ok=True)
(args.out / f"{name}.js").write_text(source)
overlay = None if args.small_buttons else str((args.out / "clear.png").resolve())
if overlay:
(args.out / "clear.png").write_bytes(clear_png())
doc = project(f"{name}.js", args.host or output["ip"], int(output["universe"]), output["uid"], groups, args.preview or None, args.pad, tuple(int(n) for n in args.view.split("x")), overlay)
(args.out / f"{name}.noisette").write_text(json.dumps(doc, indent=2) + "\n")
print(f"{args.out / (name + '.noisette')}: {len(groups)} groups, {sum(len(g['pads']) for g in groups.values())} pads")
if __name__ == "__main__":
main()
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env python3
"""Compile shows/simple.show.json into shows/simple.qxw."""
from __future__ import annotations
import json
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
if str(ROOT) not in sys.path:
sys.path.insert(0, str(ROOT))
from showfile.tools import write_show
def main() -> None:
spec = json.loads((ROOT / "shows" / "simple.show.json").read_text(encoding="utf-8"))
result = write_show(spec, "shows/simple.qxw", root=ROOT)
if not result["ok"]:
raise SystemExit(json.dumps(result, indent=2))
print(f"Wrote {result['path']} ({len(result['widgets'])} widgets)")
if __name__ == "__main__":
main()
+210
View File
@@ -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()
+64
View File
@@ -0,0 +1,64 @@
#!/usr/bin/env python3
"""Add Pan, Tilt, Focus and Rotate sliders for the movers to shows/test.qxw.
As in templeoftechno.qxw, knobs 9–12 (CC 38–41) drive all four movers at once:
Knob 9 CC 38 Pan channel 0
Knob 10 CC 39 Tilt channel 2
Knob 11 CC 40 Focus channel 7
Knob 12 CC 41 Rotate channel 5 (Lens Rotate)
They sit in a Movers position frame beside Sound peak, below the cans' chase runs.
python3 scripts/shows/mover_position.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
from mover_bank import LEFT_TO_RIGHT, NO_FUNCTION, ROOT, appearance, frame
SHOW = ROOT / "shows" / "test.qxw"
# Caption, CC, mover channel, starting value: temple techno's.
SLIDERS = (
("Pan", 38, 0, 0),
("Tilt", 39, 2, 0),
("Focus", 40, 7, 70),
("Rotate", 41, 5, 0),
)
def level(wid: int, caption: str, x: int, cc: int, channel: int, value: int, indent: str = " ") -> str:
rows = "".join(f'{indent} <Channel Fixture="{f}">{channel}</Channel>\n' for f in LEFT_TO_RIGHT)
return (f'{indent}<Slider Caption="{caption}" ID="{wid}" WidgetStyle="Slider" InvertedAppearance="false">\n'
f'{indent} <WindowState Visible="True" X="{x}" Y="10" Width="52" Height="200"/>\n'
+ appearance(indent + " ", "Sunken")
+ f'{indent} <Input Universe="1" Channel="{cc}"/>\n'
f'{indent} <SliderMode ValueDisplayStyle="Exact" ClickAndGoType="None" Monitor="false">Level</SliderMode>\n'
f'{indent} <Level LowLimit="0" HighLimit="255" Value="{value}">\n{rows}{indent} </Level>\n'
f'{indent} <Playback>\n{indent} <Function>{NO_FUNCTION}</Function>\n{indent} </Playback>\n{indent}</Slider>\n')
def main() -> None:
xml = SHOW.read_text()
if 'Caption="Movers position"' in xml:
raise SystemExit(f"{SHOW.relative_to(ROOT)} already has the mover position sliders")
next_id = max(int(i) for i in re.findall(r' ID="(\d+)"', xml.split("<VirtualConsole>")[1])
if int(i) != NO_FUNCTION) + 1
sliders = "".join(level(next_id + 1 + i, caption, 10 + 58 * i, cc, channel, value)
for i, (caption, cc, channel, value) in enumerate(SLIDERS))
widgets = frame(next_id, "Movers position", 420, 630, 10 + 58 * len(SLIDERS), 250, sliders)
xml = xml.replace(" </Frame>\n <Properties>", widgets + " </Frame>\n <Properties>", 1)
SHOW.write_text(xml)
print(f"Added the mover position sliders to {SHOW.relative_to(ROOT)} (widgets from ID {next_id})")
if __name__ == "__main__":
main()
+268
View File
@@ -0,0 +1,268 @@
#!/usr/bin/env python3
"""Merge Patterns + Movers into one SoloFrame and one Speed dial in xchc.qxw."""
from __future__ import annotations
import re
from pathlib import Path
def btn(
widget_id: int,
caption: str,
func_id: int,
x: int,
y: int,
w: int,
h: int,
bg: str,
fg: str = "4294967295",
) -> str:
return f""" <Button Caption="{caption}" ID="{widget_id}" Icon="">
<WindowState Visible="True" X="{x}" Y="{y}" Width="{w}" Height="{h}"/>
<Appearance>
<FrameStyle>None</FrameStyle>
<ForegroundColor>{fg}</ForegroundColor>
<BackgroundColor>{bg}</BackgroundColor>
<BackgroundImage>None</BackgroundImage>
<Font>Default</Font>
</Appearance>
<Function ID="{func_id}"/>
<Action>Toggle</Action>
<Intensity Adjust="False">100</Intensity>
</Button>"""
ROOT = Path(__file__).resolve().parents[2]
def main():
path = ROOT / "shows" / "xchc.qxw"
text = path.read_text()
# Combined looks: can colour chase + figure-of-8 movement
combos = [
(101, "Colour + F8", 9, 77),
(102, "Rainbow + F8", 18, 77),
(103, "OddEven + F8", 22, 77),
(104, "Center + F8", 55, 77),
(105, "Theater + F8", 67, 77),
]
combo_xml = []
for fid, name, a, b in combos:
block = f""" <Function ID="{fid}" Type="Collection" Name="{name}">
<Step Number="0">{a}</Step>
<Step Number="1">{b}</Step>
</Function>
"""
if f'Function ID="{fid}"' in text:
text = re.sub(
rf' <Function ID="{fid}"[\s\S]*?</Function>\n',
block,
text,
count=1,
)
else:
combo_xml.append(block.rstrip())
if combo_xml:
text = text.replace(
' <Monitor DisplayMode="1"',
"\n".join(combo_xml) + "\n <Monitor DisplayMode=\"1\"",
1,
)
# Build unified Show SoloFrame
# Row 0: colour / spatial patterns (cans+movers already in scenes)
# Row 1: combined flight looks
# Row 2: mover-only + exits
w, h = 150, 56
gap_x, gap_y = 8, 8
x0, y0 = 10, 28
def cell(col, row):
return x0 + col * (w + gap_x), y0 + row * (h + gap_y)
buttons = []
# Row 0 — parcans + movers colour/spatial
row0 = [
(0, "Colour", 9, "4282664004"),
(28, "Rainbow", 18, "4280427042"),
(37, "Odd Even", 22, "4284752486"),
(47, "Scanner", 41, "4292033564"),
(48, "Fill", 50, "4278218076"),
(49, "Center Out", 55, "4280817043"),
]
for i, (wid, cap, fid, bg) in enumerate(row0):
x, y = cell(i, 0)
buttons.append(btn(wid, cap, fid, x, y, w, h, bg))
row1 = [
(50, "Pairs", 60, "4294946560", "4278190080"),
(51, "Left Right", 63, "4279648704", "4294967295"),
(52, "Theater", 67, "4285143962", "4294967295"),
(200, "Colour+F8", 101, "4282664004", "4294967295"),
(201, "Rainbow+F8", 102, "4280427042", "4294967295"),
(202, "Center+F8", 104, "4280817043", "4294967295"),
]
for i, (wid, cap, fid, bg, fg) in enumerate(row1):
x, y = cell(i, 1)
buttons.append(btn(wid, cap, fid, x, y, w, h, bg, fg))
row2 = [
(100, "Figure of 8", 77, "4282664004"),
(203, "OddEven+F8", 103, "4284752486"),
(204, "Theater+F8", 105, "4285143962"),
(53, "Collapse In", 68, "4281545523"),
(54, "Chase Out", 69, "4284900966"),
(55, "Home Fade", 71, "4286611584"),
]
for i, (wid, cap, fid, bg) in enumerate(row2):
x, y = cell(i, 2)
buttons.append(btn(wid, cap, fid, x, y, w, h, bg))
# Home Fade for whole stage uses can Home Fade 71; keep mover Home Fade via MIB/Soft BO
row3 = [
(101, "Ring Collapse", 85, "4281545523"),
(114, "Ring Chase", 94, "4284900966"),
(116, "Move in Black", 98, "4279900698"),
(56, "Soft Blackout", 72, "4278190080"),
(38, "Red Test", 32, "4286578688"),
]
for i, (wid, cap, fid, bg) in enumerate(row3):
x, y = cell(i, 3)
buttons.append(btn(wid, cap, fid, x, y, w, h, bg))
frame_w = x0 + 6 * (w + gap_x) + 10
frame_h = y0 + 4 * (h + gap_y) + 16
show_frame = f""" <SoloFrame Caption="Show">
<Appearance>
<FrameStyle>Sunken</FrameStyle>
<ForegroundColor>Default</ForegroundColor>
<BackgroundColor>Default</BackgroundColor>
<BackgroundImage>None</BackgroundImage>
<Font>Default</Font>
</Appearance>
<WindowState Visible="True" X="10" Y="10" Width="{frame_w}" Height="{frame_h}"/>
<AllowChildren>True</AllowChildren>
<AllowResize>True</AllowResize>
<ShowHeader>True</ShowHeader>
<Mixing>False</Mixing>
{chr(10).join(buttons)}
</SoloFrame>"""
# Replace Patterns SoloFrame
text = re.sub(
r' <SoloFrame Caption="Patterns">[\s\S]*?</SoloFrame>',
show_frame,
text,
count=1,
)
# Remove Movers SoloFrame (buttons now in Show)
text = re.sub(
r' <SoloFrame Caption="Movers">[\s\S]*?</SoloFrame>\n',
"",
text,
count=1,
)
# Merge mover speed targets into main Speed dial; drop Mover Speed dial
text = re.sub(
r' <SpeedDial Caption="Mover Speed" ID="102">[\s\S]*?</SpeedDial>\n',
"",
text,
count=1,
)
speed_extra = """ <Function FadeIn="6" FadeOut="0" Duration="6">74</Function>
<Function FadeIn="0" FadeOut="0" Duration="6">76</Function>
<Function FadeIn="6" FadeOut="0" Duration="6">101</Function>
<Function FadeIn="6" FadeOut="0" Duration="6">102</Function>
<Function FadeIn="6" FadeOut="0" Duration="6">103</Function>
<Function FadeIn="6" FadeOut="0" Duration="6">104</Function>
<Function FadeIn="0" FadeOut="0" Duration="6">105</Function>
"""
if 'Function FadeIn="6" FadeOut="0" Duration="6">74</Function>' not in text:
text = text.replace(
' <Function FadeIn="0" FadeOut="0" Duration="6">69</Function>\n </SpeedDial>',
' <Function FadeIn="0" FadeOut="0" Duration="6">69</Function>\n'
+ speed_extra
+ " </SpeedDial>",
1,
)
# Make Speed dial visible next to Show
text = text.replace(
'<SpeedDial Caption="Speed" ID="3">\n <WindowState Visible="False" X="720" Y="20" Width="90" Height="250"/>',
f'<SpeedDial Caption="Speed" ID="3">\n <WindowState Visible="True" X="{frame_w + 20}" Y="10" Width="100" Height="{frame_h}"/>',
1,
)
# All Dim also drives mover dimmers
if "<Channel Fixture=\"8\">8</Channel>" not in text.split('Caption="All Dim"', 1)[1][:800]:
text = text.replace(
""" <Level LowLimit="0" HighLimit="255" Value="174">
<Channel Fixture="0">0</Channel>
<Channel Fixture="1">0</Channel>
<Channel Fixture="2">0</Channel>
<Channel Fixture="3">0</Channel>
<Channel Fixture="4">0</Channel>
<Channel Fixture="5">0</Channel>
<Channel Fixture="6">0</Channel>
<Channel Fixture="7">0</Channel>
</Level>
<Playback>
<Function>4294967295</Function>
</Playback>
</Slider>
<Slider Caption="1 R\"""",
""" <Level LowLimit="0" HighLimit="255" Value="174">
<Channel Fixture="0">0</Channel>
<Channel Fixture="1">0</Channel>
<Channel Fixture="2">0</Channel>
<Channel Fixture="3">0</Channel>
<Channel Fixture="4">0</Channel>
<Channel Fixture="5">0</Channel>
<Channel Fixture="6">0</Channel>
<Channel Fixture="7">0</Channel>
<Channel Fixture="8">8</Channel>
<Channel Fixture="9">8</Channel>
</Level>
<Playback>
<Function>4294967295</Function>
</Playback>
</Slider>
<Slider Caption="1 R\"""",
1,
)
# Relabel / place XY pad under Show
text = text.replace(
'Caption="Mover Position"',
'Caption="Position"',
1,
)
text = text.replace(
'<XYPad Caption="Position" ID="103" InvertedAppearance="0">\n <WindowState Visible="True" X="720" Y="180" Width="320" Height="320"/>',
f'<XYPad Caption="Position" ID="103" InvertedAppearance="0">\n <WindowState Visible="True" X="10" Y="{frame_h + 20}" Width="320" Height="300"/>',
1,
)
# Shift mover sliders under Show, right of XY pad
slider_y = frame_h + 20
old_xs = [1050 + i * 46 for i in range(10)]
new_xs = [340 + i * 46 for i in range(10)]
for ox, nx in zip(old_xs, new_xs):
text = text.replace(
f'Visible="True" X="{ox}" Y="180" Width="44" Height="320"',
f'Visible="True" X="{nx}" Y="{slider_y}" Width="44" Height="300"',
1,
)
path.write_text(text)
print(f"Unified Show controls in {path}")
print(f" SoloFrame {frame_w}x{frame_h} with pattern + F8 combos + exits")
print(" One Speed dial; Position pad + mover sliders below")
if __name__ == "__main__":
main()