blob: ee0d6d5f510d763f8f378b9197d880c3d2860e72 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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)
|