Skip to main content

Python wrapper for RtMidi

Project description

Python wrapper for RtMidi, the lightweight, cross-platform MIDI I/O library. For Linux, Mac OS X and Windows.

Setup

The wrapper is written in Cython, but the generated C++ code is included, so you can install the module as usual:

python setup.py install

If you want to build from the Cython source, make sure that you have a recent version of Cython (>= 0.17), and run:

python setup.py install --from-cython

Usage Examples

rtmidi-python uses the same API as RtMidi, only reformatted to comply with PEP-8, and with small changes to make it a little more pythonic.

Send messages

import rtmidi_python as rtmidi

midi_out = rtmidi.MidiOut()
midi_out.open_port(0)

midi_out.send_message([0x90, 48, 100]) # Note on
midi_out.send_message([0x80, 48, 100]) # Note off

Get incoming messages by polling

import rtmidi_python as rtmidi

midi_in = rtmidi.MidiIn()
midi_in.open_port(0)

while True:
    message, delta_time = midi_in.get_message()
    if message:
        print message, delta_time

Note that the signature of get_message() differs from the original RtMidi API: It returns a tuple instead of using a return parameter.

Get incoming messages using a callback

import rtmidi_python as rtmidi

def callback(message, time_stamp):
    print message, time_stamp

midi_in = rtmidi.MidiIn()
midi_in.callback = callback
midi_in.open_port(0)

# do something else here (but don't quit)

Note that the signature of the callback differs from the original RtMidi API: message is now the first parameter, like in the tuple returned by get_message().

License

rtmidi-python is licensed under the MIT License, see LICENSE.

It uses RtMidi, licensed under a modified MIT License, see RtMidi/RtMidi.h.

Project details


Download files

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

Source Distribution

rtmidi-python-0.2.2.tar.gz (54.8 kB view details)

Uploaded Source

Built Distributions

rtmidi-python-0.2.2.win-amd64-py2.7.exe (256.8 kB view details)

Uploaded Source

rtmidi-python-0.2.2.win32-py2.7.exe (224.3 kB view details)

Uploaded Source

File details

Details for the file rtmidi-python-0.2.2.tar.gz.

File metadata

File hashes

Hashes for rtmidi-python-0.2.2.tar.gz
Algorithm Hash digest
SHA256 a092ab3d9b45d43a342a602a60bfd94381dce39d8120f4d06152d7755d57ecf2
MD5 9bf154e3b06cb21e8c8d4f4e7d4df696
BLAKE2b-256 d17086e366288c5efef823926a0bfa19fdc90674ea11415f9b19a15894b71994

See more details on using hashes here.

File details

Details for the file rtmidi-python-0.2.2.win-amd64-py2.7.exe.

File metadata

File hashes

Hashes for rtmidi-python-0.2.2.win-amd64-py2.7.exe
Algorithm Hash digest
SHA256 1d341334182f4c041da107f109115b2e3a02c5eca961880fc11a664da7b4575d
MD5 033d6ee05ecd0476052d23fd8566c82c
BLAKE2b-256 18e196b91ea9b79d9af6837ed4ef7af52ba4722b0b42a9e09d8f6acd0209316c

See more details on using hashes here.

File details

Details for the file rtmidi-python-0.2.2.win32-py2.7.exe.

File metadata

File hashes

Hashes for rtmidi-python-0.2.2.win32-py2.7.exe
Algorithm Hash digest
SHA256 20959f5db54338a497d7c9e1821e5845bd1501654f8c59be0129e8c04d14bdbb
MD5 b4c7dbc6fbc139e526212cfc89a7b38d
BLAKE2b-256 3e44552a9cc5ee1e4d9c3f70dbd90504160d6018f90ff511dd3d245b6409f29a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page