Created
July 16, 2020 19:48
Star
You must be signed in to star a gist
Mido port streaming
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mido | |
with mido.open_input('mido_port', virtual=True) as in_port: | |
for msg in in_port: | |
print(msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mido | |
from mido.backends import rtmidi # one must import the backend before it's available | |
mido.set_backend('mido.backends.rtmidi', load=True) | |
out_port = mido.open_output('mido_port') | |
print(portmidi.get_devices()) | |
print(mido.get_output_names()) | |
''' | |
# prints: | |
[{'opened': False, 'is_input': 1, 'is_output': 0, 'interface': 'CoreMIDI', 'name': 'mido_port', 'id': 0}, {'opened': False, 'is_input': 1, 'is_output': 0, 'interface': 'CoreMIDI', 'name': 'mido_port', 'id': 1}, {'opened': False, 'is_input': 0, 'is_output': 1, 'interface': 'CoreMIDI', 'name': 'mido_port', 'id': 2}] | |
['mido_port'] | |
''' | |
msg = mido.Message('note_on', note=60) | |
out_port.send(msg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment