Created
July 16, 2020 19:48
-
-
Save duhaime/b72792eab26963d9aa7827be0861a1ae to your computer and use it in GitHub Desktop.
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