fixed midi port bug

This commit is contained in:
langolierz
2020-02-29 11:25:03 +00:00
parent f2fb362ad5
commit cf0e2e0ea6
2 changed files with 9 additions and 7 deletions

View File

@@ -35,11 +35,13 @@ class MidiInput(object):
def open_this_port_and_start_listening(self, port_phrase):
midi_ports = mido.get_input_names()
midi_device_on_port = [s for s in midi_ports if port_phrase in s]
if midi_device_on_port:
midi_devices = [s for s in midi_ports if not ('Midi Through' in s)]
if port_phrase == 'serial':
midi_devices = [s for s in midi_devices if port_phrase in s]
if midi_devices:
if self.data.midi_status == 'disconnected':
subport_index = self.port_index % len(midi_device_on_port)
self.midi_device = mido.open_input(midi_device_on_port[subport_index])
subport_index = self.port_index % len(midi_devices)
self.midi_device = mido.open_input(midi_devices[subport_index])
self.data.midi_status = 'connected'
self.message_handler.set_message('INFO', 'connected to midi device {}'.format(self.midi_device.name))
self.poll_midi_input()