Skip to content

Instantly share code, notes, and snippets.

@valsteen
Created September 20, 2015 16:34
Show Gist options
  • Save valsteen/3e50557c8b65d55ba2b6 to your computer and use it in GitHub Desktop.
Save valsteen/3e50557c8b65d55ba2b6 to your computer and use it in GitHub Desktop.
MIDI to sysex
def reply_sysex(self, message):
from array import array
try:
raw = array('B')
raw.fromstring(message.encode('utf-16-le'))
raw = raw.tolist()
raw.insert(0, 240)
raw.append(247)
self._send_midi(tuple(raw), False)
except Exception, e:
self.log_message(repr(e))
def receive_midi(self, midi_bytes):
from array import array
try:
raw = array('B')
raw.fromlist(list(midi_bytes[1:-1]))
message = raw.tostring().decode('utf-16-le')
self.respond(message, self.reply_sysex)
except Exception, e:
self.log_message(repr(e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment