Toggle the pad's bank 1 to the movers with Pause, and add a Threshold sound mode.
Pause flips bank 1 between the cans (36-51) and the movers (84-99). Threshold flashes the cans on bass hits and is exclusive with Sound, and knob 6 is the sides' peak. The Sound and Threshold pads light while on, and the colour pads that were on are pressed again when QLC+ reloads the show. --lock-knobs is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
72c227b153
commit
11da656ee6
6 files changed
+378
-81
No files matched your search
+113
-32
@@ -4,16 +4,37 @@ The SMC-PAD sends CC 27 as 127 when Play goes down and 0 when it comes up.
|
||||
While it is down, pad notes 52–67 go out as 68–83, so QLC+ can tell a
|
||||
second set of buttons from the first. Play itself is not passed on.
|
||||
|
||||
With lock_knobs, knobs 1–5 (CC 30–34) drive colour 1's sliders and knobs 6–10
|
||||
(CC 35–39) drive colour 2's, but only after the Custom pad (note 67, or 83
|
||||
with Play held) has been pressed. Pressing any other bank 2 pad locks them
|
||||
again, and its sliders are sent back to zero so their scenes stop.
|
||||
Locked knob turns are dropped.
|
||||
Pause (CC 28) does the same for bank 1, but toggles: each press flips it.
|
||||
Off, bank 1 pads 36–51 go out as they are, for the cans. On, they go out as
|
||||
84–99, for the movers. Pause itself is not passed on. The movers are not
|
||||
sound reactive, so Sound and Threshold (84 and 85) do nothing on their layer.
|
||||
|
||||
The Sound pad (note 36) toggles QLC+'s audio triggers, which pump the cans'
|
||||
Sound submaster in the Dimmers frame. Every press and release also sends CC 100
|
||||
at full, so switching sound off leaves the cans at full rather than wherever
|
||||
the music left them.
|
||||
|
||||
The Threshold pad (note 37) toggles a second audio trigger, which flashes the
|
||||
cans to full on bass hits. While it is on, CC 100 is held at 0 so the cans sit
|
||||
dark between hits; switching it off puts the submaster back to full.
|
||||
|
||||
The two are exclusive: turning one on taps the other's note first when it is
|
||||
on, so QLC+ switches it off.
|
||||
|
||||
Knob 6 (CC 35) is the sides' peak. It goes on to the Peak submasters, which
|
||||
set how bright the Threshold hits, the chases and the strobe flash. While Sound is on,
|
||||
it also holds both side sliders (knobs 5 and 8, CC 34 and 37) at its value, so
|
||||
the bass pumps the sides up to it; turns of knobs 5 and 8 meanwhile are kept
|
||||
and put back when Sound goes off.
|
||||
|
||||
pump and threshold follow the two pads' presses, so the pad controller can
|
||||
light whichever is on. QLC+ sends no feedback for its audio triggers, so they
|
||||
are only a guess; reopen() clears them, as QLC+ starts with both off.
|
||||
|
||||
colours holds the last colour pad pressed in each set, as sent (52–67 for the
|
||||
cans, 68–83 for the movers), or None once it is pressed again: the colour
|
||||
buttons toggle in a solo frame. QLC+ does not save which buttons are on, so
|
||||
reopen() presses them again when QLC+ loads the show.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -22,20 +43,30 @@ PLAY_CC = 27
|
||||
FIRST_NOTE = 52
|
||||
LAST_NOTE = 67
|
||||
SHIFT = 16
|
||||
CUSTOM_NOTE = 67
|
||||
KNOB_FIRST_CC = 30
|
||||
KNOBS_PER_LAYER = 5
|
||||
PAUSE_CC = 28
|
||||
BANK_1_FIRST = 36
|
||||
BANK_1_LAST = 51
|
||||
MOVERS_SHIFT = 48 # bank 1 goes out as 84–99 while Pause is on, above bank 2's held layer
|
||||
SOUND_NOTE = 36
|
||||
THRESHOLD_NOTE = 37
|
||||
SUBMASTER_CC = 100
|
||||
KNOB_CHANNEL = 0
|
||||
PEAK_CC = 35 # knob 6
|
||||
SIDE_CCS = (34, 37) # knobs 5 and 8: Cans 9–15 and Cans 1, 2, 7, 8
|
||||
|
||||
|
||||
class PlayLayer:
|
||||
def __init__(self, lock_knobs: bool = False) -> None:
|
||||
self.lock_knobs = lock_knobs
|
||||
self.unlocked: set[int] = set() # layers 0 and 1
|
||||
def __init__(self) -> None:
|
||||
self.held = False
|
||||
self.movers = False # Pause toggles bank 1 between the cans and the movers
|
||||
# (channel, note as pressed) -> note sent, so a release matches its press
|
||||
self.sent: dict[tuple[int, int], int] = {}
|
||||
self.pump = False
|
||||
self.threshold = False
|
||||
# Last value of each knob below, from the pad; QLC+ starts them at full.
|
||||
self.knobs = {cc: 127 for cc in (PEAK_CC, *SIDE_CCS)}
|
||||
# set -> (channel, note sent) of the colour that is on
|
||||
self.colours: dict[int, tuple[int, int] | None] = {1: None, 2: None}
|
||||
|
||||
def handle(self, data: list[int]) -> list[list[int]]:
|
||||
"""The messages to send on. Empty when the message is swallowed."""
|
||||
@@ -45,30 +76,80 @@ class PlayLayer:
|
||||
if kind == 0xB0 and len(data) >= 3 and data[1] == PLAY_CC:
|
||||
self.held = data[2] > 0
|
||||
return []
|
||||
if kind == 0xB0 and len(data) >= 3 and self.lock_knobs:
|
||||
index = data[1] - KNOB_FIRST_CC
|
||||
if 0 <= index < 2 * KNOBS_PER_LAYER and index // KNOBS_PER_LAYER not in self.unlocked:
|
||||
return []
|
||||
if kind == 0xB0 and len(data) >= 3 and data[1] == PAUSE_CC:
|
||||
if data[2] > 0:
|
||||
self.movers = not self.movers
|
||||
return []
|
||||
if kind == 0xB0 and len(data) >= 3 and channel == KNOB_CHANNEL and data[1] in self.knobs:
|
||||
self.knobs[data[1]] = data[2]
|
||||
if data[1] == PEAK_CC:
|
||||
return [list(data), *self.sides()]
|
||||
return [] if self.pump else [list(data)]
|
||||
if kind not in (0x80, 0x90) or len(data) < 3:
|
||||
return [list(data)]
|
||||
note = data[1]
|
||||
key = (channel, note)
|
||||
key = (channel, data[1])
|
||||
is_on = kind == 0x90 and data[2] > 0
|
||||
extra: list[list[int]] = []
|
||||
if is_on and FIRST_NOTE <= note <= LAST_NOTE:
|
||||
layer = 1 if self.held else 0
|
||||
if note == CUSTOM_NOTE:
|
||||
self.unlocked.add(layer)
|
||||
elif layer in self.unlocked:
|
||||
self.unlocked.discard(layer)
|
||||
first = KNOB_FIRST_CC + layer * KNOBS_PER_LAYER
|
||||
extra = [[0xB0, first + n, 0] for n in range(KNOBS_PER_LAYER)]
|
||||
if note == SOUND_NOTE:
|
||||
# Again on release, after any spectrum frame QLC+ still had queued
|
||||
extra = [[0xB0, SUBMASTER_CC, 127]]
|
||||
if is_on:
|
||||
out = note + SHIFT if self.held and FIRST_NOTE <= note <= LAST_NOTE else note
|
||||
out = self.shifted(data[1])
|
||||
self.sent[key] = out
|
||||
else:
|
||||
out = self.sent.pop(key, note)
|
||||
return [[status, out, *data[2:]], *extra]
|
||||
out = self.sent.pop(key, data[1])
|
||||
note = out
|
||||
before: list[list[int]] = []
|
||||
extra: list[list[int]] = []
|
||||
if note == SOUND_NOTE:
|
||||
if is_on:
|
||||
if self.threshold:
|
||||
before = tap(channel, THRESHOLD_NOTE)
|
||||
self.threshold = False
|
||||
self.pump = not self.pump
|
||||
extra = self.sides(restore=not self.pump)
|
||||
# Again on release, after any spectrum frame QLC+ still had queued
|
||||
extra = [*extra, [0xB0, SUBMASTER_CC, 127]]
|
||||
elif note == THRESHOLD_NOTE:
|
||||
if is_on:
|
||||
if self.pump:
|
||||
before = tap(channel, SOUND_NOTE)
|
||||
self.pump = False
|
||||
extra = self.sides(restore=True)
|
||||
self.threshold = not self.threshold
|
||||
extra = [*extra, [0xB0, SUBMASTER_CC, 0 if self.threshold else 127]]
|
||||
if is_on and FIRST_NOTE <= out <= LAST_NOTE + SHIFT:
|
||||
colour_set = 1 if out <= LAST_NOTE else 2
|
||||
pressed = (channel, out)
|
||||
self.colours[colour_set] = None if self.colours[colour_set] == pressed else pressed
|
||||
return [*before, [status, out, *data[2:]], *extra]
|
||||
|
||||
def shifted(self, note: int) -> int:
|
||||
"""The note a press goes out as: bank 2 up while Play is held, bank 1 up while Pause is on."""
|
||||
if self.held and FIRST_NOTE <= note <= LAST_NOTE:
|
||||
return note + SHIFT
|
||||
if self.movers and BANK_1_FIRST <= note <= BANK_1_LAST:
|
||||
return note + MOVERS_SHIFT
|
||||
return note
|
||||
|
||||
def reopen(self) -> list[list[int]]:
|
||||
"""QLC+ has loaded the show: everything is off. Press the colours that were on.
|
||||
|
||||
The Sound submaster goes back to full too, as sound is off.
|
||||
"""
|
||||
self.pump = False
|
||||
self.threshold = False
|
||||
out = []
|
||||
for colour in self.colours.values():
|
||||
if colour is not None:
|
||||
out += tap(*colour)
|
||||
return out + [[0xB0, SUBMASTER_CC, 127]]
|
||||
|
||||
def sides(self, restore: bool = False) -> list[list[int]]:
|
||||
"""The side sliders at the peak while Sound is on, or back at their own knobs."""
|
||||
if restore:
|
||||
return [[0xB0 | KNOB_CHANNEL, cc, self.knobs[cc]] for cc in SIDE_CCS]
|
||||
if not self.pump:
|
||||
return []
|
||||
return [[0xB0 | KNOB_CHANNEL, cc, self.knobs[PEAK_CC]] for cc in SIDE_CCS]
|
||||
|
||||
|
||||
def tap(channel: int, note: int) -> list[list[int]]:
|
||||
"""A press and release of note, to toggle a QLC+ button off."""
|
||||
return [[0x90 | channel, note, 127], [0x80 | channel, note, 0]]
|
||||
Reference in new issue
Block a user