python-rtmidi

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

python-rtmidi Ranking & Summary

Advertisement

  • Rating:
  • License:
  • MIT/X Consortium Lic...
  • Price:
  • FREE
  • Publisher Name:
  • Christopher Arndt
  • Publisher web site:
  • http://chrisarndt.de/project/spammcan/

python-rtmidi Tags


python-rtmidi Description

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).Notepython-rtmidi is currently in alpha-stage, which means is is published in the hope that other developers try it out and help finding bugs, and that its API is not yet finalised. What is there should work but is currently only tested thoroughly under Linux/ALSA and less regulary under Linux/JACK and OS X/CoreMIDI. Windows support is still untested but will be reviewed soon.Usage exampleHere'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 timeimport rtmidimidiout = rtmidi.MidiOut()available_ports = midiout.get_ports()if available_ports: midiout.open_port(0)else: midiout.open_virtual_port("My virtual output")note_on = # channel 10, middle C, velocity 112note_off = midiout.send_message(note_on)time.sleep(0.5)midiout.send_message(note_off)del midioutMore 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 or by reading the RtMidi documentation.Installationpython-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.From PyPIIf you have all the dependencies, you should be able to install the package with pip or easy_install: pip install python-rtmidior, if you prefer setuptools: easy_install python-rtmidiThis 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-rtmidiFrom the Source DistributionOf 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.1a.tar.gz$ tar xzf python-rtmidi-0.1a.tar.gz$ cd python-rtmidi-0.1a$ python setup.py installFrom SubversionLastly, 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 installProduct's homepage


python-rtmidi Related Software