aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--midi_controller_launchpad_mini.py11
-rw-r--r--midi_launchpad_mini_integrationtest.py19
2 files changed, 29 insertions, 1 deletions
diff --git a/midi_controller_launchpad_mini.py b/midi_controller_launchpad_mini.py
index adf18d5..960dd7d 100644
--- a/midi_controller_launchpad_mini.py
+++ b/midi_controller_launchpad_mini.py
@@ -11,14 +11,18 @@ class MidiController:
self._midiWrapper = MidiWrapper()
self._handlers = {
+ 96 : self._soloTool.stop,
112 : self._playPause,
- 96 : self._soloTool.stop,
101 : self._soloTool.jumpToA,
102 : self._soloTool.previousStoredAbLimits,
103 : self._soloTool.nextStoredAbLimits,
118 : self._soloTool.previousSong,
119 : self._soloTool.nextSong
}
+
+ for i in range(16, 24):
+ rate = round(0.5 + (i - 16) * 0.1, 1)
+ self._handlers[i] = self._createSetPlaybackRateCallback(rate)
def connect(self):
self._midiWrapper.connect(MidiController.DEVICE_NAME)
@@ -37,3 +41,8 @@ class MidiController:
else:
self._soloTool.play()
+ def _createSetPlaybackRateCallback(self, rate):
+ def f():
+ self._soloTool.setPlaybackRate(rate)
+ return f
+
diff --git a/midi_launchpad_mini_integrationtest.py b/midi_launchpad_mini_integrationtest.py
index 8779503..ee39182 100644
--- a/midi_launchpad_mini_integrationtest.py
+++ b/midi_launchpad_mini_integrationtest.py
@@ -149,6 +149,24 @@ def test_previousAndNextAbButtons(uut, midiWrapperMock, soloTool, playerMock):
midiWrapperMock.simulateInput(previousLimitButton)
checkLimit(abLimits[0][0], abLimits[0][1])
+def test_playbackRateButtons(uut, midiWrapperMock, soloTool, playerMock):
+ playbackRateOptions = {
+ 16 : 0.5,
+ 17 : 0.6,
+ 18 : 0.7,
+ 19 : 0.8,
+ 20 : 0.9,
+ 21 : 1.0,
+ 22 : 1.1,
+ 23 : 1.2
+ }
+ uut.connect()
+ assert playerMock.rate == 1.0
+
+ for button in playbackRateOptions:
+ midiWrapperMock.simulateInput(button)
+ assert playerMock.rate == playbackRateOptions[button]
+
def test_unassignedButton(uut, midiWrapperMock):
unassignedButton = 48
uut.connect()
@@ -156,3 +174,4 @@ def test_unassignedButton(uut, midiWrapperMock):
# expect no crash
midiWrapperMock.simulateInput(unassignedButton)
# XXX would be better to assert that nothing changed in the solo tool
+