diff options
author | Eddy Pedroni <eddy@0xf7.com> | 2022-01-01 10:18:37 +0100 |
---|---|---|
committer | Eddy Pedroni <eddy@0xf7.com> | 2022-01-01 10:18:37 +0100 |
commit | 71f6a49110b6696ca6ac7956baa4edaa1aaa9527 (patch) | |
tree | e16178d2db8c6a8b7459801aab34d46255d4e8f6 /midi_controller_launchpad_mini.py | |
parent | 9090422b2ba5eab9e4131f9b9281ed83128d977c (diff) |
Added partial Launchpad support, refactored existing files
Diffstat (limited to 'midi_controller_launchpad_mini.py')
-rw-r--r-- | midi_controller_launchpad_mini.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/midi_controller_launchpad_mini.py b/midi_controller_launchpad_mini.py new file mode 100644 index 0000000..16c819c --- /dev/null +++ b/midi_controller_launchpad_mini.py @@ -0,0 +1,40 @@ +from midi_wrapper_mido import MidiWrapper + +class MidiController: + DEVICE_NAME = "Launchpad Mini MIDI 1" + + def __init__(self, soloTool, midiWrapperOverride=None): + self._soloTool = soloTool + if midiWrapperOverride is not None: + self._midiWrapper = midiWrapperOverride + else: + self._midiWrapper = MidiWrapper() + + self._handlers = { + 112 : self._playPause, + 96 : self._stop, + 101 : self._jumpToA + } + + def connect(self): + self._midiWrapper.connect(MidiController.DEVICE_NAME) + self._midiWrapper.setCallback(self._callback) + + def _callback(self, msg): + if msg.velocity < 127: + return + + if msg.note in self._handlers: + handler = self._handlers[msg.note]() + + def _playPause(self): + if self._soloTool.isPlaying(): + self._soloTool.pause() + else: + self._soloTool.play() + + def _stop(self): + self._soloTool.stop() + + def _jumpToA(self): + self._soloTool.jumpToA() |