aboutsummaryrefslogtreecommitdiffstats
path: root/midi_wrapper_mido.py
diff options
context:
space:
mode:
authorEddy Pedroni <eddy@0xf7.com>2022-01-01 10:18:37 +0100
committerEddy Pedroni <eddy@0xf7.com>2022-01-01 10:18:37 +0100
commit71f6a49110b6696ca6ac7956baa4edaa1aaa9527 (patch)
treee16178d2db8c6a8b7459801aab34d46255d4e8f6 /midi_wrapper_mido.py
parent9090422b2ba5eab9e4131f9b9281ed83128d977c (diff)
Added partial Launchpad support, refactored existing files
Diffstat (limited to 'midi_wrapper_mido.py')
-rw-r--r--midi_wrapper_mido.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/midi_wrapper_mido.py b/midi_wrapper_mido.py
new file mode 100644
index 0000000..ee0d6d5
--- /dev/null
+++ b/midi_wrapper_mido.py
@@ -0,0 +1,21 @@
+import mido
+
+class MidiWrapper:
+ def __init__(self):
+ self._inPort = None
+ self._outPort = None
+ self._callback = None
+
+ def setCallback(self, callback):
+ self._callback = callback
+
+ def connect(self, deviceName):
+ self._inPort = mido.open_input(deviceName)
+ self._inPort.callback = self._callback
+ self._outPort = mido.open_output(deviceName)
+
+ def sendMessage(note, velocity=127, channel=0):
+ if self._outPort is not None:
+ msg = mido.Message('note_on', channel=channel, velocity=velocity, note=note)
+ self.outPort.send(msg)
+