Mido - MIDI Objects for Python
Overview
Mido is a Python library for working with MIDI 1.0 ports, messages and files:
>>> import mido
>>> msg = mido.Message('note_on', note=60)
>>> msg.type
'note_on'
>>> msg.note
60
>>> msg.bytes()
[144, 60, 64]
>>> msg.copy(channel=2)
Message('note_on', channel=2, note=60, velocity=64, time=0)
port = mido.open_output('Port Name')
port.send(msg)
with mido.open_input() as inport:
for msg in inport:
print(msg)
mid = mido.MidiFile('song.mid')
for msg in mid.play():
port.send(msg)
Mido is short for MIDI objects.
About this document
This document refers to Mido version 1.3.2.
Note
An up-to-date version of this document is always available at https://mido.readthedocs.io.
License
This documentation (Except our code of conduct) is licensed under the Creative Commons Attribution 4.0 International License.
See also
Community & Source Code
Come visit us at https://github.com/mido.
Everybody is welcome!
See also