aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEddy Pedroni <eddy@0xf7.com>2022-01-01 21:02:19 +0100
committerEddy Pedroni <eddy@0xf7.com>2022-01-01 21:02:19 +0100
commit406e06ecfa0391cc3138a33bee0e5e45cb06f6c5 (patch)
tree485367728310e8b82f05f5deac28e4e31226f510
parent27ba3bc396a2da4ffcc39e3e36da5f37df8f628e (diff)
Added playback volume functionality to launchpad
-rw-r--r--midi_controller_launchpad_mini.py8
-rw-r--r--midi_launchpad_mini_integrationtest.py18
2 files changed, 26 insertions, 0 deletions
diff --git a/midi_controller_launchpad_mini.py b/midi_controller_launchpad_mini.py
index 960dd7d..bc2ed8a 100644
--- a/midi_controller_launchpad_mini.py
+++ b/midi_controller_launchpad_mini.py
@@ -20,6 +20,10 @@ class MidiController:
119 : self._soloTool.nextSong
}
+ for i in range(0, 8):
+ volume = round(0.125 + i * 0.125, 3)
+ self._handlers[i] = self._createSetPlaybackVolumeCallback(volume)
+
for i in range(16, 24):
rate = round(0.5 + (i - 16) * 0.1, 1)
self._handlers[i] = self._createSetPlaybackRateCallback(rate)
@@ -46,3 +50,7 @@ class MidiController:
self._soloTool.setPlaybackRate(rate)
return f
+ def _createSetPlaybackVolumeCallback(self, volume):
+ def f():
+ self._soloTool.setPlaybackVolume(volume)
+ return f
diff --git a/midi_launchpad_mini_integrationtest.py b/midi_launchpad_mini_integrationtest.py
index ee39182..275bd33 100644
--- a/midi_launchpad_mini_integrationtest.py
+++ b/midi_launchpad_mini_integrationtest.py
@@ -167,6 +167,24 @@ def test_playbackRateButtons(uut, midiWrapperMock, soloTool, playerMock):
midiWrapperMock.simulateInput(button)
assert playerMock.rate == playbackRateOptions[button]
+def test_playbackVolumeButtons(uut, midiWrapperMock, soloTool, playerMock):
+ playbackVolumeOptions = {
+ 0 : 0.125,
+ 1 : 0.250,
+ 2 : 0.375,
+ 3 : 0.500,
+ 4 : 0.625,
+ 5 : 0.750,
+ 6 : 0.875,
+ 7 : 1.000
+ }
+ uut.connect()
+ assert playerMock.volume == 1.0
+
+ for button in playbackVolumeOptions:
+ midiWrapperMock.simulateInput(button)
+ assert playerMock.volume == playbackVolumeOptions[button]
+
def test_unassignedButton(uut, midiWrapperMock):
unassignedButton = 48
uut.connect()