midi: use python-rtmidi instead of pyrtmidi
This commit is contained in:
parent
e4c303c9c0
commit
bf994816d8
3 changed files with 120 additions and 77 deletions
|
|
@ -4,18 +4,27 @@ import traceback
|
|||
import json as JSON
|
||||
import re
|
||||
|
||||
def ipcSend(name, data):
|
||||
def ipc_send(name, data):
|
||||
print(JSON.dumps([name, data]))
|
||||
stdout.flush()
|
||||
|
||||
try:
|
||||
import rtmidi
|
||||
API = rtmidi.RtMidiIn.UNIX_JACK if 'jack' in argv else rtmidi.RtMidiIn.UNSPECIFIED
|
||||
JACK = API == rtmidi.RtMidiIn.UNIX_JACK
|
||||
in_dev = rtmidi.RtMidiIn(API, 'MIDI->OSC probe')
|
||||
out_dev = rtmidi.RtMidiOut(API, 'OSC->MIDI probe')
|
||||
import rtmidis
|
||||
from rtmidi.midiconstants import *
|
||||
|
||||
API = rtmidi.API_UNIX_JACK if 'jack' in argv else rtmidi.API_UNSPECIFIED
|
||||
if API is rtmidi.API_UNIX_JACK and rtmidi.API_UNIX_JACK not in rtmidi.get_compiled_api():
|
||||
API = rtmidi.API_UNSPECIFIED
|
||||
ipc_send('log', 'python-rtmidi was not compiled with jack midi support, falling back to default API')
|
||||
|
||||
JACK = API == rtmidi.API_UNIX_JACK
|
||||
|
||||
in_dev = rtmidi.MidiIn(API, 'MIDI->OSC probe')
|
||||
out_dev = rtmidi.MidiOut(API, 'OSC->MIDI probe')
|
||||
|
||||
except:
|
||||
ipcSend('error', 'pyrtmidi not found (or wrong version)\nRunning with python version %s' % version)
|
||||
ipc_send('log', 'ERROR: MIDI: python-rtmidi not found (or wrong version)\nRunning with python version %s' % version)
|
||||
ipc_send('log', '\nGet python-rtmidi at https://spotlightkid.github.io/python-rtmidi/')
|
||||
exit()
|
||||
|
||||
if version_info.major == 3:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue