https://github.com/spotlightkid/python-rtmidi
Python bindings for the cross-platform MIDI I/O library RtMidi
https://github.com/spotlightkid/python-rtmidi
alsa coremidi jack-midi midi python rtmidi
Last synced: about 11 hours ago
JSON representation
Python bindings for the cross-platform MIDI I/O library RtMidi
- Host: GitHub
- URL: https://github.com/spotlightkid/python-rtmidi
- Owner: SpotlightKid
- License: other
- Created: 2015-06-24T18:13:05.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2025-04-17T17:18:14.000Z (28 days ago)
- Last Synced: 2025-05-13T02:12:11.598Z (2 days ago)
- Topics: alsa, coremidi, jack-midi, midi, python, rtmidi
- Language: Cython
- Homepage: https://spotlightkid.github.io/python-rtmidi/
- Size: 4.67 MB
- Stars: 370
- Watchers: 17
- Forks: 67
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: docs/contributing.rst
- License: LICENSE.md
- Authors: AUTHORS.md
Awesome Lists containing this project
README
# Welcome to python-rtmidi!
A Python binding for the RtMidi C++ library implemented using Cython.
[](https://pypi.org/project/python-rtmidi)

[](LICENSE.md)

[](https://pypi.org/project/python-rtmidi/#files)
[](https://github.com/SpotlightKid/python-rtmidi/actions)# 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), macOS / OS X (CoreMIDI & JACK), and
Windows (MultiMedia System) operating systems.[python-rtmidi] is a Python binding for RtMidi implemented using [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.9+).The [documentation] provides installation instructions, a history of changes
per release and an API reference.See the file [LICENSE.md] about copyright and usage terms.
The source code repository and issue tracker are hosted on GitHub:
.
## 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:```python
import time
import rtmidimidiout = rtmidi.MidiOut()
available_ports = midiout.get_ports()if available_ports:
midiout.open_port(0)
else:
midiout.open_virtual_port("My virtual output")with midiout:
note_on = [0x90, 60, 112] # channel 1, middle C, velocity 112
note_off = [0x80, 60, 0]
midiout.send_message(note_on)
time.sleep(0.5)
midiout.send_message(note_off)
time.sleep(0.1)del midiout
```More usage examples can be found in the [examples] and [tests] directories of
the source repository.[Cython]: http://cython.org/
[documentation]: https://spotlightkid.github.io/python-rtmidi/
[examples]: https://github.com/SpotlightKid/python-rtmidi/tree/master/examples
[LICENSE.md]: https://github.com/SpotlightKid/python-rtmidi/blob/master/LICENSE.md
[python-rtmidi]: https://github.com/SpotlightKid/python-rtmidi
[tests]: https://github.com/SpotlightKid/python-rtmidi/tree/master/tests
[RtMidi]: http://www.music.mcgill.ca/~gary/rtmidi/index.html