#!/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 pad controller 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 colour scenes leave the dimmers alone: the Dimmers frame's Level sliders own them, on knob 15 (movers), knob 5 (cans 9–15), knob 7 (cans 3–6) and knob 8 (cans 1, 2, 7, 8). """ 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 # padcontroller/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 PAD_PORT = "padcontroller" # padcontroller/midi.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), ("Amber", 255, 191, 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), ) 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)] # Level sliders on the dimmer channels: caption, knob (from 1), fixtures, channel. DIMMERS = ( ("Movers", 15, MOVERS, MOVER_BRIGHTNESS), ("Cans 9–15", 5, CANS[8:], DIMMER), ("Cans 3–6", 7, CANS[2:6], DIMMER), ("Cans 1, 2, 7, 8", 8, CANS[0:2] + CANS[6:8], DIMMER), ) def dimmers() -> dict: return { "type": "frame", "caption": "Dimmers", "x": 10, "y": 630, "w": 250, "h": 250, "children": [{ "type": "slider", "caption": caption, "value": 255, "channels": [[fixture, channel] for fixture in fixtures], "x": 10 + index * 58, "y": 10, "w": 52, "h": 200, "input": {"universe": 1, "cc": [0, KNOB_FIRST_CC + knob - 1]}, } for index, (caption, knob, fixtures, channel) in enumerate(DIMMERS)], } 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): key = f"colour_{label}_{i + 1}" values = {can: {RED: r, GREEN: g, BLUE: b, WHITE: w} for can in cans} for mover in movers: values[mover] = {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}) 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) frames.append({ "type": "solo", "caption": f"Colour {label}", "x": 10, "y": 10 + si * 310, "w": 400, "h": 300, "children": buttons, }) spec["functions"] = functions spec["vc"] = frames + [dimmers()] SPEC.write_text(json.dumps(spec, indent=2) + "\n") if __name__ == "__main__": main()