aboutsummaryrefslogtreecommitdiffstats
path: root/midi_controller_launchpad_mini.py
diff options
context:
space:
mode:
authorEddy Pedroni <eddy@0xf7.com>2022-01-03 16:47:48 +0100
committerEddy Pedroni <eddy@0xf7.com>2022-01-03 16:47:48 +0100
commit1423f2922650a8ba9104e595f87d66a83a244fb1 (patch)
treed46fc7dacf8a4a4815bd6d07af1e950d2bcb53a6 /midi_controller_launchpad_mini.py
parent794d645856da721e0bc7e97a788dcc60e4c87f0c (diff)
Added LED feedback to playback rate and volume, same hacky implementation
Diffstat (limited to 'midi_controller_launchpad_mini.py')
-rw-r--r--midi_controller_launchpad_mini.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/midi_controller_launchpad_mini.py b/midi_controller_launchpad_mini.py
index ec69509..2e83cc2 100644
--- a/midi_controller_launchpad_mini.py
+++ b/midi_controller_launchpad_mini.py
@@ -9,6 +9,14 @@ class MidiController:
LED_OFF = 0
BUTTON_MATRIX = [[x for x in range(y * 16, y * 16 + 8)] for y in range(0,8)] # address as [row][col]
+ MIN_PLAYBACK_RATE = 0.5
+ MAX_PLAYBACK_RATE = 1.2
+ PLAYBACK_RATE_STEP = 0.1
+
+ MIN_PLAYBACK_VOLUME = 0.125
+ MAX_PLAYBACK_VOLUME = 1.0
+ PLAYBACK_VOLUME_STEP = 0.125
+
def __init__(self, soloTool, midiWrapperOverride=None):
self._soloTool = soloTool
if midiWrapperOverride is not None:
@@ -30,12 +38,12 @@ class MidiController:
}
for i in range(0, 8):
- volume = round(0.125 + i * 0.125, 3)
- self._handlers[i] = self._createSetPlaybackVolumeCallback(volume)
+ volume = round(MidiController.MIN_PLAYBACK_VOLUME + i * MidiController.PLAYBACK_VOLUME_STEP, 3)
+ self._handlers[i] = self._createSetPlaybackVolumeCallback(volume, [MidiController.LED_GREEN] * (i + 1) + [MidiController.LED_OFF] * (7 - i))
- for i in range(16, 24):
- rate = round(0.5 + (i - 16) * 0.1, 1)
- self._handlers[i] = self._createSetPlaybackRateCallback(rate)
+ for i, button in enumerate(range(16, 24)):
+ rate = round(MidiController.MIN_PLAYBACK_RATE + MidiController.PLAYBACK_RATE_STEP * i, 1)
+ self._handlers[button] = self._createSetPlaybackRateCallback(rate, [MidiController.LED_YELLOW] * (i + 1) + [MidiController.LED_OFF] * (7 - i))
def connect(self):
self._midiWrapper.setCallback(self._callback)
@@ -43,7 +51,7 @@ class MidiController:
self._initialiseButtonLEDs()
def _callback(self, msg):
- if msg.velocity < 127:
+ if msg.type != "note_on" or msg.velocity < 127:
return
if msg.note in self._handlers:
@@ -61,14 +69,18 @@ class MidiController:
self._soloTool.stop()
self._setButtonLED(7, 0, MidiController.LED_YELLOW)
- def _createSetPlaybackRateCallback(self, rate):
+ def _createSetPlaybackRateCallback(self, rate, colours):
def f():
self._soloTool.setPlaybackRate(rate)
+ for col, colour in enumerate(colours):
+ self._setButtonLED(1, col, colour)
return f
- def _createSetPlaybackVolumeCallback(self, volume):
+ def _createSetPlaybackVolumeCallback(self, volume, colours):
def f():
self._soloTool.setPlaybackVolume(volume)
+ for col, colour in enumerate(colours):
+ self._setButtonLED(0, col, colour)
return f
def _setButtonLED(self, row, col, colour):