#!/usr/bin/env python3 """Add a Movers speed dial on knob 13 to shows/test.qxw. Knob 13 (CC 42) sets how long Wander and Ballyhoo take to go round, as knob 1 does for the cans' chases. Wander gets the dial's time and Ballyhoo an eighth of it. QLC+ 4.12 counts an EFX's fade-in inside every round, not just the first, so a round takes that less its fade-in (2 s for Wander, 0.5 s for Ballyhoo): Knob fully left 62 s Wander, 7.5 s Ballyhoo Starting value 22 s Wander, 2.5 s Ballyhoo (as before the dial) Knob fully right 10 s Wander, 1 s Ballyhoo The fade-ins stay, so the movers don't jump when either starts. The dial sits beside the cans' Speed dial. python3 scripts/shows/mover_speed.py Run it once on a show with Wander and Ballyhoo; it stops if the dial is already there. QLC+ has to reopen the show to see it. """ from __future__ import annotations import re from mover_bank import NO_FUNCTION, ROOT, appearance SHOW = ROOT / "shows" / "test.qxw" SPEED_CC = 42 # knob 13 SLOWEST_MS, FASTEST_MS, START_MS = 64000, 12000, 24000 # Index into QLC+'s speed dial factors: (Not Sent), 0, 1/16, 1/8, 1/4, 1/2, 1, 2, 4, 8, 16 TIMES_1, TIMES_1_8 = 6, 3 NOT_SENT = 0 def main() -> None: xml = SHOW.read_text() if 'Caption="Movers speed"' in xml: raise SystemExit(f"{SHOW.relative_to(ROOT)} already has the movers speed dial") engine, console = xml.split("") wid = max(int(i) for i in re.findall(r' ID="(\d+)"', console) if int(i) != NO_FUNCTION) + 1 def function(name: str) -> int: return int(re.search(rf'', engine).group(1)) rows = "".join(f' {function(name)}\n' for name, factor in (("Movers wander", TIMES_1), ("Movers ballyhoo", TIMES_1_8))) dial = (f' \n' ' \n' + appearance(" ", "Sunken") + f' \n' f' \n' ' \n' f' \n' + rows + ' \n') xml = xml.replace(" \n ", dial + " \n ", 1) SHOW.write_text(xml) print(f"Added the movers speed dial to {SHOW.relative_to(ROOT)} (widget {wid}, knob 13)") if __name__ == "__main__": main()