Skip to content

Instantly share code, notes, and snippets.

@nucklearproject
Created September 17, 2023 20:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nucklearproject/823331176a98303fcc35ac794fa4b385 to your computer and use it in GitHub Desktop.
Save nucklearproject/823331176a98303fcc35ac794fa4b385 to your computer and use it in GitHub Desktop.
Mido python - Receive messages from muiltiple input port and print them out.
"""
Receive messages from muiltiple input port and print them out.
"""
import sys
#from mido.ports import MultiPort
from mido import open_input, get_input_names
ports = get_input_names()
portA = open_input(ports[1])
portB = open_input(ports[2])
while True:
for msg1 in portA.iter_pending():
print(f'Received {msg1}')
sys.stdout.flush()
for msg in portB.iter_pending():
print(f'Received {msg}')
sys.stdout.flush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment