Files
qlcplus/tests/test_pad_layer.py
T
jimmyandClaude Opus 5.5 d522b1a2cf Add sound-reactive cans, a strobe pad and side chases to the test show.
The Sound pad (bank 1 note 36) toggles a QLC+ Audio Triggers widget whose
volume bar drives a Sound submaster beside the can dimmers, so the cans'
brightness follows the music while the movers stay steady. padcontroller sends
CC 100 at full on every press and release of that pad, bypassing its CC
smoothing, so switching sound off always leaves the cans at full.

test.qxw also gains Chase forward/reverse, a double and an opposing zigzag
down the side cans (RGB matrices whose colour follows the Colour 2 pads), a
Strobe flash pad with the cans' strobe channel forced HTP, and the Dimmers
frame, forced-LTP side colours and dimmer-free colour scenes from parallel
sessions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 17:03:27 +13:00

90 lines
3.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]
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], [0xB0, 100, 127]])
self.assertEqual(layer.handle([0x89, 36, 0]), [[0x89, 36, 0], [0xB0, 100, 127]])
self.assertEqual(layer.handle([0x99, 37, 100]), [[0x99, 37, 100]])
if __name__ == "__main__":
unittest.main()
class LockedKnobsTest(unittest.TestCase):
def test_knobs_are_dropped_until_custom_is_pressed(self):
layer = PlayLayer(lock_knobs=True)
self.assertEqual(layer.handle([0xB0, 31, 64]), [])
layer.handle([0x99, 67, 100])
self.assertEqual(layer.handle([0xB0, 31, 64]), [[0xB0, 31, 64]])
self.assertEqual(layer.handle([0xB0, 36, 64]), [])
def test_another_pad_locks_them_again(self):
layer = PlayLayer(lock_knobs=True)
layer.handle([0x99, 67, 100])
layer.handle([0x99, 60, 100])
self.assertEqual(layer.handle([0xB0, 31, 64]), [])
def test_locking_sends_the_sliders_back_to_zero(self):
layer = PlayLayer(lock_knobs=True)
layer.handle([0x99, 67, 100])
sent = layer.handle([0x99, 60, 100])
self.assertEqual(sent[0], [0x99, 60, 100])
self.assertEqual(sent[1:], [[0xB0, 30 + n, 0] for n in range(5)])
self.assertEqual(layer.handle([0x99, 61, 100]), [[0x99, 61, 100]])
def test_play_layer_unlocks_the_second_set(self):
layer = PlayLayer(lock_knobs=True)
layer.handle(PLAY_DOWN)
layer.handle([0x99, 67, 100])
self.assertEqual(layer.handle([0xB0, 36, 64]), [[0xB0, 36, 64]])
self.assertEqual(layer.handle([0xB0, 31, 64]), [])
def test_other_knobs_and_unlocked_mode_are_untouched(self):
self.assertEqual(PlayLayer(lock_knobs=True).handle([0xB0, 40, 64]), [[0xB0, 40, 64]])
self.assertEqual(PlayLayer().handle([0xB0, 31, 64]), [[0xB0, 31, 64]])