You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importrtmidi2midi_out=rtmidi2.MidiOut()
# open the first available portmidi_out.open_port(0)
# send C3 with vel. 100 on channel 1midi_out.send_noteon(0, 48, 100)
# get messages from all available portsmidi_in=MidiInMulti()
midi_in.open_ports("*")
defcallback(msg, timestamp):
msgtype, channel=splitchannel(msg[0])
print(msgtype2str(msgtype), msg[1], msg[2])
midi_in.callback=callback
You can also get the device which generated the event by changing your callback to:
defcallback(src, msg, timestamp):
# src will hold the name of the deviceprint("got message from", src)
Send multiple notes at once
# send a cluster of ALL notes with a duration of 1 secondmidi_out=MidiOut()
midi_out.open_port()
notes=range(127)
velocities= [90] *len(notes)
midi_out.send_noteon_many(0, notes, velocities)
time.sleep(1)
midi_out.send_noteon_many(0, notes, [0] *len(notes))
License
rtmidi2 is licensed under the MIT License, see LICENSE.
It uses RtMidi, licensed under a modified MIT License, see RtMidi/RtMidi.h.
About
python bindings to rtmidi allowing to listen to multiple ports simultaneously