def print_messages(inargs=None): ports = [mido.open_input(name) for name in mido.get_input_names()] for port in ports: print('Using {}'.format(port)) print('Waiting for messages...') try: for message in multi_receive(ports): print('Received {}'.format(message)) except KeyboardInterrupt: pass
print("\n input ports ", ports) for port in ports: print('Using {}'.format(port)) print('\n ----- \n Waiting for messages...\n -----\n') local_off = Message('control_change', channel=13, control=122, value=0) with mido.open_output(to_Keyboard, autoreset=True) as kb: time.sleep(1) kb.send(local_off) try: with mido.open_output(to_Axoloti, autoreset=True) as port: for message in multi_receive(ports): if hasattr(message, "note"): currNote = message if message.type == 'note_on': on = Message('note_on', channel=outCh, velocity=currNote.velocity, note=currNote.note) port.send(on) #print(on) if message.type == 'note_off': off = Message('note_off', channel=outCh, note=currNote.note) port.send(off) if message.type == 'control_change':
#!/usr/bin/env python """ Receive messages from multiple ports. """ import mido from mido.ports import multi_receive # Open all available inputs. ports = [mido.open_input(name) for name in mido.get_input_names()] for port in ports: print('Using {}'.format(port)) print('Waiting for messages...') try: for message in multi_receive(ports): print('Received {}'.format(message)) except KeyboardInterrupt: pass