& JACK), Macintosh OS X “> Springe zum Hauptinhalt

What is python-rtmidi?

python-rtmidi is a Python binding for the RtMidi C++ library. RtMidi provides a simple, cross-platform API for realtime MIDI input/output on Linux (ALSA & JACK), Macintosh OS X (CoreMidi & JACK), and Windows (Multimedia Library).

python-rtmidi is implemented with Cython and provides a thin wrapper around the RtMidi C++ interface. The API is very similar to the C++ one but with the naming scheme adapted to the Python PEP-8 conventions and requirements of the Python package naming structure. It supports Python 2.7, 3.3, 3.4 and 3.5.

Quick Start

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()

with (midiout.open_port(0) if midiout.get_ports() else
      midiout.open_virtual_port("My virtual output")):
    note_on = [0x90, 60, 112] # channel 1, middle C, velocity 112
    note_off = [0x80, 60, 0]

del midiout