Group scripts into pad/, shows/ and anim/ folders.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5f593b973c
commit
647cfa3a75
26 files changed
+68
-66
No files matched your search
@@ -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 smoother 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 smoother with --lock-knobs to make them work only
|
||||
after the Custom pad is pressed; any other pad sends them back to zero (see
|
||||
pad_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 # scripts/pad/pad_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 = "SMC-PAD Smooth" # scripts/pad/smooth_smc_pad.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
@@ -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()
|
||||
@@ -0,0 +1,837 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate shows/cabaret.qxw — grouped can RGB + per-mover position and RGB."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
OUT = ROOT / "shows" / "cabaret.qxw"
|
||||
|
||||
M1, M2 = 8, 9
|
||||
|
||||
# Can groups: 1-2 | 3-4-5-6 | 7-8
|
||||
GROUP_L = [0, 1]
|
||||
GROUP_C = [2, 3, 4, 5]
|
||||
GROUP_R = [6, 7]
|
||||
|
||||
# Can 8ch: Dim=0, R=2, G=3, B=4
|
||||
# Mover 43ch: Pan/Tilt Speed=4, Focus=7, Center Bright=8; RGB heads 1–7
|
||||
MOVER_SPEED = 4
|
||||
MOVER_FOCUS = 7
|
||||
MOVER_DIM = 8
|
||||
MOVER_R = [10, 14, 18, 22, 26, 30, 34]
|
||||
MOVER_G = [11, 15, 19, 23, 27, 31, 35]
|
||||
MOVER_B = [12, 16, 20, 24, 28, 32, 36]
|
||||
FOCUS_DEFAULT = 70
|
||||
CANS = list(range(8))
|
||||
|
||||
PALETTE: dict[str, tuple[int, int, int]] = {
|
||||
"Amber": (255, 90, 0),
|
||||
"Pink": (255, 50, 160),
|
||||
"HotBlue": (round(0.30 * 255), 0, 255), # 30% red, 100% blue
|
||||
"Red": (255, 0, 0),
|
||||
"Green": (0, 255, 0),
|
||||
"Blue": (0, 0, 255),
|
||||
"Orange": (255, 127, 0),
|
||||
"Yellow": (255, 255, 0),
|
||||
"Purple": (127, 0, 255),
|
||||
}
|
||||
|
||||
CAN_ODD = [0, 2, 4, 6] # #1,3,5,7
|
||||
CAN_EVEN = [1, 3, 5, 7] # #2,4,6,8
|
||||
MOVER_SOLIDS = [
|
||||
"Amber",
|
||||
"Pink",
|
||||
"Red",
|
||||
"Green",
|
||||
"Blue",
|
||||
"Orange",
|
||||
"Yellow",
|
||||
"Purple",
|
||||
]
|
||||
|
||||
# Pad display values. M2 (left) is hung 180°, so its pad pan is reversed:
|
||||
# DMX pan = 255 - pad pan. M1 pad pan is DMX pan.
|
||||
PAD_PAN = {M2: 181, M1: 80}
|
||||
PAD_TILT = {M2: 145, M1: 161}
|
||||
POSITION_FADE_MS = 2000
|
||||
# name, M1 (pan, tilt), M2 (pan, tilt), button colour
|
||||
# Same DMX pan = split (180° hang). Cross left was mirrored (108) = 180° out.
|
||||
# Now = live pad aim (M2 pad 181/145 → DMX 74/145, M1 pad 80/161).
|
||||
POSITIONS: list[tuple[str, tuple[int, int], tuple[int, int], str]] = [
|
||||
("Now", (80, 161), (74, 145), "4278236360"),
|
||||
("Here", (179, 0), (179, 0), "4282664004"),
|
||||
("Down", (179, 36), (179, 36), "4284900966"),
|
||||
("Mid", (164, 18), (144, 18), "4286611584"),
|
||||
("Cross", (140, 26), (140, 26), "4281545523"),
|
||||
("Out", (200, 22), (200, 22), "4279900698"),
|
||||
]
|
||||
POSITION_FUNC0 = 100
|
||||
PADS_FUNC = POSITION_FUNC0 + len(POSITIONS)
|
||||
PADS_BG = "4282800750" # #465A6E pad grey-blue
|
||||
FIGURE8_FLOOR_FUNC = 110
|
||||
FIGURE8_WALL_FUNC = 111
|
||||
FIGURE8_MS = 12000
|
||||
FIGURE8_FLOOR_BG = "4282664004"
|
||||
FIGURE8_WALL_BG = "4286611584"
|
||||
LOOK_PAIRS: list[tuple[str, str | None]] = [
|
||||
("Amber", None),
|
||||
("Pink", "Amber"),
|
||||
("Pink", "HotBlue"),
|
||||
("Red", "Green"),
|
||||
("Blue", "Green"),
|
||||
("Blue", "Red"),
|
||||
("Orange", "Blue"),
|
||||
("Yellow", "Purple"),
|
||||
]
|
||||
|
||||
|
||||
def color_label(name: str) -> str:
|
||||
return "Blue" if name == "HotBlue" else name
|
||||
|
||||
|
||||
def qlc_color(r: int, g: int, b: int) -> str:
|
||||
return str((0xFF << 24) | (r << 16) | (g << 8) | b)
|
||||
|
||||
|
||||
def mix_color(
|
||||
a: tuple[int, int, int], b: tuple[int, int, int]
|
||||
) -> tuple[int, int, int]:
|
||||
return ((a[0] + b[0]) // 2, (a[1] + b[1]) // 2, (a[2] + b[2]) // 2)
|
||||
|
||||
RGB = [
|
||||
("R", 2, MOVER_R, "4294901760", "Red"),
|
||||
("G", 3, MOVER_G, "4278255360", "Green"),
|
||||
("B", 4, MOVER_B, "4278190335", "Blue"),
|
||||
]
|
||||
|
||||
|
||||
def appearance(
|
||||
fg: str = "Default",
|
||||
bg: str = "Default",
|
||||
frame: str = "Sunken",
|
||||
) -> str:
|
||||
return f""" <Appearance>
|
||||
<FrameStyle>{frame}</FrameStyle>
|
||||
<ForegroundColor>{fg}</ForegroundColor>
|
||||
<BackgroundColor>{bg}</BackgroundColor>
|
||||
<BackgroundImage>None</BackgroundImage>
|
||||
<Font>Default</Font>
|
||||
</Appearance>"""
|
||||
|
||||
|
||||
def slider(
|
||||
wid: int,
|
||||
caption: str,
|
||||
x: int,
|
||||
y: int,
|
||||
w: int,
|
||||
h: int,
|
||||
channels: list[tuple[int, int]],
|
||||
*,
|
||||
value: int = 0,
|
||||
fg: str = "Default",
|
||||
cng: str = "None",
|
||||
inverted: bool = False,
|
||||
) -> str:
|
||||
ch_xml = "\n".join(
|
||||
f' <Channel Fixture="{fid}">{ch}</Channel>' for fid, ch in channels
|
||||
)
|
||||
inv = "true" if inverted else "false"
|
||||
return f""" <Slider Caption="{caption}" ID="{wid}" WidgetStyle="Slider" InvertedAppearance="{inv}">
|
||||
<WindowState Visible="True" X="{x}" Y="{y}" Width="{w}" Height="{h}"/>
|
||||
{appearance(fg=fg)}
|
||||
<SliderMode ValueDisplayStyle="Exact" ClickAndGoType="{cng}" Monitor="true">Level</SliderMode>
|
||||
<Reset/>
|
||||
<Level LowLimit="0" HighLimit="255" Value="{value}">
|
||||
{ch_xml}
|
||||
</Level>
|
||||
<Playback>
|
||||
<Function>4294967295</Function>
|
||||
</Playback>
|
||||
</Slider>"""
|
||||
|
||||
|
||||
def xypad(
|
||||
wid: int,
|
||||
caption: str,
|
||||
fid: int,
|
||||
x: int,
|
||||
y: int,
|
||||
w: int,
|
||||
h: int,
|
||||
*,
|
||||
reverse_pan: bool = False,
|
||||
reverse_tilt: bool = False,
|
||||
pan: int = 128,
|
||||
tilt: int = 128,
|
||||
) -> str:
|
||||
pan_rev = "True" if reverse_pan else "False"
|
||||
tilt_rev = "True" if reverse_tilt else "False"
|
||||
return f""" <XYPad Caption="{caption}" ID="{wid}" InvertedAppearance="0">
|
||||
<WindowState Visible="True" X="{x}" Y="{y}" Width="{w}" Height="{h}"/>
|
||||
{appearance()}
|
||||
<Fixture ID="{fid}" Head="0">
|
||||
<Axis ID="X" LowLimit="0" HighLimit="1" Reverse="{pan_rev}"/>
|
||||
<Axis ID="Y" LowLimit="0" HighLimit="1" Reverse="{tilt_rev}"/>
|
||||
</Fixture>
|
||||
<Window hMin="0" hMax="255" vMin="0" vMax="255"/>
|
||||
<Pan Position="{pan}"/>
|
||||
<Tilt Position="{tilt}"/>
|
||||
</XYPad>"""
|
||||
|
||||
|
||||
def label_frame(wid: int, caption: str, x: int, y: int, w: int, h: int) -> str:
|
||||
return f""" <Frame Caption="{caption}" ID="{wid}">
|
||||
<Appearance>
|
||||
<FrameStyle>Sunken</FrameStyle>
|
||||
<ForegroundColor>Default</ForegroundColor>
|
||||
<BackgroundColor>Default</BackgroundColor>
|
||||
<BackgroundImage>None</BackgroundImage>
|
||||
<Font>Default</Font>
|
||||
</Appearance>
|
||||
<WindowState Visible="True" X="{x}" Y="{y}" Width="{w}" Height="{h}"/>
|
||||
<AllowChildren>True</AllowChildren>
|
||||
<AllowResize>True</AllowResize>
|
||||
<ShowHeader>True</ShowHeader>
|
||||
<ShowEnableButton>False</ShowEnableButton>
|
||||
<ShowIntensityButton>False</ShowIntensityButton>
|
||||
<Mixing>False</Mixing>
|
||||
</Frame>"""
|
||||
|
||||
|
||||
def button(
|
||||
wid: int,
|
||||
caption: str,
|
||||
func_id: int,
|
||||
x: int,
|
||||
y: int,
|
||||
w: int,
|
||||
h: int,
|
||||
bg: str,
|
||||
fg: str = "4294967295",
|
||||
*,
|
||||
indent: str = " ",
|
||||
) -> str:
|
||||
inner = indent + " "
|
||||
return f"""{indent}<Button Caption="{caption}" ID="{wid}" Icon="">
|
||||
{inner}<WindowState Visible="True" X="{x}" Y="{y}" Width="{w}" Height="{h}"/>
|
||||
{inner}<Appearance>
|
||||
{inner} <FrameStyle>None</FrameStyle>
|
||||
{inner} <ForegroundColor>{fg}</ForegroundColor>
|
||||
{inner} <BackgroundColor>{bg}</BackgroundColor>
|
||||
{inner} <BackgroundImage>None</BackgroundImage>
|
||||
{inner} <Font>Default</Font>
|
||||
{inner}</Appearance>
|
||||
{inner}<Function ID="{func_id}"/>
|
||||
{inner}<Action>Toggle</Action>
|
||||
{inner}<Intensity Adjust="False">100</Intensity>
|
||||
{indent}</Button>"""
|
||||
|
||||
|
||||
def solo_frame(wid: int, caption: str, x: int, y: int, w: int, h: int, children: str) -> str:
|
||||
return f""" <SoloFrame Caption="{caption}" ID="{wid}">
|
||||
<Appearance>
|
||||
<FrameStyle>Sunken</FrameStyle>
|
||||
<ForegroundColor>Default</ForegroundColor>
|
||||
<BackgroundColor>Default</BackgroundColor>
|
||||
<BackgroundImage>None</BackgroundImage>
|
||||
<Font>Default</Font>
|
||||
</Appearance>
|
||||
<WindowState Visible="True" X="{x}" Y="{y}" Width="{w}" Height="{h}"/>
|
||||
<AllowChildren>True</AllowChildren>
|
||||
<AllowResize>True</AllowResize>
|
||||
<ShowHeader>True</ShowHeader>
|
||||
<ShowEnableButton>False</ShowEnableButton>
|
||||
<Mixing>False</Mixing>
|
||||
{children}
|
||||
</SoloFrame>"""
|
||||
|
||||
|
||||
def can_fixture_val(fid: int, r: int, g: int, b: int) -> str:
|
||||
# Dimmer is owned by the Can Bright slider (HTP).
|
||||
return (
|
||||
f' <FixtureVal ID="{fid}">'
|
||||
f"1,0,2,{r},3,{g},4,{b},5,0,6,0,7,0"
|
||||
f"</FixtureVal>"
|
||||
)
|
||||
|
||||
|
||||
def mover_fixture_val(fid: int, r: int, g: int, b: int) -> str:
|
||||
# Dimmer is owned by the Mover Bright slider (HTP).
|
||||
parts: list[int] = []
|
||||
for i in range(7):
|
||||
base = 10 + i * 4
|
||||
parts.extend([base, r, base + 1, g, base + 2, b, base + 3, 0])
|
||||
return f' <FixtureVal ID="{fid}">{",".join(str(x) for x in parts)}</FixtureVal>'
|
||||
|
||||
|
||||
def look_scene_xml(
|
||||
func_id: int,
|
||||
name: str,
|
||||
can_colors: dict[int, tuple[int, int, int]] | None = None,
|
||||
mover_colors: dict[int, tuple[int, int, int]] | None = None,
|
||||
) -> str:
|
||||
vals: list[str] = []
|
||||
if can_colors:
|
||||
vals += [can_fixture_val(fid, *rgb) for fid, rgb in can_colors.items()]
|
||||
if mover_colors:
|
||||
vals += [mover_fixture_val(fid, *rgb) for fid, rgb in mover_colors.items()]
|
||||
return f""" <Function ID="{func_id}" Type="Scene" Name="{name}">
|
||||
<Speed FadeIn="0" FadeOut="0" Duration="0"/>
|
||||
{chr(10).join(vals)}
|
||||
</Function>"""
|
||||
|
||||
|
||||
def look_caption(kind: str, left_n: str, right_n: str | None) -> str:
|
||||
ll, rl = color_label(left_n), color_label(right_n or left_n)
|
||||
if right_n is None:
|
||||
return ll
|
||||
if kind == "cans":
|
||||
return f"1-4 {ll} 5-8 {rl}"
|
||||
return f"Odd {ll} Even {rl}"
|
||||
|
||||
|
||||
def look_values(
|
||||
kind: str, left: tuple[int, int, int], right: tuple[int, int, int]
|
||||
) -> tuple[dict[int, tuple[int, int, int]] | None, dict[int, tuple[int, int, int]] | None]:
|
||||
if kind == "cans":
|
||||
return {**{i: left for i in range(4)}, **{i: right for i in range(4, 8)}}, None
|
||||
if kind == "cans_oe":
|
||||
return {**{i: left for i in CAN_ODD}, **{i: right for i in CAN_EVEN}}, None
|
||||
raise ValueError(kind)
|
||||
|
||||
|
||||
def build_looks() -> tuple[str, dict[str, list[tuple[str, int, str]]]]:
|
||||
specs: dict[str, list[tuple[str, int, str]]] = {
|
||||
"cans": [],
|
||||
"movers": [],
|
||||
"cans_oe": [],
|
||||
}
|
||||
scenes: list[str] = []
|
||||
func_id = 0
|
||||
for kind in ("cans", "cans_oe"):
|
||||
for left_n, right_n in LOOK_PAIRS:
|
||||
if kind == "cans_oe" and right_n is None:
|
||||
continue
|
||||
left = PALETTE[left_n]
|
||||
right = PALETTE[right_n] if right_n else left
|
||||
cans, movers = look_values(kind, left, right)
|
||||
if right_n is None:
|
||||
cans = {fid: left for fid in CANS}
|
||||
movers = None
|
||||
ll, rl = color_label(left_n), color_label(right_n or left_n)
|
||||
name = f"{kind} {ll}" if right_n is None else f"{kind} {ll} {rl}"
|
||||
scenes.append(look_scene_xml(func_id, name, cans, movers))
|
||||
bg = qlc_color(*left) if right_n is None else qlc_color(*mix_color(left, right))
|
||||
specs[kind].append((look_caption(kind, left_n, right_n), func_id, bg))
|
||||
func_id += 1
|
||||
for color_n in MOVER_SOLIDS:
|
||||
rgb = PALETTE[color_n]
|
||||
label = color_label(color_n)
|
||||
scenes.append(
|
||||
look_scene_xml(
|
||||
func_id,
|
||||
f"movers {label}",
|
||||
mover_colors={M1: rgb, M2: rgb},
|
||||
)
|
||||
)
|
||||
specs["movers"].append((label, func_id, qlc_color(*rgb)))
|
||||
func_id += 1
|
||||
return "\n".join(scenes), specs
|
||||
|
||||
|
||||
def look_scenes_xml() -> str:
|
||||
xml, _ = build_looks()
|
||||
return xml
|
||||
|
||||
|
||||
def position_scene_xml() -> str:
|
||||
blocks = [
|
||||
f""" <Function ID="{PADS_FUNC}" Type="Scene" Name="Mover Pads">
|
||||
<Speed FadeIn="0" FadeOut="0" Duration="0"/>
|
||||
</Function>"""
|
||||
]
|
||||
for i, (name, m1, m2, _bg) in enumerate(POSITIONS):
|
||||
poses = {M1: m1, M2: m2}
|
||||
vals = []
|
||||
for fid in (M1, M2):
|
||||
pan, tilt = poses[fid]
|
||||
vals.append(
|
||||
f' <FixtureVal ID="{fid}">0,{pan},1,0,2,{tilt},3,0</FixtureVal>'
|
||||
)
|
||||
blocks.append(
|
||||
f""" <Function ID="{POSITION_FUNC0 + i}" Type="Scene" Name="Mover {name}">
|
||||
<Speed FadeIn="{POSITION_FADE_MS}" FadeOut="0" Duration="{POSITION_FADE_MS}"/>
|
||||
{chr(10).join(vals)}
|
||||
</Function>"""
|
||||
)
|
||||
return "\n".join(blocks)
|
||||
|
||||
|
||||
def position_button_specs() -> list[tuple[str, int, str]]:
|
||||
return (
|
||||
[("Pads", PADS_FUNC, PADS_BG)]
|
||||
+ [
|
||||
(name, POSITION_FUNC0 + i, bg)
|
||||
for i, (name, _m1, _m2, bg) in enumerate(POSITIONS)
|
||||
]
|
||||
+ [
|
||||
("Floor 8", FIGURE8_FLOOR_FUNC, FIGURE8_FLOOR_BG),
|
||||
("Wall 8", FIGURE8_WALL_FUNC, FIGURE8_WALL_BG),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def figure8_floor_center() -> tuple[int, int]:
|
||||
"""Now is the live floor aim; average both heads so the 8 stays on the ground."""
|
||||
now = next((m1, m2) for name, m1, m2, _bg in POSITIONS if name == "Now")
|
||||
pans = [now[0][0], now[1][0]]
|
||||
tilts = [now[0][1], now[1][1]]
|
||||
return (pans[0] + pans[1]) // 2, (tilts[0] + tilts[1]) // 2
|
||||
|
||||
|
||||
def figure8_wall_bounds() -> tuple[int, int, int, int]:
|
||||
"""Pan/tilt centre and amplitude covering Here–Out (the wall looks)."""
|
||||
pans: list[int] = []
|
||||
tilts: list[int] = []
|
||||
for name, m1, m2, _bg in POSITIONS:
|
||||
if name == "Now":
|
||||
continue
|
||||
for pan, tilt in (m1, m2):
|
||||
pans.append(pan)
|
||||
tilts.append(tilt)
|
||||
p0, p1 = min(pans), max(pans)
|
||||
t0, t1 = min(tilts), max(tilts)
|
||||
return (p0 + p1) // 2, (t0 + t1) // 2, (p1 - p0) // 2, (t1 - t0) // 2
|
||||
|
||||
|
||||
def figure8_efx_block(
|
||||
func_id: int,
|
||||
name: str,
|
||||
width: int,
|
||||
height: int,
|
||||
rotation: int,
|
||||
pan_c: int,
|
||||
tilt_c: int,
|
||||
) -> str:
|
||||
fixtures = "\n".join(
|
||||
f""" <Fixture>
|
||||
<ID>{fid}</ID>
|
||||
<Direction>Forward</Direction>
|
||||
<Intensity>255</Intensity>
|
||||
</Fixture>"""
|
||||
for fid in (M1, M2)
|
||||
)
|
||||
return f""" <Function ID="{func_id}" Type="EFX" Name="{name}">
|
||||
{fixtures}
|
||||
<PropagationMode>Parallel</PropagationMode>
|
||||
<Speed Duration="{FIGURE8_MS}" FadeOut="0" FadeIn="0"/>
|
||||
<Direction>Forward</Direction>
|
||||
<RunOrder>Loop</RunOrder>
|
||||
<Algorithm>Eight</Algorithm>
|
||||
<Width>{width}</Width>
|
||||
<Height>{height}</Height>
|
||||
<Rotation>{rotation}</Rotation>
|
||||
<Axis Name="X">
|
||||
<Offset>{pan_c}</Offset>
|
||||
<Frequency>1</Frequency>
|
||||
<Phase>0</Phase>
|
||||
</Axis>
|
||||
<Axis Name="Y">
|
||||
<Offset>{tilt_c}</Offset>
|
||||
<Frequency>1</Frequency>
|
||||
<Phase>0</Phase>
|
||||
</Axis>
|
||||
</Function>"""
|
||||
|
||||
|
||||
def figure8_efx_xml() -> str:
|
||||
floor_pan, floor_tilt = figure8_floor_center()
|
||||
wall_pan, wall_tilt, wall_pan_amp, wall_tilt_amp = figure8_wall_bounds()
|
||||
# Floor 8: around Now, tilt stays on the ground. Rotation 90 = upright 8.
|
||||
# Wall 8: Here–Out box (tilt 0–36). Rotation 0 = 8 across the wall.
|
||||
return "\n".join(
|
||||
[
|
||||
figure8_efx_block(
|
||||
FIGURE8_FLOOR_FUNC,
|
||||
"Figure of 8 Floor",
|
||||
16,
|
||||
18,
|
||||
90,
|
||||
floor_pan,
|
||||
floor_tilt,
|
||||
),
|
||||
figure8_efx_block(
|
||||
FIGURE8_WALL_FUNC,
|
||||
"Figure of 8 Walls",
|
||||
wall_pan_amp,
|
||||
wall_tilt_amp,
|
||||
0,
|
||||
wall_pan,
|
||||
wall_tilt,
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def fixture_xml() -> str:
|
||||
parts = []
|
||||
for i in range(8):
|
||||
parts.append(
|
||||
f""" <Fixture>
|
||||
<Manufacturer>beamZ</Manufacturer>
|
||||
<Model>BCC145</Model>
|
||||
<Mode>8 Channel</Mode>
|
||||
<ID>{i}</ID>
|
||||
<Name>BCC145 #{i + 1}</Name>
|
||||
<Universe>0</Universe>
|
||||
<Address>{87 + i * 8}</Address>
|
||||
<Channels>8</Channels>
|
||||
</Fixture>"""
|
||||
)
|
||||
for i, addr in enumerate((0, 44)):
|
||||
parts.append(
|
||||
f""" <Fixture>
|
||||
<Manufacturer>Small Eye 7</Manufacturer>
|
||||
<Model>Mover</Model>
|
||||
<Mode>43 Channel</Mode>
|
||||
<ID>{8 + i}</ID>
|
||||
<Name>Small Eye 7 #{i + 1}</Name>
|
||||
<Universe>0</Universe>
|
||||
<Address>{addr}</Address>
|
||||
<Channels>43</Channels>
|
||||
</Fixture>"""
|
||||
)
|
||||
return "\n".join(parts)
|
||||
|
||||
|
||||
def fixture_groups_xml() -> str:
|
||||
def heads(fids: list[int]) -> str:
|
||||
return "\n".join(
|
||||
f' <Head X="{i}" Y="0" Fixture="{fid}">0</Head>'
|
||||
for i, fid in enumerate(fids)
|
||||
)
|
||||
|
||||
return f""" <FixtureGroup ID="0">
|
||||
<Name>Cans 1-2</Name>
|
||||
<Size X="2" Y="1"/>
|
||||
{heads(GROUP_L)}
|
||||
</FixtureGroup>
|
||||
<FixtureGroup ID="1">
|
||||
<Name>Cans 3-6</Name>
|
||||
<Size X="4" Y="1"/>
|
||||
{heads(GROUP_C)}
|
||||
</FixtureGroup>
|
||||
<FixtureGroup ID="2">
|
||||
<Name>Cans 7-8</Name>
|
||||
<Size X="2" Y="1"/>
|
||||
{heads(GROUP_R)}
|
||||
</FixtureGroup>
|
||||
<FixtureGroup ID="3">
|
||||
<Name>Small Eye Movers</Name>
|
||||
<Size X="2" Y="1"/>
|
||||
<Head X="0" Y="0" Fixture="8">0</Head>
|
||||
<Head X="1" Y="0" Fixture="9">0</Head>
|
||||
</FixtureGroup>"""
|
||||
|
||||
|
||||
def main() -> None:
|
||||
pad_w, pad_h = 240, 240
|
||||
sl_w, sl_h = 44, 240
|
||||
gap = 8
|
||||
block_gap = 28
|
||||
|
||||
widgets: list[str] = []
|
||||
wid = 0
|
||||
max_x = 0
|
||||
max_y = 0
|
||||
|
||||
def place_slider(
|
||||
caption, x, y, w, h, channels, value=0, fg="Default", cng="None", inverted=False
|
||||
):
|
||||
nonlocal wid, max_x, max_y
|
||||
widgets.append(
|
||||
slider(
|
||||
wid,
|
||||
caption,
|
||||
x,
|
||||
y,
|
||||
w,
|
||||
h,
|
||||
channels,
|
||||
value=value,
|
||||
fg=fg,
|
||||
cng=cng,
|
||||
inverted=inverted,
|
||||
)
|
||||
)
|
||||
wid += 1
|
||||
max_x = max(max_x, x + w)
|
||||
max_y = max(max_y, y + h)
|
||||
|
||||
def place_rgb_block(prefix: str, x: int, y: int, dim_chs, rgb_chs_for):
|
||||
"""Dim + R G B. rgb_chs_for(name, can_ch, mover_chs) -> channel list."""
|
||||
place_slider(
|
||||
f"{prefix} Dim", x, y, sl_w, sl_h, dim_chs, 0, "4294967295"
|
||||
)
|
||||
x += sl_w + 2
|
||||
for name, can_ch, mover_chs, fg, cng in RGB:
|
||||
place_slider(
|
||||
f"{prefix} {name}",
|
||||
x,
|
||||
y,
|
||||
sl_w,
|
||||
sl_h,
|
||||
rgb_chs_for(name, can_ch, mover_chs),
|
||||
fg=fg,
|
||||
cng=cng,
|
||||
)
|
||||
x += sl_w + 2
|
||||
return x
|
||||
|
||||
def place_mover(prefix: str, fid: int, x: int, y: int, *, reverse_pan: bool = False) -> int:
|
||||
nonlocal wid, max_y
|
||||
widgets.append(
|
||||
xypad(
|
||||
wid,
|
||||
f"{prefix} Position",
|
||||
fid,
|
||||
x,
|
||||
y,
|
||||
pad_w,
|
||||
pad_h,
|
||||
reverse_pan=reverse_pan,
|
||||
pan=PAD_PAN[fid],
|
||||
tilt=PAD_TILT[fid],
|
||||
)
|
||||
)
|
||||
wid += 1
|
||||
max_y = max(max_y, y + pad_h)
|
||||
return x + pad_w + gap
|
||||
|
||||
def place_looks(
|
||||
title: str,
|
||||
looks: list[tuple[str, int, str]],
|
||||
x: int,
|
||||
y: int,
|
||||
*,
|
||||
cols: int = 2,
|
||||
btn_w: int = 156,
|
||||
) -> int:
|
||||
nonlocal wid, max_x, max_y
|
||||
header_h = 28
|
||||
pad = 4
|
||||
gap_x, gap_y = 6, 6
|
||||
n = len(looks)
|
||||
cols = max(1, min(cols, n))
|
||||
rows = max(1, (n + cols - 1) // cols)
|
||||
frame_w = pad * 2 + cols * btn_w + (cols - 1) * gap_x
|
||||
frame_h = header_h + sl_h
|
||||
inner_h = sl_h - pad
|
||||
btn_h = (inner_h - gap_y * (rows - 1)) // rows
|
||||
look_btns = []
|
||||
frame_id = wid
|
||||
wid += 1
|
||||
for i, (caption, func_id, bg) in enumerate(looks):
|
||||
col, row = i % cols, i // cols
|
||||
look_btns.append(
|
||||
button(
|
||||
wid,
|
||||
caption,
|
||||
func_id,
|
||||
pad + col * (btn_w + gap_x),
|
||||
header_h + pad + row * (btn_h + gap_y),
|
||||
btn_w,
|
||||
btn_h,
|
||||
bg,
|
||||
indent=" ",
|
||||
)
|
||||
)
|
||||
wid += 1
|
||||
widgets.append(
|
||||
solo_frame(
|
||||
frame_id,
|
||||
title,
|
||||
x,
|
||||
y - header_h,
|
||||
frame_w,
|
||||
frame_h,
|
||||
"\n".join(look_btns),
|
||||
)
|
||||
)
|
||||
max_x = max(max_x, x + frame_w)
|
||||
max_y = max(max_y, y - header_h + frame_h)
|
||||
return x + frame_w
|
||||
|
||||
_, look_specs = build_looks()
|
||||
|
||||
y0 = 28
|
||||
x = 10
|
||||
# M2 on the left, M1 on the right. Left unit is hung opposite, so pan is reversed.
|
||||
x = place_mover("M2", M2, x, y0, reverse_pan=True)
|
||||
x += block_gap
|
||||
x = place_mover("M1", M1, x, y0)
|
||||
x += block_gap
|
||||
place_slider(
|
||||
"M Bright",
|
||||
x,
|
||||
y0,
|
||||
sl_w,
|
||||
sl_h,
|
||||
[(M1, MOVER_DIM), (M2, MOVER_DIM)],
|
||||
255,
|
||||
"4294967295",
|
||||
)
|
||||
x += sl_w + 2
|
||||
place_slider(
|
||||
"M Focus",
|
||||
x,
|
||||
y0,
|
||||
sl_w,
|
||||
sl_h,
|
||||
[(M1, MOVER_FOCUS), (M2, MOVER_FOCUS)],
|
||||
FOCUS_DEFAULT,
|
||||
"4294902015",
|
||||
)
|
||||
x += sl_w + 2
|
||||
place_slider(
|
||||
"Speed",
|
||||
x,
|
||||
y0,
|
||||
sl_w,
|
||||
sl_h,
|
||||
[(M1, MOVER_SPEED), (M2, MOVER_SPEED)],
|
||||
0,
|
||||
"4294967295",
|
||||
inverted=True,
|
||||
)
|
||||
x += sl_w + 2
|
||||
for name, _can_ch, mover_chs, fg, cng in RGB:
|
||||
place_slider(
|
||||
f"M {name}",
|
||||
x,
|
||||
y0,
|
||||
sl_w,
|
||||
sl_h,
|
||||
[(fid, c) for fid in (M1, M2) for c in mover_chs],
|
||||
fg=fg,
|
||||
cng=cng,
|
||||
)
|
||||
x += sl_w + 2
|
||||
x += block_gap - 2
|
||||
x = place_looks(
|
||||
"Position",
|
||||
position_button_specs(),
|
||||
x,
|
||||
y0,
|
||||
cols=2,
|
||||
btn_w=72,
|
||||
)
|
||||
x += block_gap
|
||||
x = place_looks("Movers", look_specs["movers"], x, y0)
|
||||
|
||||
y1 = y0 + pad_h + 40
|
||||
x = 10
|
||||
groups = [
|
||||
("1-2", GROUP_L),
|
||||
("3-6", GROUP_C),
|
||||
("7-8", GROUP_R),
|
||||
]
|
||||
for label, fids in groups:
|
||||
block_w = 4 * sl_w + 3 * 2
|
||||
widgets.append(label_frame(wid, f"Cans {label}", x, y1 - 28, block_w, 24))
|
||||
wid += 1
|
||||
x = place_rgb_block(
|
||||
label,
|
||||
x,
|
||||
y1,
|
||||
[(f, 0) for f in fids],
|
||||
lambda _n, can_ch, _m, fids=fids: [(f, can_ch) for f in fids],
|
||||
)
|
||||
x += block_gap
|
||||
|
||||
place_slider(
|
||||
"C Bright",
|
||||
x,
|
||||
y1,
|
||||
sl_w,
|
||||
sl_h,
|
||||
[(f, 0) for f in CANS],
|
||||
255,
|
||||
"4294967295",
|
||||
)
|
||||
x += sl_w + 2
|
||||
place_slider(
|
||||
"C Color",
|
||||
x,
|
||||
y1,
|
||||
sl_w,
|
||||
sl_h,
|
||||
[(f, ch) for f in CANS for ch in (2, 3, 4)],
|
||||
0,
|
||||
"4294967295",
|
||||
"RGB",
|
||||
)
|
||||
x += sl_w + block_gap
|
||||
x = place_looks("Cans", look_specs["cans"], x, y1)
|
||||
x += block_gap
|
||||
place_looks("Cans Odd/Even", look_specs["cans_oe"], x, y1)
|
||||
|
||||
total_w = max_x + 16
|
||||
total_h = max_y + 16
|
||||
|
||||
qxw = f"""<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE Workspace>
|
||||
<Workspace xmlns="http://www.qlcplus.org/Workspace" CurrentWindow="VirtualConsole">
|
||||
<Creator>
|
||||
<Name>Q Light Controller Plus</Name>
|
||||
<Version>4.12.7</Version>
|
||||
<Author>Jimmy</Author>
|
||||
</Creator>
|
||||
<Engine>
|
||||
<InputOutputMap>
|
||||
<Universe Name="Universe 1" ID="0">
|
||||
<Output Plugin="ArtNet" UID="192.168.1.92" Line="7">
|
||||
<PluginParameters outputIP="192.168.1.228" outputUni="0"/>
|
||||
</Output>
|
||||
</Universe>
|
||||
<Universe Name="Universe 2" ID="1"/>
|
||||
<Universe Name="Universe 3" ID="2"/>
|
||||
<Universe Name="Universe 4" ID="3"/>
|
||||
</InputOutputMap>
|
||||
{fixture_xml()}
|
||||
{fixture_groups_xml()}
|
||||
{look_scenes_xml()}
|
||||
{position_scene_xml()}
|
||||
{figure8_efx_xml()}
|
||||
</Engine>
|
||||
<VirtualConsole>
|
||||
<Frame Caption="">
|
||||
<Appearance>
|
||||
<FrameStyle>None</FrameStyle>
|
||||
<ForegroundColor>Default</ForegroundColor>
|
||||
<BackgroundColor>Default</BackgroundColor>
|
||||
<BackgroundImage>None</BackgroundImage>
|
||||
<Font>Default</Font>
|
||||
</Appearance>
|
||||
{"\n".join(widgets)}
|
||||
</Frame>
|
||||
<Properties>
|
||||
<Size Width="{total_w}" Height="{total_h}"/>
|
||||
<GrandMaster ChannelMode="Intensity" ValueMode="Reduce" SliderMode="Normal"/>
|
||||
</Properties>
|
||||
</VirtualConsole>
|
||||
<SimpleDesk>
|
||||
<Engine/>
|
||||
</SimpleDesk>
|
||||
</Workspace>
|
||||
"""
|
||||
OUT.parent.mkdir(parents=True, exist_ok=True)
|
||||
OUT.write_text(qxw)
|
||||
print(f"Wrote {OUT} ({total_w}x{total_h}, {wid} widgets)")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -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()
|
||||
@@ -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()
|
||||
@@ -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()
|
||||
Reference in new issue
Block a user