#!/usr/bin/env python3 """Show in shows/test.qxw whether the pad's bank 1 is on the cans or the movers. Pause on the pad latches bank 1 onto the cans or the movers, but only padcontroller knows which is on (padcontroller/layer.py). It now says so on MIDI channel 16: note 0 held down for the cans and note 1 for the movers, the other released. Two Flash buttons in a Pads layer frame, under the movers pads frame, light while their note is held, so whichever is lit is the layer the pads are on. Flash rather than Toggle, so each message sets the state outright and a missed one can't leave them the wrong way round. Each flashes an empty scene of its own: QLC+ lights every button whose function is flashing, so with one scene between them both would light. python3 scripts/shows/layer_indicator.py Run it once; it stops if the frame 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, button, frame SHOW = ROOT / "shows" / "test.qxw" LAYER_NOTE_BASE = 15 * 4096 + 128 # QLC+ input channel of a channel-16 note: this plus the note CANS_NOTE, MOVERS_NOTE = 0, 1 # padcontroller/layer.py SIZE = 90 def main() -> None: xml = SHOW.read_text() if 'Caption="Pads layer"' in xml: raise SystemExit(f"{SHOW.relative_to(ROOT)} already has the pads layer indicator") fid = max(int(i) for i in re.findall(r'")[1]) if int(i) != NO_FUNCTION) + 1 layers = (("Cans pads", CANS_NOTE), ("Movers pads", MOVERS_NOTE)) scenes = "".join(f' \n' ' \n \n' for k, (caption, _) in enumerate(layers)) buttons = "".join(button(wid + 1 + k, caption, 10 + k * SIZE, 10, SIZE, fid + k, LAYER_NOTE_BASE + note, "Flash") for k, (caption, note) in enumerate(layers)) widget = frame(wid, "Pads layer", 470, 700, 2 * SIZE + 20, SIZE + 20, buttons, header=False) anchor = ' ' # after the movers pads in the console if anchor not in xml: raise SystemExit("Couldn't find the Movers position frame") xml = xml.replace(anchor, widget + anchor, 1) xml = xml.replace(" ", scenes + " ", 1) SHOW.write_text(xml) print(f"Added the pads layer indicator to {SHOW.relative_to(ROOT)} (widgets from ID {wid})") if __name__ == "__main__": main()