Remove the sound-reactive cans from the test show.

The Sound and Threshold audio triggers go, with the Sound submaster beside the
cans' Front and Back sliders (CC 100) and the Sound peak frame with its Peak
submaster and Hit button and the Cans hit functions only Hit ran. Pads 1 and 2
are plain spare buttons again (scripts/shows/drop_sound.py). The pads frame's
own Peak (knob 6) stays: it is the chases' peak.

The pad controller drops its side of it: the Pump and Threshold modes, the
CC 100 resets, holding the side knobs at the peak and the pad lamps that showed
which mode was on. Pads 1 and 2 and knobs 5, 6 and 8 pass straight through.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jimmyandClaude Opus 5.5 committed 2026-10-23 13:57:00 +13:00
1 parent 3b38df3dd0
commit e7e1cf656b
6 files changed
+92 -349

No files matched your search

+6 -76
View File
@@ -6,30 +6,7 @@ second set of buttons from the first. Play itself is not passed on.
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.
84–99, for the movers. Pause itself is not passed on.
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
@@ -43,7 +20,7 @@ QLC+ 4.12 leaves an EFX's last offset on the movers when it stops, until those
sliders change, so when the one that is on goes off, settle asks for the two
knobs one step off and then back (nudge() and positions()). Swapping needs
none: the new EFX writes over the old one's offset. moving holds the note whose
EFX is on, from the presses: a guess like pump.
EFX is on, from the presses: only a guess, as QLC+ sends no feedback for it.
"""
from __future__ import annotations
@@ -56,12 +33,7 @@ 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
# Wander, Ballyhoo, Circle, Sweep; Diamond, Square, Corners, Leaf; Tilt: pads 13–16, 9–12, 5
RELATIVE_NOTES = (96, 97, 98, 99, 92, 93, 94, 95, 88)
POSITION_CCS = (38, 39) # knobs 9 and 10: the movers' Pan and Tilt
@@ -73,10 +45,6 @@ class PlayLayer:
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)}
# Pan and Tilt as last sent; QLC+ starts them at 0.
self.position = {cc: 0 for cc in POSITION_CCS}
self.moving: int | None = None
@@ -96,11 +64,6 @@ class PlayLayer:
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 == 0xB0 and len(data) >= 3 and channel == KNOB_CHANNEL and data[1] in self.position:
self.position[data[1]] = data[2]
return [list(data)]
@@ -114,26 +77,7 @@ class PlayLayer:
else:
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]]
elif note in RELATIVE_NOTES and is_on:
if note in RELATIVE_NOTES and is_on:
if note == self.moving:
self.moving = None
self.settle = True
@@ -143,7 +87,7 @@ class PlayLayer:
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]
return [[status, out, *data[2:]]]
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."""
@@ -154,27 +98,13 @@ class PlayLayer:
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
"""QLC+ has loaded the show: everything is off. Press the colours that were on."""
self.moving = None
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]
return out
def nudge(self) -> list[list[int]]:
"""Pan and Tilt one step off their knobs, so QLC+ writes them again."""
+4 -39
View File
@@ -6,7 +6,6 @@ immediately, and eases Control Change values toward their targets at
On start it also sets the pad lamps over USB (scripts/pad/pad_lamps.py): bank 1 off and
bank 2 in the colours from shows/test.qxw. On Bluetooth it says so and carries on.
While it runs, the Pump and Threshold pads (notes 36 and 37) light while their mode is on.
While Play is held, bank 2 notes 52–67 go out as 68–83 (see padcontroller/layer.py).
Point QLC+ MIDI input at that virtual port (midi.qxw does this via
@@ -39,7 +38,6 @@ import os
import re
import subprocess
import sys
import threading
import time
from dataclasses import dataclass, field
from pathlib import Path
@@ -52,11 +50,11 @@ for p in glob.glob(str(ROOT / ".venv" / "lib" / "python*" / "site-packages")):
sys.path.insert(0, p)
import rtmidi
from padcontroller.layer import SUBMASTER_CC, PlayLayer # noqa: E402
from padcontroller.layer import PlayLayer # noqa: E402
# The lamp colours come from the show scripts, which are not part of this package.
sys.path.insert(0, str(ROOT / "scripts" / "pad"))
from pad_lamps import set_lamps, set_sound_lamps # noqa: E402
from pad_lamps import set_lamps # noqa: E402
VIRTUAL_NAME = "padcontroller"
COLOURS_FILE = Path(os.environ.get("XDG_STATE_HOME", Path.home() / ".local" / "state")) / "padcontroller" / "colours.json"
@@ -172,33 +170,6 @@ def save_colours(layer: PlayLayer) -> None:
print(f"Colours not saved: {exc}", flush=True)
class SoundLamps:
"""Show which sound pad is on, off the MIDI loop: each write takes ~60 ms."""
def __init__(self) -> None:
self.wanted: tuple[bool, bool] | None = None
self.wake = threading.Event()
threading.Thread(target=self._run, daemon=True).start()
def show(self, pump: bool, threshold: bool) -> None:
self.wanted = (pump, threshold)
self.wake.set()
def _run(self) -> None:
shown = None
while True:
self.wake.wait()
self.wake.clear()
wanted = self.wanted
if wanted is None or wanted == shown:
continue
try:
set_sound_lamps(*wanted)
shown = wanted
except (SystemExit, Exception) as exc: # no Private port on Bluetooth
print(f"Sound lamps not set: {exc}", flush=True)
def main() -> None:
ap = argparse.ArgumentParser(description=__doc__)
ap.add_argument(
@@ -237,10 +208,8 @@ def main() -> None:
print(f"Virtual: {VIRTUAL_NAME} (tau={args.tau}s @ {args.rate} Hz)", flush=True)
print("Pass notes through (Play held shifts bank 2 up 16); smooth CC. Ctrl+C to stop.", flush=True)
ensure_links(src_name)
sound_lamps = None
if not args.no_lamps:
set_lamps()
sound_lamps = SoundLamps()
dt = 1.0 / args.rate
alpha = 1.0 - math.exp(-dt / max(args.tau, 1e-4))
@@ -272,8 +241,6 @@ def main() -> None:
for out in taps:
midiout.send_message(out)
print(f"QLC+ reopened: pressed {sum(out[0] & 0xF0 == 0x90 for out in taps)} colour pad(s) again", flush=True)
if sound_lamps:
sound_lamps.show(layer.pump, layer.threshold)
# Drain inbound
while True:
@@ -285,7 +252,7 @@ def main() -> None:
continue
for out in layer.handle(list(data)):
cmd = out[0] & 0xF0
if cmd == 0xB0 and len(out) >= 3 and out[1] != SUBMASTER_CC:
if cmd == 0xB0 and len(out) >= 3:
# Control Change → smooth
key = (out[0] & 0x0F, out[1])
target[key] = float(out[2])
@@ -293,10 +260,8 @@ def main() -> None:
current[key] = float(out[2])
last_sent[key] = -1
else:
# Notes, aftertouch, PC, the Sound reset (always resent), etc. → immediate
# Notes, aftertouch, PC, etc. → immediate
midiout.send_message(out)
if sound_lamps:
sound_lamps.show(layer.pump, layer.threshold)
if layer.settle:
layer.settle = False
later += [(now + SETTLE_DELAY, layer.nudge), (now + 2 * SETTLE_DELAY, layer.positions)]
-39
View File
@@ -28,44 +28,5 @@ def set_lamps() -> None:
print(f"Lamps not set: {exc}", flush=True)
# Bank 1 pads 1 and 2 (notes 36 and 37), lit while their sound mode is on.
PUMP_RGB = (0, 255, 0)
THRESHOLD_RGB = (255, 120, 0)
def set_sound_lamps(pump: bool, threshold: bool) -> None:
"""Light the Pump and Threshold pads while their mode is on, without saving.
Writes only the pad's running copy, so the stored preset (bank 1 off) comes
back on a power cycle. Needs the USB Private port; raises when it is missing.
"""
sys.path.insert(0, str(ROOT))
sys.path.insert(0, str(ROOT / "scripts" / "pad"))
import pad_colours
import rtmidi
from padcontroller.device import transact
from padcontroller.preset import scale
from padcontroller.sysex import RAM, write_request
lamps = {0: PUMP_RGB if pump else (0, 0, 0), 1: THRESHOLD_RGB if threshold else (0, 0, 0)}
midiout = rtmidi.MidiOut(rtapi=rtmidi.API_LINUX_ALSA)
midiin = rtmidi.MidiIn(rtapi=rtmidi.API_LINUX_ALSA)
try:
# Free both clients when the Private port is missing too, or every
# sound pad press on Bluetooth leaks two and fills the sequencer.
index = midiout.get_ports().index(pad_colours.private_port(midiout.get_ports()))
midiin.open_port(index)
midiin.ignore_types(sysex=False, timing=True, active_sense=True)
midiout.open_port(index)
for base in pad_colours.bank_bases(1):
for pad, rgb in lamps.items():
address = RAM + base + pad * pad_colours.RECORD + pad_colours.RGB_AT
transact(midiout, midiin, write_request(address, bytes(scale(c) for c in rgb)))
finally:
for port in (midiout, midiin):
port.close_port()
port.delete()
if __name__ == "__main__":
set_lamps()
+68
View File
@@ -0,0 +1,68 @@
#!/usr/bin/env python3
"""Take the sound-reactive cans out of shows/test.qxw.
Removes the Sound and Threshold audio triggers, the Sound submaster beside the
cans' Front and Back sliders (CC 100), and the Sound peak frame with its Peak
submaster and Hit button, with the Cans hit scene and chaser that only Hit ran.
The Pump and Threshold buttons on pads 1 and 2 (notes 36 and 37) were empty;
they go back to plain spare buttons like the rest of that row. The pads frame's
own Peak (CC 35) stays: it is the chases' peak.
padcontroller/layer.py drops its side of it in the same change: the two pads'
modes, the CC 100 resets and the pad lamps that showed which was on.
python3 scripts/shows/drop_sound.py
Run it once; it stops if the audio triggers are already gone. QLC+ has to
reopen the show to see it.
"""
from __future__ import annotations
import re
from mover_bank import ROOT
SHOW = ROOT / "shows" / "test.qxw"
SOUND_SLIDER_W = 55 # the Sound slider and the gap before it in the Cans frame
def cut(xml: str, pattern: str, what: str) -> str:
xml, n = re.subn(pattern, "", xml, count=1, flags=re.S)
if n != 1:
raise SystemExit(f"Couldn't find {what}")
return xml
def main() -> None:
xml = SHOW.read_text()
if "<AudioTriggers" not in xml:
raise SystemExit(f"{SHOW.relative_to(ROOT)} has no sound triggers left")
for caption in ("Sound", "Threshold"):
xml = cut(xml, rf' <AudioTriggers BarsNumber="\d+" Caption="{caption}" ID="\d+">\n.*? </AudioTriggers>\n',
f"the {caption} audio trigger")
xml = cut(xml, r' <Slider Caption="Sound" ID="66" .*? </Slider>\n', "the Sound submaster")
xml = cut(xml, r' <Frame Caption="Sound peak" ID="76">\n.*? </Frame>\n', "the Sound peak frame")
for fid, name in ((55, "Cans hit"), (56, "Cans hit 100 ms")):
xml = cut(xml, rf' <Function ID="{fid}" Type="\w+" Name="{name}">\n.*? </Function>\n', name)
# The Dimmers frame and its Cans frame lose the Sound slider's width.
for caption, wid, x, y, w, h in (("Dimmers", 68, 880, 15, 264, 250), ("Cans", 73, 70, 40, 165, 205)):
old = f'<WindowState Visible="True" X="{x}" Y="{y}" Width="{w}" Height="{h}"/>'
frame = re.search(rf'<Frame Caption="{caption}" ID="{wid}">\n(?:.*\n){{0,8}}?\s*{re.escape(old)}', xml)
if frame is None:
raise SystemExit(f"Couldn't find the {caption} frame at {w} wide")
xml = xml.replace(frame.group(0), frame.group(0).replace(f'Width="{w}"', f'Width="{w - SOUND_SLIDER_W}"'), 1)
for caption, wid in (("Pump", 57), ("Threshold", 58)):
old = f'<Button Caption="{caption}" ID="{wid}" Icon="">'
if old not in xml:
raise SystemExit(f"Couldn't find the {caption} button")
xml = xml.replace(old, f'<Button Caption="Button {wid}" ID="{wid}" Icon="">', 1)
SHOW.write_text(xml)
print(f"Took the sound pieces out of {SHOW.relative_to(ROOT)}")
if __name__ == "__main__":
main()
+4 -110
View File
@@ -819,27 +819,6 @@
<FixtureVal ID="15">0,255,1,230</FixtureVal>
<FixtureVal ID="16">0,255,1,230</FixtureVal>
</Function>
<Function ID="55" Type="Scene" Name="Cans hit">
<Speed FadeIn="0" FadeOut="0" Duration="0"/>
<FixtureVal ID="0">0,255</FixtureVal>
<FixtureVal ID="1">0,255</FixtureVal>
<FixtureVal ID="6">0,255</FixtureVal>
<FixtureVal ID="7">0,255</FixtureVal>
<FixtureVal ID="10">0,255</FixtureVal>
<FixtureVal ID="11">0,255</FixtureVal>
<FixtureVal ID="12">0,255</FixtureVal>
<FixtureVal ID="13">0,255</FixtureVal>
<FixtureVal ID="14">0,255</FixtureVal>
<FixtureVal ID="15">0,255</FixtureVal>
<FixtureVal ID="16">0,255</FixtureVal>
</Function>
<Function ID="56" Type="Chaser" Name="Cans hit 100 ms">
<Speed FadeIn="0" FadeOut="0" Duration="100"/>
<Direction>Forward</Direction>
<RunOrder>SingleShot</RunOrder>
<SpeedModes FadeIn="Common" FadeOut="Common" Duration="Common"/>
<Step Number="0" FadeIn="0" Hold="0" FadeOut="0">55</Step>
</Function>
<Function ID="67" Type="Scene" Name="Cans strobe 2">
<Speed FadeIn="0" FadeOut="50" Duration="0"/>
<FixtureVal ID="0">0,255,1,230,5,0</FixtureVal>
@@ -1993,7 +1972,7 @@
<Action>Toggle</Action>
<Intensity Adjust="False">100</Intensity>
</Button>
<Button Caption="Pump" ID="57" Icon="">
<Button Caption="Button 57" ID="57" Icon="">
<WindowState Visible="True" X="10" Y="280" Width="90" Height="90"/>
<Appearance>
<FrameStyle>None</FrameStyle>
@@ -2006,7 +1985,7 @@
<Action>Toggle</Action>
<Intensity Adjust="False">100</Intensity>
</Button>
<Button Caption="Threshold" ID="58" Icon="">
<Button Caption="Button 58" ID="58" Icon="">
<WindowState Visible="True" X="100" Y="280" Width="90" Height="90"/>
<Appearance>
<FrameStyle>None</FrameStyle>
@@ -2070,7 +2049,7 @@
<BackgroundImage>None</BackgroundImage>
<Font>Default</Font>
</Appearance>
<WindowState Visible="True" X="880" Y="15" Width="264" Height="250"/>
<WindowState Visible="True" X="880" Y="15" Width="209" Height="250"/>
<AllowChildren>True</AllowChildren>
<AllowResize>True</AllowResize>
<ShowHeader>True</ShowHeader>
@@ -2106,7 +2085,7 @@
<BackgroundImage>None</BackgroundImage>
<Font>Default</Font>
</Appearance>
<WindowState Visible="True" X="70" Y="40" Width="165" Height="205"/>
<WindowState Visible="True" X="70" Y="40" Width="110" Height="205"/>
<AllowChildren>True</AllowChildren>
<AllowResize>True</AllowResize>
<ShowHeader>False</ShowHeader>
@@ -2158,69 +2137,8 @@
<Function>4294967295</Function>
</Playback>
</Slider>
<Slider Caption="Sound" ID="66" WidgetStyle="Slider" InvertedAppearance="false">
<WindowState Visible="True" X="110" Y="0" Width="52" Height="200"/>
<Appearance>
<FrameStyle>Sunken</FrameStyle>
<ForegroundColor>Default</ForegroundColor>
<BackgroundColor>Default</BackgroundColor>
<BackgroundImage>None</BackgroundImage>
<Font>Default</Font>
</Appearance>
<Input Universe="1" Channel="100"/>
<SliderMode ValueDisplayStyle="Exact" ClickAndGoType="None">Submaster</SliderMode>
<Level LowLimit="0" HighLimit="255" Value="227"/>
<Playback>
<Function>4294967295</Function>
</Playback>
</Slider>
</Frame>
</Frame>
<Frame Caption="Sound peak" ID="76">
<Appearance>
<FrameStyle>Sunken</FrameStyle>
<ForegroundColor>Default</ForegroundColor>
<BackgroundColor>Default</BackgroundColor>
<BackgroundImage>None</BackgroundImage>
<Font>Default</Font>
</Appearance>
<WindowState Visible="True" X="1160" Y="15" Width="72" Height="250"/>
<AllowChildren>True</AllowChildren>
<AllowResize>True</AllowResize>
<ShowHeader>True</ShowHeader>
<ShowEnableButton>False</ShowEnableButton>
<Collapsed>False</Collapsed>
<Disabled>False</Disabled>
<Slider Caption="Peak" ID="77" WidgetStyle="Slider" InvertedAppearance="false">
<WindowState Visible="True" X="10" Y="45" Width="52" Height="200"/>
<Appearance>
<FrameStyle>Sunken</FrameStyle>
<ForegroundColor>Default</ForegroundColor>
<BackgroundColor>Default</BackgroundColor>
<BackgroundImage>None</BackgroundImage>
<Font>Default</Font>
</Appearance>
<Input Universe="1" Channel="35"/>
<SliderMode ValueDisplayStyle="Exact" ClickAndGoType="None">Submaster</SliderMode>
<Level LowLimit="0" HighLimit="255" Value="50"/>
<Playback>
<Function>4294967295</Function>
</Playback>
</Slider>
<Button Caption="Hit" ID="78" Icon="">
<WindowState Visible="True" X="200" Y="10" Width="60" Height="60"/>
<Appearance>
<FrameStyle>None</FrameStyle>
<ForegroundColor>Default</ForegroundColor>
<BackgroundColor>Default</BackgroundColor>
<BackgroundImage>None</BackgroundImage>
<Font>Default</Font>
</Appearance>
<Function ID="56"/>
<Action>Toggle</Action>
<Intensity Adjust="False">100</Intensity>
</Button>
</Frame>
<Frame Caption="Chase runs" ID="83">
<Appearance>
<FrameStyle>Sunken</FrameStyle>
@@ -2785,30 +2703,6 @@
</Playback>
</Slider>
</Frame>
<AudioTriggers BarsNumber="16" Caption="Sound" ID="67">
<WindowState Visible="True" X="1285" Y="0" Width="400" Height="380"/>
<Appearance>
<FrameStyle>Sunken</FrameStyle>
<ForegroundColor>Default</ForegroundColor>
<BackgroundColor>Default</BackgroundColor>
<BackgroundImage>None</BackgroundImage>
<Font>Default</Font>
</Appearance>
<Input Universe="1" Channel="37028"/>
<SpectrumBar Name="Bass" Type="3" MinThreshold="0" MaxThreshold="255" Divisor="1" Index="0" WidgetID="66"/>
</AudioTriggers>
<AudioTriggers BarsNumber="16" Caption="Threshold" ID="75">
<WindowState Visible="True" X="1285" Y="385" Width="400" Height="380"/>
<Appearance>
<FrameStyle>Sunken</FrameStyle>
<ForegroundColor>Default</ForegroundColor>
<BackgroundColor>Default</BackgroundColor>
<BackgroundImage>None</BackgroundImage>
<Font>Default</Font>
</Appearance>
<Input Universe="1" Channel="37029"/>
<SpectrumBar Name="Bass" Type="3" MinThreshold="100" MaxThreshold="110" Divisor="1" Index="0" WidgetID="78"/>
</AudioTriggers>
<Frame Caption="Movers pads" ID="84">
<Appearance>
<FrameStyle>Sunken</FrameStyle>
+10 -85
View File
@@ -10,7 +10,6 @@ PLAY_DOWN = [0xB0, 27, 127]
PLAY_UP = [0xB0, 27, 0]
PAUSE_DOWN = [0xB0, 28, 127]
PAUSE_UP = [0xB0, 28, 0]
SIDES_FULL = [[0xB0, 34, 127], [0xB0, 37, 127]]
class PlayLayerTest(unittest.TestCase):
@@ -47,88 +46,18 @@ class PlayLayerTest(unittest.TestCase):
layer.handle(PLAY_DOWN)
self.assertEqual(layer.handle([0x99, 55, 0]), [[0x99, 55, 0]])
def test_sound_pad_puts_the_submaster_back_to_full(self):
def test_pads_1_and_2_pass_straight_through(self):
layer = PlayLayer()
self.assertEqual(layer.handle([0x99, 36, 100]), [[0x99, 36, 100], *SIDES_FULL, [0xB0, 100, 127]])
self.assertEqual(layer.handle([0x89, 36, 0]), [[0x89, 36, 0], [0xB0, 100, 127]])
self.assertEqual(layer.handle([0x99, 36, 100]), [[0x99, 36, 100]])
self.assertEqual(layer.handle([0x89, 36, 0]), [[0x89, 36, 0]])
self.assertEqual(layer.handle([0x99, 37, 100]), [[0x99, 37, 100]])
def test_threshold_pad_holds_the_submaster_at_zero_while_on(self):
layer = PlayLayer()
self.assertEqual(layer.handle([0x99, 37, 100]), [[0x99, 37, 100], [0xB0, 100, 0]])
self.assertEqual(layer.handle([0x89, 37, 0]), [[0x89, 37, 0], [0xB0, 100, 0]])
self.assertEqual(layer.handle([0x99, 37, 100]), [[0x99, 37, 100], [0xB0, 100, 127]])
self.assertEqual(layer.handle([0x89, 37, 0]), [[0x89, 37, 0], [0xB0, 100, 127]])
def test_sound_pads_track_which_mode_is_on(self):
layer = PlayLayer()
layer.handle([0x99, 36, 100])
layer.handle([0x89, 36, 0])
self.assertEqual((layer.pump, layer.threshold), (True, False))
layer.handle([0x99, 36, 100])
layer.handle([0x99, 36, 0]) # note on at velocity 0 is a release
self.assertEqual((layer.pump, layer.threshold), (False, False))
def test_turning_threshold_on_switches_pump_off_first(self):
layer = PlayLayer()
layer.handle([0x99, 36, 100])
self.assertEqual(
layer.handle([0x99, 37, 100]),
[[0x99, 36, 127], [0x89, 36, 0], [0x99, 37, 100], *SIDES_FULL, [0xB0, 100, 0]],
)
self.assertEqual((layer.pump, layer.threshold), (False, True))
def test_turning_pump_on_switches_threshold_off_first(self):
layer = PlayLayer()
layer.handle([0x99, 37, 100])
self.assertEqual(
layer.handle([0x99, 36, 100]),
[[0x99, 37, 127], [0x89, 37, 0], [0x99, 36, 100], *SIDES_FULL, [0xB0, 100, 127]],
)
self.assertEqual((layer.pump, layer.threshold), (True, False))
def test_turning_a_mode_off_leaves_the_other_alone(self):
layer = PlayLayer()
layer.handle([0x99, 37, 100])
self.assertEqual(layer.handle([0x99, 37, 100]), [[0x99, 37, 100], [0xB0, 100, 127]])
self.assertEqual((layer.pump, layer.threshold), (False, False))
def test_peak_knob_goes_on_to_the_hits_submaster(self):
def test_peak_and_side_knobs_pass_straight_through(self):
layer = PlayLayer()
self.assertEqual(layer.handle([0xB0, 35, 60]), [[0xB0, 35, 60]])
def test_side_knobs_pass_through_while_sound_is_off(self):
layer = PlayLayer()
self.assertEqual(layer.handle([0xB0, 34, 90]), [[0xB0, 34, 90]])
layer.handle([0x99, 37, 100]) # Threshold keeps them: the submaster holds the sides dark
self.assertEqual(layer.handle([0xB0, 37, 80]), [[0xB0, 37, 80]])
def test_pump_holds_the_sides_at_the_peak(self):
layer = PlayLayer()
layer.handle([0xB0, 34, 90])
layer.handle([0xB0, 35, 60])
self.assertEqual(layer.handle([0x99, 36, 100]),
[[0x99, 36, 100], [0xB0, 34, 60], [0xB0, 37, 60], [0xB0, 100, 127]])
self.assertEqual(layer.handle([0xB0, 35, 40]), [[0xB0, 35, 40], [0xB0, 34, 40], [0xB0, 37, 40]])
self.assertEqual(layer.handle([0xB0, 37, 100]), []) # kept for later
def test_pump_off_puts_the_side_knobs_back(self):
layer = PlayLayer()
layer.handle([0xB0, 34, 90])
layer.handle([0xB0, 35, 60])
layer.handle([0x99, 36, 100])
layer.handle([0xB0, 37, 100])
self.assertEqual(layer.handle([0x99, 36, 100]),
[[0x99, 36, 100], [0xB0, 34, 90], [0xB0, 37, 100], [0xB0, 100, 127]])
def test_threshold_taking_over_from_pump_puts_the_side_knobs_back(self):
layer = PlayLayer()
layer.handle([0xB0, 34, 90])
layer.handle([0xB0, 35, 60])
layer.handle([0x99, 36, 100])
self.assertEqual(layer.handle([0x99, 37, 100]),
[[0x99, 36, 127], [0x89, 36, 0], [0x99, 37, 100],
[0xB0, 34, 90], [0xB0, 37, 127], [0xB0, 100, 0]])
def test_colours_remember_the_last_pad_in_each_set(self):
layer = PlayLayer()
layer.handle([0x99, 52, 100])
@@ -144,16 +73,13 @@ class PlayLayerTest(unittest.TestCase):
layer.handle([0x99, 52, 100])
self.assertEqual(layer.colours[1], None)
def test_reopen_presses_the_colours_again_and_clears_sound(self):
def test_reopen_presses_the_colours_again(self):
layer = PlayLayer()
layer.handle([0x99, 54, 100])
layer.handle(PLAY_DOWN)
layer.handle([0x99, 66, 100])
layer.handle(PLAY_UP)
layer.handle([0x99, 36, 100])
self.assertEqual(layer.reopen(), [[0x99, 54, 127], [0x89, 54, 0], [0x99, 82, 127], [0x89, 82, 0],
[0xB0, 100, 127]])
self.assertEqual((layer.pump, layer.threshold), (False, False))
self.assertEqual(layer.reopen(), [[0x99, 54, 127], [0x89, 54, 0], [0x99, 82, 127], [0x89, 82, 0]])
self.assertEqual(layer.colours, {1: (9, 54), 2: (9, 82)}) # still on, for the next reopen
def test_pause_toggles_bank_1_to_the_movers(self):
@@ -167,14 +93,13 @@ class PlayLayerTest(unittest.TestCase):
layer.handle(PAUSE_UP)
self.assertEqual(layer.handle([0x99, 44, 100]), [[0x99, 44, 100]])
def test_sound_pads_do_nothing_on_the_movers_layer(self):
def test_pads_1_and_2_move_up_on_the_movers_layer(self):
layer = PlayLayer()
layer.handle(PAUSE_DOWN)
self.assertEqual(layer.handle([0x99, 36, 100]), [[0x99, 84, 100]])
self.assertEqual(layer.handle([0x89, 36, 0]), [[0x89, 84, 0]])
self.assertEqual(layer.handle([0x99, 37, 100]), [[0x99, 85, 100]])
self.assertEqual(layer.handle([0x89, 37, 0]), [[0x89, 85, 0]])
self.assertEqual((layer.pump, layer.threshold), (False, False))
def test_bank_1_release_matches_its_press_across_pause(self):
layer = PlayLayer()
@@ -183,8 +108,8 @@ class PlayLayerTest(unittest.TestCase):
layer.handle(PAUSE_DOWN)
self.assertEqual(layer.handle([0x89, 48, 0]), [[0x89, 96, 0]])
def test_reopen_with_no_colours_only_resets_the_submaster(self):
self.assertEqual(PlayLayer().reopen(), [[0xB0, 100, 127]])
def test_reopen_with_no_colours_sends_nothing(self):
self.assertEqual(PlayLayer().reopen(), [])
def test_wander_off_settles_pan_and_tilt(self):
layer = PlayLayer()