Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Overview

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 Library & Kernel Streaming) 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 2 (tested with Python 2.7) and Python 3 (3.2).

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 10:

import time
import rtmidi

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

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

note_on = [0x99, 60, 112] # channel 10, middle C, velocity 112
note_off = [0x89, 60, 0]
midiout.send_message(note_on)
time.sleep(0.5)
midiout.send_message(note_off)

del midiout

More usage examples can be found in the tests directory of the source distribution. API documentation is available by looking at the docstrings in the Cython source code or using tools like pydoc or IPython and by reading the RtMidi documentation.

Installation

python-rtmidi is a Python C(++)-extension and therefore a C++ compiler and a build environment as well as some system-dependant libraries are needed. See “Requirements” below for details.

Installer (Windows only)

An installer with a pre-compiled version for Windows with Windows MultiMedia API support is available through PyPI fro some Python versions. Download it from python-rtmidi’s PyPI page and start the installer by double-clicking.

From PyPI

If you have all the dependencies, you should be able to install the package with pip or easy_install:

$ pip install python-rtmidi

or, if you prefer setuptools:

$ easy_install python-rtmidi

This will download the source distribution, compile the extension and install it in your active Python installation. Unless you want to change the Cython source file _rtmidi.pyx, there is no need to have Cython installed.

python-rtmidi also works well with virtualenv and virtualenvwrapper. If you have both installed, creating an isolated environment for testing and using python-rtmidi is as easy as:

$ mkvirtualenv rtmidi
(rtmidi)$ pip install python-rtmidi

From the Source Distribution

Of course, you can also download the source distribution package as a Zip archive or tarball, extract it and install using the common distutils commands, e.g.:

$ wget http://chrisarndt.de/projects/python-rtmidi/download/python-rtmidi-0.2a.tar.gz
$ tar xzf python-rtmidi-0.2a.tar.gz
$ cd python-rtmidi-0.2a
$ python setup.py install

From Subversion

Lastly, you can check out the python-rtmidi source code from the Subversion repository and then install it from your working copy. Since the repository does not include the C++ module source code pre-compiled from the Cython source, you’ll also need to install Cython from its Git repository. Using virtualenv/virtualenvwrapper is strongly recommended in this scenario:

$ mkvirtualenv rtmidi
(rtmidi)$ cdvirtualenv
(rtmidi)$ git clone https://github.com/cython/cython.git
(rtmidi)$ svn co svn://svn.chrisarndt.de/projects/python-rtmidi/trunk python-rtmidi
(rtmidi)$ cd cython
(rtmidi)$ python setup.py install
(rtmidi)$ cd ../python-rtmidi
(rtmidi)$ python setup.py install

Requirements

Naturally, you’ll need a C++ compiler and a build environment. See the platform-specific hints below.

Only if you want to change the Cython source file _rtmidi.pyx or want to recompile _rtmidi.cpp with a newer Cython version, you’ll need to install Cython >= 0.17. Currently this version is only available via the Git respository (see Cython web site) as version 0.17pre. The _rtmidi.cpp file in the source distribution was compiled with Cython 0.17pre as of 2012-07-22 and Python 2.7.2.

RtMidi (and therefore python-rtmidi) supports several low-level MIDI libraries on different operating systems. Only one of the available options needs to be present on the target system, but support for more than one can be compiled in. The setup script will try to detect available libraries and should use the appropriate compilations flags automatically.

  • Linux: ALSA, JACK

  • OS X: CoreMIDI, JACK

  • Windows: MultiMedia (MM), Windows Kernel Streaming

Linux

For the C++ compiler and the pthread library install the build-essential package on debian-based systems.

Then you’ll need Python development headers and libraries. On Linux, install the python-dev package. If you use the official installers from python.org you should already have these.

To get ALSA support, you must install development files for the libasound library (debian package: libasound-dev). For JACK support, install the libjack development files (libjack-dev or libjack-jackd2-dev).

OS X

Install the latest Xcode or g++ from MacPorts or homebrew (untested). CoreMIDI support comes with installing Xcode. For JACK support, install JACK for OS X with the full installer.

Windows

On Windows you’ll need Visual Studio 2008 Express. Visual Studio 2010 (Express) or later editions will not work with current official Python distributons. After you have installed the Visual Studio, you probably need to edit the WINLIB_DIR and WININC_DIR variables at the top of the setup.py file to point to the location of WinMM.lib and the Microsoft SDK headers.

Compiling python-rtmidi with Windows Kernel Streaming support currently does not work due to syntax errors in RtMidi.cpp. This is currentyl being investigated. You can exclude Windows Kernel Streaming Support by providing the --no-winks option to the setup.py invocation.

Compiling with MinGW also does not work out-of-the-box yet. If you have any useful hints, please let the author know.

Release files for python-rtmidi 0.2a

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distributions (sdists)

Source distribution for python-rtmidi 0.2a
File Size Uploaded
python-rtmidi-0.2a.zip 75.9 kB Details
python-rtmidi-0.2a.tar.bz2 57.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for python-rtmidi 0.2a
File
python_rtmidi-0.2a-py2.7-macosx-10.6-i386.egg Legacy Egg format - - Details
python_rtmidi-0.2a-py2.6-macosx-10.6-universal.egg Legacy Egg format - - Details
python-rtmidi-0.2a.win32-py3.2.exe Details
python-rtmidi-0.2a.win32-py2.7.exe Details

Total release size: 832.3 kB

Release files / python-rtmidi-0.2a.zip

Download URL python-rtmidi-0.2a.zip
Size 75.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2339cc147887c9f8e1a6dad4d08342fb2c00f14e5a92a1984659d9b6db9a2dfb
BLAKE2b-256 checksum
How to use checksums
89dde788c1ae959b20312e398716d6eeb37f114ab8daced80c97c934d08320c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / python-rtmidi-0.2a.tar.bz2

Download URL python-rtmidi-0.2a.tar.bz2
Size 57.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0b3336eb6cfdc8316bced7d43622cebb5f8f590d6f09b53cb85dd45bde609692
BLAKE2b-256 checksum
How to use checksums
72553faa865ec20a196be1181225ed2a5e42b6d0094b5f504ddf5d69a7a78d31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / python_rtmidi-0.2a-py2.7-macosx-10.6-i386.egg

Download URL python_rtmidi-0.2a-py2.7-macosx-10.6-i386.egg
Size 63.7 kB
Tags Egg
SHA-256 checksum
How to use checksums
7cc144af1795dff0b9fd3f33da328b5420ddd1bd4da409675c1ab4050d073e49
BLAKE2b-256 checksum
How to use checksums
1805fa597902c71fc1cab3663140559b8d9d6e2230b334a5f6596fcc15a82a3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / python_rtmidi-0.2a-py2.6-macosx-10.6-universal.egg

Download URL python_rtmidi-0.2a-py2.6-macosx-10.6-universal.egg
Size 145.3 kB
Tags Egg
SHA-256 checksum
How to use checksums
996461075df8d5cd3720cb4706cc4d503299226ccf9ea7a79486a1b89fdac84e
BLAKE2b-256 checksum
How to use checksums
bbfae7b5b042e3556122cd871bd304e40e43a8d42243cac25dd38b5357036c1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / python-rtmidi-0.2a.win32-py3.2.exe

Download URL python-rtmidi-0.2a.win32-py3.2.exe
Size 245.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9e93e75622f0821400554c0c99fdda216b6da8aabdb31176ce1f6244bd11845a
BLAKE2b-256 checksum
How to use checksums
219575ad9eb83a097ceed2dc3fdb3d19ff54d7d5f366dd7786a6b3a48a4c4e6b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / python-rtmidi-0.2a.win32-py2.7.exe

Download URL python-rtmidi-0.2a.win32-py2.7.exe
Size 245.4 kB
Tags Source
SHA-256 checksum
How to use checksums
72fd73725753b2ea18b5c13df7dd9d3885b25efa0dbe8df100ce891814993e7d
BLAKE2b-256 checksum
How to use checksums
da2fd59d5e05398686d75a76812fbab7fbffcd8c0f608a4f3853df579c0790a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

1.5.8

26 release files

1.5.7

26 release files

1.5.6

21 release files

1.5.5

21 release files

1.5.4

21 release files

1.5.3

21 release files

1.5.2

21 release files

1.5.1

17 release files

1.5.0

17 release files

1.4.9

13 release files

1.4.8

12 release files

1.4.7

12 release files

1.4.6

12 release files

1.4.5

12 release files

1.4.4

12 release files

1.4.3

12 release files

1.4.2

12 release files

1.4.1

12 release files

1.4.0

12 release files

1.3.1

12 release files

1.3.0

12 release files

1.2.1

12 release files

1.2.0

12 release files

1.1.2

12 release files

1.1.1

1 release file

1.1.0

11 release files

1.0.0

9 release files

This release

0.2a This release

6 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page