From 71f6a49110b6696ca6ac7956baa4edaa1aaa9527 Mon Sep 17 00:00:00 2001 From: Eddy Pedroni Date: Sat, 1 Jan 2022 10:18:37 +0100 Subject: Added partial Launchpad support, refactored existing files --- midi_wrapper_mido.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 midi_wrapper_mido.py (limited to 'midi_wrapper_mido.py') 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) + -- cgit v1.2.3