Files
qlcplus/tests/test_pad_layer.py
T
jimmyandClaude Opus 5.5 c3fe965e79 Add Circle and Sweep for the movers to the test show.
They fill the movers layer's top row, pads 15 and 16 (notes 98 and 99), in
the Movement solo frame with Wander and Ballyhoo: a circle of about ±45° of
pan and ±21° of tilt, and a straight pan sweep of about ±60°, both mirrored
and relative to the knobs. Knob 13's speed dial gives them a quarter of its
time, 5.5 s a round to start with (scripts/shows/mover_more_efx.py). The pad
controller settles the knobs after them too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 01:47:05 +13:00

228 lines
9.8 KiB
Python

import sys
import unittest
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
from padcontroller.layer import PlayLayer # noqa: E402
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):
def test_notes_pass_through_when_play_is_up(self):
layer = PlayLayer()
self.assertEqual(layer.handle([0x99, 52, 100]), [[0x99, 52, 100]])
def test_play_is_not_passed_on(self):
layer = PlayLayer()
self.assertEqual(layer.handle(PLAY_DOWN), [])
self.assertEqual(layer.handle(PLAY_UP), [])
def test_bank_2_moves_up_while_play_is_held(self):
layer = PlayLayer()
layer.handle(PLAY_DOWN)
self.assertEqual(layer.handle([0x99, 52, 100]), [[0x99, 68, 100]])
self.assertEqual(layer.handle([0x99, 67, 100]), [[0x99, 83, 100]])
layer.handle(PLAY_UP)
self.assertEqual(layer.handle([0x99, 52, 100]), [[0x99, 52, 100]])
def test_other_notes_and_ccs_are_left_alone(self):
layer = PlayLayer()
layer.handle(PLAY_DOWN)
self.assertEqual(layer.handle([0x99, 40, 100]), [[0x99, 40, 100]])
self.assertEqual(layer.handle([0xB0, 30, 64]), [[0xB0, 30, 64]])
def test_release_matches_its_press(self):
layer = PlayLayer()
layer.handle(PLAY_DOWN)
layer.handle([0x99, 55, 100])
layer.handle(PLAY_UP)
self.assertEqual(layer.handle([0x89, 55, 0]), [[0x89, 71, 0]])
layer.handle([0x99, 55, 100])
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):
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]])
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):
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])
layer.handle([0x99, 55, 100])
layer.handle(PLAY_DOWN)
layer.handle([0x99, 61, 100]) # Colour 2 Blue, sent as 77
self.assertEqual(layer.colours, {1: (9, 55), 2: (9, 77)})
def test_pressing_the_lit_colour_again_turns_it_off(self):
layer = PlayLayer()
layer.handle([0x99, 52, 100])
layer.handle([0x89, 52, 0])
layer.handle([0x99, 52, 100])
self.assertEqual(layer.colours[1], None)
def test_reopen_presses_the_colours_again_and_clears_sound(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.colours, {1: (9, 54), 2: (9, 82)}) # still on, for the next reopen
def test_pause_toggles_bank_1_to_the_movers(self):
layer = PlayLayer()
self.assertEqual(layer.handle(PAUSE_DOWN), [])
self.assertEqual(layer.handle(PAUSE_UP), [])
self.assertEqual(layer.handle([0x99, 40, 100]), [[0x99, 88, 100]])
self.assertEqual(layer.handle([0x99, 51, 100]), [[0x99, 99, 100]])
self.assertEqual(layer.handle([0x99, 52, 100]), [[0x99, 52, 100]])
layer.handle(PAUSE_DOWN)
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):
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()
layer.handle(PAUSE_DOWN)
layer.handle([0x99, 48, 100])
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_wander_off_settles_pan_and_tilt(self):
layer = PlayLayer()
self.assertEqual(layer.handle([0xB0, 38, 40]), [[0xB0, 38, 40]])
layer.handle([0xB0, 39, 0])
layer.handle(PAUSE_DOWN)
self.assertEqual(layer.handle([0x99, 48, 100]), [[0x99, 96, 100]])
layer.handle([0x89, 48, 0])
self.assertEqual((layer.moving, layer.settle), (96, False))
layer.handle([0x99, 48, 100])
self.assertEqual((layer.moving, layer.settle), (None, True))
self.assertEqual(layer.nudge(), [[0xB0, 38, 39], [0xB0, 39, 1]])
self.assertEqual(layer.positions(), [[0xB0, 38, 40], [0xB0, 39, 0]])
def test_chase_on_the_cans_layer_is_not_wander(self):
layer = PlayLayer()
layer.handle([0x99, 48, 100])
layer.handle([0x99, 48, 100])
self.assertEqual((layer.moving, layer.settle), (None, False))
def test_ballyhoo_takes_over_from_wander_without_a_settle(self):
layer = PlayLayer()
layer.handle(PAUSE_DOWN)
layer.handle([0x99, 48, 100])
self.assertEqual(layer.handle([0x99, 49, 100]), [[0x99, 97, 100]])
self.assertEqual((layer.moving, layer.settle), (97, False))
layer.handle([0x99, 49, 100])
self.assertEqual((layer.moving, layer.settle), (None, True))
def test_sweep_off_settles(self):
layer = PlayLayer()
layer.handle(PAUSE_DOWN)
self.assertEqual(layer.handle([0x99, 51, 100]), [[0x99, 99, 100]])
self.assertEqual((layer.moving, layer.settle), (99, False))
layer.handle([0x99, 51, 100])
self.assertEqual((layer.moving, layer.settle), (None, True))
if __name__ == "__main__":
unittest.main()