Skip to main content

MIDI Objects for Python

Project description

Mido is a library for working with MIDI messages and ports. It’s designed to be as straight forward and Pythonic as possible:

>>> import mido
>>> output = mido.open_output()
>>> output.send(mido.Message('note_on', note=60, velocity=64))
>>> with input as mido.open_input('SH-201'):
...     for msg in input:
...         print(msg)
>>> msg = mido.Message('program_change', program=10)
>>> msg.type
>>> = 2
>>> msg2 = msg.copy(program=9)
<message program_change channel=2, program=9, time=0>

Full documentation at


This is the first stable release. All basic functionality is in place. (Messages, ports and parser.)


Mido targets Python 2.7 and 3.2 and runs on Ubuntu and Mac OS X. May also run on other systems.

If you want to use message ports, you will need PortMidi installed on your system. The PortMidi library is loaded on demand, so you can use the parser and messages without it.


To install:

$ pip install mido

The PortMidi wrapper is written with ctypes, so no compilation is required.

If you want to use ports, you need the PortMidi shared library. The Ubuntu package is called libportmidi-dev. PortMidi is also available in MacPorts and Homebrew under the name portmidi.


Documentation is available at

Known Bugs

  • on OS X, PortMidi usually hangs for a second or two seconds while initializing. (It always succeeds.)
  • libportmidi prints out error messages instead of returning err and setting the error message string. Thus, Mido can’t catch errors and raise the proper exception. (I’ve been able to work around this when opening ports, so don’t know if this is still a problem.)
  • there is an obscure bug involving the OS X application Midi Keys. See tmp/

Future Plans

  • add a library of useful tools, such as delays, an event engine and message filters.
  • support running status (This is currently tricky or impossible with PortMidi, but could be useful for other data sources.)
  • support time codes (0xf1). (These have one data bytes divided into 3 bits type and 4 bits values. It’s unclear how to handle this.)


Mido is released under the terms of the MIT license.

Latest version of the code: .

Author: Ole Martin Bjørndalen -

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for mido, version 1.0.3
Filename, size File type Python version Upload date Hashes
Filename, size mido-1.0.3.tar.gz (28.4 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page