Last modified 4 months ago Last modified on 08/18/2020 04:21:40 PM

A Python wrapper for the RtMidi C++ library written with Cython.

The current version is 1.4.3, released on 2020-08-11.

Quick links


$ pip install python-rtmidi

Or clone the Git repository:

$ git clone

and build & install with:

$ python install


RtMidi is a set of C++ classes which provides a concise and simple, cross-platform API (Application Programming Interface) for realtime MIDI input/output across Linux (ALSA & JACK), Macintosh OS X (CoreMIDI & JACK), and Windows (MultiMedia System) operating systems.

python-rtmidi is a Python binding for RtMidi implemented with Cython and provides a thin wrapper around the RtMidi C++ interface. The API is basically the same as the C++ one but with the naming scheme of classes, methods and parameters adapted to the Python PEP-8 conventions and requirements of the Python package naming structure. python-rtmidi supports Python 3 (3.5, 3.6, 3.7 and 3.8).

Usage example

Here's a quick example of how to use python-rtmidi to open the first available MIDI output port and send a middle C note on MIDI channel 1:

import time
import rtmidi

midiout = rtmidi.MidiOut()
available_ports = midiout.get_ports()

if available_ports:
    midiout.open_virtual_port("My virtual output")

with midiout:
    # channel 1, middle C, velocity 112
    note_on = [0x90, 60, 112]
    note_off = [0x80, 60, 0]

del midiout

More usage examples can be found in the examples directory of the source distribution.

The documentation provides installation instructions and an API reference.