Files
qlcplus/tests/test_pad_layer.py
T
jimmyandClaude Opus 5.5 913494c0aa Add a Ballyhoo pad for the movers to the test show.
Pad 11 on the movers layer (note 94) toggles a fast figure of eight around
the Pan and Tilt knobs, like Wander: about ±85° of pan and ±26° of tilt, all
four movers together so the pairs mirror left to right and front to back
(scripts/shows/mover_ballyhoo.py).

The pad controller now settles the knobs after Ballyhoo goes off as well as
Wander, and keeps track of each separately.

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

220 lines
9.5 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, 45, 100]), [[0x99, 93, 100]])
layer.handle([0x89, 45, 0])
self.assertEqual((layer.moving, layer.settle), ({93}, False))
layer.handle([0x99, 45, 100])
self.assertEqual((layer.moving, layer.settle), (set(), True))
self.assertEqual(layer.nudge(), [[0xB0, 38, 39], [0xB0, 39, 1]])
self.assertEqual(layer.positions(), [[0xB0, 38, 40], [0xB0, 39, 0]])
def test_strobe_2_on_the_cans_layer_is_not_wander(self):
layer = PlayLayer()
layer.handle([0x99, 45, 100])
layer.handle([0x99, 45, 100])
self.assertEqual((layer.moving, layer.settle), (set(), False))
def test_ballyhoo_off_settles_while_wander_runs_on(self):
layer = PlayLayer()
layer.handle(PAUSE_DOWN)
layer.handle([0x99, 45, 100])
self.assertEqual(layer.handle([0x99, 46, 100]), [[0x99, 94, 100]])
self.assertEqual((layer.moving, layer.settle), ({93, 94}, False))
layer.handle([0x99, 46, 100])
self.assertEqual((layer.moving, layer.settle), ({93}, True))
if __name__ == "__main__":
unittest.main()