Files
qlcplus/scripts/make_twisted_vc.py
T

954 lines
27 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""Generate shows/twisted.qxw — 15 cans + 4 movers with SMC-PAD MIDI.
Level sliders: knobs 1–16 (MIDI CC 30–45 on Universe 2).
Pad banks (8 each, SoloFrame + MIDI notes):
Movers 1–8 pad 1 wander, pad 5 all Colour 1, pad 6 outer 1 / centre 2
Cans 9–16 pad 13 all Colour 1, pad 14 split
Can colour (one writer per fixture channel):
Colour 1 knobs → Level on C1 cans + mover outer; Playback scenes on the
other cans (All C1 only). Same MIDI, disjoint fixtures.
Colour 2 knobs → Level on mover centre only; Playback on C2 cans (Split).
No fixture channel is wired to two sliders at once.
pipenv run python scripts/make_twisted_vc.py
shows/twisted.qxw also has hand-built functions (venue wave, static,
mover centre off). Regenerating from this script drops those.
"""
from __future__ import annotations
from pathlib import Path
from urllib.parse import quote
ROOT = Path(__file__).resolve().parents[1]
OUT = ROOT / "shows" / "twisted.qxw"
# Fixture IDs
CAN_1_8 = list(range(8))
# Cans 9–12 (13–15 dim on shared auto-cans slider)
CAN_9_12 = [8, 9, 10, 11]
ALL_CANS = list(range(15))
# Cans 13–15: R→purple→yellow chasers, one full fade apart (≈120° on the cycle).
CAN13_FID = 12
CAN14_FID = 13
CAN15_FID = 14
AUTO_COLOR_CANS = frozenset({CAN13_FID, CAN14_FID, CAN15_FID})
# Colour 1: cans 1–12 only.
C1_CANS = list(range(12)) # fixtures 0–11
C2_CANS: list[int] = [] # split pad stops C1ext; no can Colour 2
C1_EXT_CANS = sorted(set(ALL_CANS) - set(C1_CANS) - AUTO_COLOR_CANS)
MOVERS = [15, 16, 17, 18] # Front L/R, Back L/R
MOVERS_FRONT = [15, 16]
MOVER_BACK_LEFT = 17
MOVER_BACK_RIGHT = 18
PAN_OFFSET_BL = 64 # +90°
PAN_OFFSET_BR = 192 # −90°
# Private CCs. Knob 9/10 stay on CC 38/39; scripts/mover_offsets_midi.py
# adds that encoder step onto each of these so the corrections survive.
PAN_MIDI = (50, 51, 52, 53) # FL FR BL BR
TILT_MIDI = (54, 55, 56, 57)
FID_WANDER = 0 # pad 1
FID_WANDER_FRONT = 54
FID_WANDER_BACK = 55
# One slow circle around the live aim. ±18 pan, ±12 tilt, 24s.
WANDER_MS = 24000
WANDER_FADE_MS = 4000
WANDER_PAN = 18
WANDER_TILT = 12
WANDER_BG = "4294953472"
FID_MOVER_ALL_C1 = 4
FID_MOVER_SPLIT = 5
FID_CAN_ALL_C1 = 12
FID_CAN_SPLIT = 13
FID_C1EXT_R, FID_C1EXT_G, FID_C1EXT_B = 16, 17, 18
FID_C2PB_R, FID_C2PB_G, FID_C2PB_B = 19, 20, 21
FID_CAN13_RED, FID_CAN13_PURPLE, FID_CAN13_YELLOW = 23, 24, 25
FID_CAN13_CHASER = 26
FID_CAN14_RED, FID_CAN14_PURPLE, FID_CAN14_YELLOW = 27, 28, 29
FID_CAN14_CHASER = 30
FID_CAN_AUTOCHASER_START = 31
FID_CAN15_RED, FID_CAN15_PURPLE, FID_CAN15_YELLOW = 32, 33, 34
FID_CAN15_CHASER = 35
STARTUP_ID = 22
CAN_CHASE_MS = 3500
CAN_CHASE_PHASE_MS = CAN_CHASE_MS
CAN_TRANSITION_MIN_MS = 500
CAN_TRANSITION_MAX_MS = 10000
# Speed Dial visibility: PlusMinus=2 Seconds=32 Milliseconds=64
SPEED_VIS_FADER = 2 | 32 | 64
MOVER_R_CENTER = [10]
MOVER_G_CENTER = [11]
MOVER_B_CENTER = [12]
MOVER_R_OUTER = [14, 18, 22, 26, 30, 34]
MOVER_G_OUTER = [15, 19, 23, 27, 31, 35]
MOVER_B_OUTER = [16, 20, 24, 28, 32, 36]
MOVER_ADDRS = (0, 44, 257, 300)
MOVER_NAMES = (
"Front Left Mover",
"Front Right Mover",
"Back Left Mover",
"Back Right Mover",
)
def appearance(fg: str = "Default") -> str:
return f""" <Appearance>
<FrameStyle>Sunken</FrameStyle>
<ForegroundColor>{fg}</ForegroundColor>
<BackgroundColor>Default</BackgroundColor>
<BackgroundImage>None</BackgroundImage>
<Font>Default</Font>
</Appearance>"""
def label_frame(caption: str, x: int, y: int, w: int, h: int = 28) -> str:
return f""" <Frame Caption="{caption}">
<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 knob_cc(knob: int) -> int:
return 29 + knob
def pad_input_channel(pad: int) -> int:
note = 35 + pad
return 128 + note
def relative_circle(
func_id: int,
name: str,
fixtures: list[tuple[int, int]],
*,
rotation: int,
) -> str:
"""Relative circle around the live pan/tilt. Offset 127 is no shift."""
fixture_xml = "\n".join(
f""" <Fixture>
<ID>{fid}</ID>
<Head>0</Head>
<Mode>0</Mode>
<Direction>Forward</Direction>
<StartOffset>{offset}</StartOffset>
</Fixture>"""
for fid, offset in fixtures
)
return f""" <Function ID="{func_id}" Type="EFX" Name="{name}">
{fixture_xml}
<PropagationMode>Parallel</PropagationMode>
<Speed FadeIn="{WANDER_FADE_MS}" FadeOut="0" Duration="{WANDER_MS}"/>
<Direction>Forward</Direction>
<RunOrder>Loop</RunOrder>
<Algorithm>Circle</Algorithm>
<Width>{WANDER_PAN}</Width>
<Height>{WANDER_TILT}</Height>
<Rotation>{rotation}</Rotation>
<StartOffset>0</StartOffset>
<IsRelative>1</IsRelative>
<Axis Name="X">
<Offset>127</Offset>
<Frequency>1</Frequency>
<Phase>0</Phase>
</Axis>
<Axis Name="Y">
<Offset>127</Offset>
<Frequency>1</Frequency>
<Phase>0</Phase>
</Axis>
</Function>"""
def collection(func_id: int, name: str, steps: list[int]) -> str:
step_xml = "\n".join(
f' <Step Number="{i}">{sid}</Step>' for i, sid in enumerate(steps)
)
return f""" <Function ID="{func_id}" Type="Collection" Name="{name}">
<Speed FadeIn="0" FadeOut="0" Duration="0"/>
{step_xml}
</Function>"""
def scene(func_id: int, name: str) -> str:
return f""" <Function ID="{func_id}" Type="Scene" Name="{name}">
<Speed FadeIn="0" FadeOut="0" Duration="0"/>
</Function>"""
def chaser_xml(
func_id: int,
name: str,
steps: list[int],
*,
fade_in: int,
hold: int = 0,
fade_out: int = 0,
) -> str:
duration = fade_in + hold + fade_out
step_xml = "\n".join(
f' <Step Number="{i}" FadeIn="{fade_in}" Hold="{hold}" FadeOut="{fade_out}">{sid}</Step>'
for i, sid in enumerate(steps)
)
return f""" <Function ID="{func_id}" Type="Chaser" Name="{name}">
<Speed FadeIn="{fade_in}" FadeOut="{fade_out}" Duration="{duration}"/>
<Direction>Forward</Direction>
<RunOrder>Loop</RunOrder>
<SpeedModes FadeIn="Common" FadeOut="Common" Duration="Common"/>
{step_xml}
</Function>"""
def solo_can_color_scene(
can_fid: int, func_id: int, name: str, r: int, g: int, b: int
) -> str:
return channel_scene(
func_id,
name,
[can_fid],
[(2, r), (3, g), (4, b)],
)
def channel_scene(
func_id: int,
name: str,
fixtures: list[int],
values: list[tuple[int, int]],
) -> str:
payload = ",".join(f"{ch},{val}" for ch, val in values)
vals = "\n".join(
f' <FixtureVal ID="{fid}">{payload}</FixtureVal>' for fid in fixtures
)
return f""" <Function ID="{func_id}" Type="Scene" Name="{name}">
<Speed FadeIn="0" FadeOut="0" Duration="0"/>
{vals}
</Function>"""
def script(func_id: int, name: str, lines: list[str]) -> str:
cmds = "\n".join(
f" <Command>{quote(line, safe='')}</Command>" for line in lines
)
return f""" <Function ID="{func_id}" Type="Script" Name="{name}">
<Speed FadeIn="0" FadeOut="0" Duration="0"/>
<Direction>Forward</Direction>
<RunOrder>Loop</RunOrder>
{cmds}
</Function>"""
def hold_mode_script(
func_id: int,
name: str,
*,
start: list[int] | None = None,
stop: list[int] | None = None,
) -> str:
lines = ["stoponexit:false"]
for fid in stop or []:
lines.append(f"stopfunction:{fid}")
for fid in start or []:
lines.append(f"startfunction:{fid}")
lines.extend(["label:keep", "wait:3600000", "jump:keep"])
return script(func_id, name, lines)
def button(
wid: int,
caption: str,
func_id: int,
x: int,
y: int,
w: int,
h: int,
*,
pad: int | None = None,
bg: str = "4282664004",
fg: str = "4294967295",
indent: str = " ",
) -> str:
midi = ""
if pad is not None:
midi = f"\n{indent} <Input Universe=\"1\" Channel=\"{pad_input_channel(pad)}\"/>"
return f"""{indent}<Button Caption="{caption}" ID="{wid}" Icon="">
{indent} <WindowState Visible="True" X="{x}" Y="{y}" Width="{w}" Height="{h}"/>
{indent} <Appearance>
{indent} <FrameStyle>None</FrameStyle>
{indent} <ForegroundColor>{fg}</ForegroundColor>
{indent} <BackgroundColor>{bg}</BackgroundColor>
{indent} <BackgroundImage>None</BackgroundImage>
{indent} <Font>Default</Font>
{indent} </Appearance>{midi}
{indent} <Function ID="{func_id}"/>
{indent} <Action>Toggle</Action>
{indent} <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 slider(
wid: int,
caption: str,
x: int,
y: int,
w: int,
h: int,
channels: list[tuple[int, int]],
*,
knob: int | None = None,
midi: int | None = None,
value: int = 0,
fg: str = "Default",
cng: str = "None",
) -> str:
ch_xml = "\n".join(
f' <Channel Fixture="{fid}">{ch}</Channel>' for fid, ch in channels
)
channel = midi if midi is not None else (None if knob is None else knob_cc(knob))
midi_xml = ""
if channel is not None:
midi_xml = f'\n <Input Universe="1" Channel="{channel}"/>'
return f""" <Slider Caption="{caption}" ID="{wid}" WidgetStyle="Slider" InvertedAppearance="false">
<WindowState Visible="True" X="{x}" Y="{y}" Width="{w}" Height="{h}"/>
{appearance(fg=fg)}{midi_xml}
<SliderMode ValueDisplayStyle="Exact" ClickAndGoType="{cng}" Monitor="false">Level</SliderMode>
<Level LowLimit="0" HighLimit="255" Value="{value}">
{ch_xml}
</Level>
<Playback>
<Function>4294967295</Function>
</Playback>
</Slider>"""
def speed_dial(
wid: int,
caption: str,
x: int,
y: int,
w: int,
h: int,
time_ms: int,
functions: list[tuple[int, int, int]],
*,
min_ms: int = CAN_TRANSITION_MIN_MS,
max_ms: int = CAN_TRANSITION_MAX_MS,
visibility: int = SPEED_VIS_FADER,
knob: int | None = None,
) -> str:
"""functions are (func_id, duration_mult, fade_in_mult); 0 = not sent."""
fn_xml = "\n".join(
f' <Function FadeIn="{fade}" FadeOut="0" Duration="{dur}">{fid}</Function>'
for fid, dur, fade in functions
)
midi = ""
if knob is not None:
midi = f'\n <Input Universe="1" Channel="{knob_cc(knob)}"/>'
return f""" <SpeedDial Caption="{caption}" ID="{wid}">
<WindowState Visible="True" X="{x}" Y="{y}" Width="{w}" Height="{h}"/>
{appearance()}{midi}
<Visibility>{visibility}</Visibility>
<AbsoluteValue Minimum="{min_ms}" Maximum="{max_ms}"/>
<Time>{time_ms}</Time>
{fn_xml}
</SpeedDial>"""
def playback_slider(
wid: int,
caption: str,
x: int,
y: int,
w: int,
h: int,
func_id: int,
*,
knob: int,
fg: str = "Default",
cng: str = "None",
) -> str:
return f""" <Slider Caption="{caption}" ID="{wid}" WidgetStyle="Slider" InvertedAppearance="false">
<WindowState Visible="True" X="{x}" Y="{y}" Width="{w}" Height="{h}"/>
{appearance(fg=fg)}
<Input Universe="1" Channel="{knob_cc(knob)}"/>
<SliderMode ValueDisplayStyle="Exact" ClickAndGoType="{cng}" Monitor="false">Playback</SliderMode>
<Level LowLimit="0" HighLimit="255" Value="0"/>
<Playback>
<Function>{func_id}</Function>
</Playback>
</Slider>"""
def fixture_xml() -> str:
parts: list[str] = []
for i in range(15):
parts.append(
f""" <Fixture>
<Manufacturer>beamZ</Manufacturer>
<Model>BCC145</Model>
<Mode>8 Channel</Mode>
<ID>{i}</ID>
<Name>BCC145 #{i + 1:02d}</Name>
<Universe>0</Universe>
<Address>{87 + i * 8}</Address>
<Channels>8</Channels>
</Fixture>"""
)
for i, (addr, name) in enumerate(zip(MOVER_ADDRS, MOVER_NAMES)):
parts.append(
f""" <Fixture>
<Manufacturer>Small Eye 7</Manufacturer>
<Model>Mover</Model>
<Mode>43 Channel</Mode>
<ID>{15 + i}</ID>
<Name>{name}</Name>
<Universe>0</Universe>
<Address>{addr}</Address>
<Channels>43</Channels>
</Fixture>"""
)
return "\n".join(parts)
def main() -> None:
sl_w, sl_h = 52, 200
gap = 8
group_gap = 24
row_gap = 20
widgets: list[str] = []
wid = 0
max_x = 0
max_y = 0
def place(caption, x, y, channels, *, knob=None, midi=None, value=0, fg="Default", cng="None"):
nonlocal wid, max_x, max_y
widgets.append(
slider(
wid,
caption,
x,
y,
sl_w,
sl_h,
channels,
knob=knob,
midi=midi,
value=value,
fg=fg,
cng=cng,
)
)
wid += 1
max_x = max(max_x, x + sl_w)
max_y = max(max_y, y + sl_h)
def header(caption: str, x: int, y: int, cols: int) -> None:
w = cols * sl_w + (cols - 1) * gap
widgets.append(label_frame(caption, x, y, w))
btn_w, btn_h = 72, 48
btn_gap = 6
bank_pad = 10
cols, rows = 4, 2
bank_inner_w = cols * btn_w + (cols - 1) * btn_gap
bank_w = bank_pad * 2 + bank_inner_w
bank_h = 28 + rows * btn_h + (rows - 1) * btn_gap + bank_pad
mover_labels = {
1: ("Wander", WANDER_BG),
5: ("All C1", "4278236360"),
6: ("Outer/Ctr", "4282664004"),
}
can_labels = {
13: ("All C1", "4284900966"),
14: ("Split 1/2", "4286611584"),
}
c1ext_ids = (FID_C1EXT_R, FID_C1EXT_G, FID_C1EXT_B)
c2pb_ids = (FID_C2PB_R, FID_C2PB_G, FID_C2PB_B)
functions_list = [scene(i, f"Pad {i + 1}") for i in range(16)]
# Back heads are hung 90°, so their box is rotated to match the room.
functions_list[FID_WANDER] = collection(
FID_WANDER,
"Wander",
[FID_WANDER_FRONT, FID_WANDER_BACK],
)
functions_list[FID_MOVER_ALL_C1] = scene(FID_MOVER_ALL_C1, "Movers: All Colour 1")
functions_list[FID_MOVER_SPLIT] = scene(FID_MOVER_SPLIT, "Movers: Outer 1 / Centre 2")
functions_list[FID_CAN_ALL_C1] = hold_mode_script(
FID_CAN_ALL_C1,
"Cans: All Colour 1",
stop=list(c2pb_ids),
)
functions_list[FID_CAN_SPLIT] = hold_mode_script(
FID_CAN_SPLIT,
"Cans: Split Colour 1 / 2",
stop=list(c1ext_ids),
)
functions_list.extend(
[
channel_scene(FID_C1EXT_R, "C1ext R", C1_EXT_CANS, [(2, 255)]),
channel_scene(FID_C1EXT_G, "C1ext G", C1_EXT_CANS, [(3, 255)]),
channel_scene(FID_C1EXT_B, "C1ext B", C1_EXT_CANS, [(4, 255)]),
channel_scene(FID_C2PB_R, "C2 cans R", C2_CANS, [(2, 255)]),
channel_scene(FID_C2PB_G, "C2 cans G", C2_CANS, [(3, 255)]),
channel_scene(FID_C2PB_B, "C2 cans B", C2_CANS, [(4, 255)]),
solo_can_color_scene(
CAN13_FID, FID_CAN13_RED, "Can 13 Red", 255, 0, 0
),
solo_can_color_scene(
CAN13_FID, FID_CAN13_PURPLE, "Can 13 Purple", 200, 0, 255
),
solo_can_color_scene(
CAN13_FID, FID_CAN13_YELLOW, "Can 13 Yellow", 255, 200, 0
),
chaser_xml(
FID_CAN13_CHASER,
"Can 13 Red Purple Yellow",
[FID_CAN13_RED, FID_CAN13_PURPLE, FID_CAN13_YELLOW],
fade_in=CAN_CHASE_MS,
),
solo_can_color_scene(
CAN14_FID, FID_CAN14_RED, "Can 14 Red", 255, 0, 0
),
solo_can_color_scene(
CAN14_FID, FID_CAN14_PURPLE, "Can 14 Purple", 200, 0, 255
),
solo_can_color_scene(
CAN14_FID, FID_CAN14_YELLOW, "Can 14 Yellow", 255, 200, 0
),
chaser_xml(
FID_CAN14_CHASER,
"Can 14 Red Purple Yellow",
[FID_CAN14_RED, FID_CAN14_PURPLE, FID_CAN14_YELLOW],
fade_in=CAN_CHASE_MS,
),
solo_can_color_scene(
CAN15_FID, FID_CAN15_RED, "Can 15 Red", 255, 0, 0
),
solo_can_color_scene(
CAN15_FID, FID_CAN15_PURPLE, "Can 15 Purple", 200, 0, 255
),
solo_can_color_scene(
CAN15_FID, FID_CAN15_YELLOW, "Can 15 Yellow", 255, 200, 0
),
chaser_xml(
FID_CAN15_CHASER,
"Can 15 Red Purple Yellow",
[FID_CAN15_RED, FID_CAN15_PURPLE, FID_CAN15_YELLOW],
fade_in=CAN_CHASE_MS,
),
script(
FID_CAN_AUTOCHASER_START,
"Start can 13/14/15 chasers phased",
[
"stoponexit:false",
f"startfunction:{FID_CAN13_CHASER}",
f"wait:{CAN_CHASE_PHASE_MS}",
f"startfunction:{FID_CAN14_CHASER}",
f"wait:{CAN_CHASE_PHASE_MS}",
f"startfunction:{FID_CAN15_CHASER}",
"label:keep",
"wait:3600000",
"jump:keep",
],
),
f""" <Function ID="{STARTUP_ID}" Type="Collection" Name="Startup: All Colour 1">
<Step Number="0">{FID_CAN_ALL_C1}</Step>
<Step Number="1">{FID_MOVER_ALL_C1}</Step>
<Step Number="2">{FID_CAN_AUTOCHASER_START}</Step>
<Step Number="3">{FID_WANDER}</Step>
</Function>""",
relative_circle(
FID_WANDER_FRONT,
"Wander front",
[(MOVERS_FRONT[0], 0), (MOVERS_FRONT[1], 180)],
rotation=0,
),
relative_circle(
FID_WANDER_BACK,
"Wander back",
[(MOVER_BACK_LEFT, 90), (MOVER_BACK_RIGHT, 270)],
rotation=90,
),
]
)
def pad_bank(
title: str,
pads: range,
labels: dict[int, tuple[str, str]],
x0: int,
y0: int,
default_bg: str,
) -> None:
nonlocal wid, max_x, max_y
kids: list[str] = []
for i, pad in enumerate(pads):
col = i % cols
row = (rows - 1) - (i // cols)
bx = bank_pad + col * (btn_w + btn_gap)
by = 28 + row * (btn_h + btn_gap)
if pad in labels:
caption, bg = labels[pad]
else:
caption, bg = "", default_bg
kids.append(
button(
wid + i,
caption,
pad - 1,
bx,
by,
btn_w,
btn_h,
pad=pad,
bg=bg,
)
)
frame_id = wid + len(pads)
widgets.append(
solo_frame(frame_id, title, x0, y0, bank_w, bank_h, "\n".join(kids))
)
wid = frame_id + 1
max_x = max(max_x, x0 + bank_w)
max_y = max(max_y, y0 + bank_h)
left_x = 16
label_y1 = 12
y1 = 44
x = left_x
header("Colour 1 (outer)", x, label_y1, 3)
place(
"R",
x,
y1,
[(f, 2) for f in C1_CANS] + [(m, c) for m in MOVERS for c in MOVER_R_OUTER],
knob=5,
fg="4294901760",
cng="Red",
)
place(
"G",
x + sl_w + gap,
y1,
[(f, 3) for f in C1_CANS] + [(m, c) for m in MOVERS for c in MOVER_G_OUTER],
knob=3,
fg="4278255360",
cng="Green",
)
place(
"B",
x + 2 * (sl_w + gap),
y1,
[(f, 4) for f in C1_CANS] + [(m, c) for m in MOVERS for c in MOVER_B_OUTER],
knob=1,
fg="4278190335",
cng="Blue",
)
c1_x = x
x += 3 * (sl_w + gap) + group_gap
header("Colour 2 (centre)", x, label_y1, 3)
place(
"R",
x,
y1,
[(m, c) for m in MOVERS for c in MOVER_R_CENTER],
knob=6,
fg="4294901760",
cng="Red",
)
place(
"G",
x + sl_w + gap,
y1,
[(m, c) for m in MOVERS for c in MOVER_G_CENTER],
knob=4,
fg="4278255360",
cng="Green",
)
place(
"B",
x + 2 * (sl_w + gap),
y1,
[(m, c) for m in MOVERS for c in MOVER_B_CENTER],
knob=2,
fg="4278190335",
cng="Blue",
)
c2_x = x
colours_right = x + 3 * (sl_w + gap)
auto_dim_x = colours_right + group_gap
header("Can 13–15", auto_dim_x, label_y1, 2)
place(
"Bright",
auto_dim_x,
y1,
[(CAN13_FID, 0), (CAN14_FID, 0), (CAN15_FID, 0)],
knob=7,
)
transition_funcs = [
(FID_CAN13_CHASER, 6, 6),
(FID_CAN14_CHASER, 6, 6),
(FID_CAN15_CHASER, 6, 6),
(FID_CAN_AUTOCHASER_START, 6, 0),
]
widgets.append(
speed_dial(
wid,
"Transition",
auto_dim_x + sl_w + gap,
y1,
sl_w,
sl_h,
CAN_CHASE_MS,
transition_funcs,
knob=8,
)
)
wid += 1
max_x = max(max_x, auto_dim_x + 2 * sl_w + gap)
max_y = max(max_y, y1 + sl_h)
auto_dim_right = auto_dim_x + 2 * sl_w + gap
# Width of brightness (3) + mover row for pattern bank alignment.
row2_right = (
left_x
+ 3 * sl_w
+ 2 * gap
+ group_gap
+ 10 * sl_w
+ 9 * gap
)
pattern_x = max(auto_dim_right, row2_right) + group_gap
pad_bank(
"Can patterns",
range(9, 17),
can_labels,
pattern_x,
label_y1,
"4284900966",
)
label_y2 = y1 + sl_h + row_gap
y2 = label_y2 + 32
x = left_x
header("Brightness", x, label_y2, 3)
place("Cans 1–8", x, y2, [(f, 0) for f in CAN_1_8], knob=15)
place(
"Cans 9–12",
x + sl_w + gap,
y2,
[(f, 0) for f in CAN_9_12],
knob=16,
)
place(
"Movers",
x + 2 * (sl_w + gap),
y2,
[(m, 8) for m in MOVERS],
knob=13,
)
x += 3 * (sl_w + gap) + group_gap
header("Movers", x, label_y2, 10)
place("FL", x, y2, [(MOVERS_FRONT[0], 0)], midi=PAN_MIDI[0])
place("FR", x + sl_w + gap, y2, [(MOVERS_FRONT[1], 0)], midi=PAN_MIDI[1])
place(
"BL +90°",
x + 2 * (sl_w + gap),
y2,
[(MOVER_BACK_LEFT, 0)],
midi=PAN_MIDI[2],
value=PAN_OFFSET_BL,
)
place(
"BR −90°",
x + 3 * (sl_w + gap),
y2,
[(MOVER_BACK_RIGHT, 0)],
midi=PAN_MIDI[3],
value=PAN_OFFSET_BR,
)
place("Tilt FL", x + 4 * (sl_w + gap), y2, [(MOVERS_FRONT[0], 2)], midi=TILT_MIDI[0])
place("Tilt FR", x + 5 * (sl_w + gap), y2, [(MOVERS_FRONT[1], 2)], midi=TILT_MIDI[1])
place("Tilt BL", x + 6 * (sl_w + gap), y2, [(MOVER_BACK_LEFT, 2)], midi=TILT_MIDI[2])
place("Tilt BR", x + 7 * (sl_w + gap), y2, [(MOVER_BACK_RIGHT, 2)], midi=TILT_MIDI[3])
place(
"Focus",
x + 8 * (sl_w + gap),
y2,
[(m, 7) for m in MOVERS],
knob=11,
value=70,
)
place("Rotate", x + 9 * (sl_w + gap), y2, [(m, 5) for m in MOVERS], knob=12)
pad_bank(
"Mover patterns",
range(1, 9),
mover_labels,
pattern_x,
label_y2,
"4278218076",
)
# C1ext Playback: same knobs as Colour 1, disjoint cans (All C1). Stop via pad 14 script.
pb_y = max_y + 12
pb_h = 28
pb_w = 3 * sl_w + 2 * gap
pb_kids = []
for i, (cap, fid, knob, fg, cng) in enumerate(
[
("C1ext R", FID_C1EXT_R, 5, "4294901760", "Red"),
("C1ext G", FID_C1EXT_G, 3, "4278255360", "Green"),
("C1ext B", FID_C1EXT_B, 1, "4278190335", "Blue"),
]
):
pb_kids.append(
playback_slider(
wid + i,
cap,
c1_x + i * (sl_w + gap),
pb_y,
sl_w,
pb_h,
fid,
knob=knob,
fg=fg,
cng=cng,
)
)
wid += 3
for i, (cap, fid, knob, fg, cng) in enumerate(
[
("C2can R", FID_C2PB_R, 6, "4294901760", "Red"),
("C2can G", FID_C2PB_G, 4, "4278255360", "Green"),
("C2can B", FID_C2PB_B, 2, "4278190335", "Blue"),
]
):
pb_kids.append(
playback_slider(
wid + i,
cap,
c2_x + i * (sl_w + gap),
pb_y,
sl_w,
pb_h,
fid,
knob=knob,
fg=fg,
cng=cng,
)
)
wid += 3
widgets.extend(pb_kids)
max_y = max(max_y, pb_y + pb_h)
max_x = max(max_x, c1_x + pb_w, c2_x + pb_w)
functions = "\n".join(functions_list)
margin = 24
canvas_scale = 2
total_w = (max_x + margin) * canvas_scale
total_h = (max_y + margin) * canvas_scale
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>tech</Author>
</Creator>
<Engine Autostart="{STARTUP_ID}">
<InputOutputMap>
<Universe Name="Universe 1" ID="0">
<Output Plugin="ArtNet" UID="192.168.1.143" Line="1"/>
</Universe>
<Universe Name="Universe 2" ID="1">
<Input Plugin="MIDI" UID="SMC-PAD Bluetooth" Line="1"/>
</Universe>
<Universe Name="Universe 3" ID="2"/>
<Universe Name="Universe 4" ID="3"/>
</InputOutputMap>
{fixture_xml()}
{functions}
</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()