#!/usr/bin/env python3 """Split the movers' Pan slider in shows/test.qxw so the back pair face the back wall at knob 0. M3 and M4 are mounted 90° round from M1 and M2: at pan 0 the front pair face the audience and the back pair face the middle. Knob 9 (CC 38) now drives two sliders over the same span of 212 steps, so the pairs keep that 90° of pan (about 43 steps of 540°) between them all the way round: Pan M1, M2 0–212 Pan back M3, M4 43–255 At knob 0 the front pair face the audience and the back pair the back wall. Turning it, the left pair (M1, M3) and the right pair (M2, M4) point at the centre together and at the side walls together. python3 scripts/shows/mover_pan_back.py Run it once on a show without it; it stops if it is already there. QLC+ has to reopen the show to see it. """ from __future__ import annotations import re from mover_bank import M1, M2, M3, M4, NO_FUNCTION, ROOT SHOW = ROOT / "shows" / "test.qxw" BACK_OFFSET = 43 # 90° of pan, of 540° over 256 steps ORDER = ("Brightness", "Pan", "Pan back", "Tilt", "Focus", "Rotate") def main() -> None: xml = SHOW.read_text() if 'Caption="Pan back"' in xml: raise SystemExit(f"{SHOW.relative_to(ROOT)} already has the back movers' pan") wid = max(int(i) for i in re.findall(r' ID="(\d+)"', xml.split("")[1]) if int(i) != NO_FUNCTION) + 1 start = xml.index('", start) frame = xml[start:end] pan = re.search(r' \n', frame, re.S).group(0) level = re.search(r'', pan).group(0) def rows(*fixtures: int) -> str: return "".join(f' 0\n' for f in fixtures) channels = rows(M1, M2, M3, M4) assert channels in pan front = (pan.replace(level, f'') .replace(channels, rows(M1, M2))) back = (re.sub(r'Caption="Pan" ID="\d+"', f'Caption="Pan back" ID="{wid}"', pan) .replace(level, f'') .replace(channels, rows(M3, M4))) frame = frame.replace(pan, front + back) # Six sliders 58 apart fit the frame as it is. for i, caption in enumerate(ORDER): frame, n = re.subn(rf'(]*>\n\s*{5 + 58 * i}"', frame) assert n == 1, caption SHOW.write_text(xml[:start] + frame + xml[end:]) print(f"Split the movers' Pan in {SHOW.relative_to(ROOT)} (Pan back is widget {wid})") if __name__ == "__main__": main()