Python wrapper for RtMidi written in Cython. Allows sending raw messages, multi-port input and sending multiple messages in one call.
Project description
Python wrapper for RtMidi, the lightweight, cross-platform MIDI I/O library. For Linux, Mac OS X and Windows.
Based on rtmidi-python
Installation
pip install rtmidi2
This module is compatible with Python 3 >= 3.7
Documentation
Usage Examples
rtmidi2 uses a very similar API as RtMidi
Print all in and out ports
import rtmidi2
print(rtmidi2.get_in_ports())
print(rtmidi2.get_out_ports())
Send messages
import rtmidi2
midi_out = rtmidi2.MidiOut()
# open the first available port
midi_out.open_port(0)
# send C3 with vel. 100 on channel 1
midi_out.send_noteon(0, 48, 100)
Get incoming messages - blocking interface
midi_in = rtmidi.MidiIn()
midi_in.open_port(0)
while True:
message, delta_time = midi_in.get_message() # will block until a message is available
if message:
print(message, delta_time)
Get incoming messages using a callback – non blocking
def callback(message, time_stamp):
print(message, time_stamp)
midi_in = rtmidi2.MidiIn()
midi_in.callback = callback
midi_in.open_port(0)
Open multiple ports at once
# get messages from all available ports
midi_in = MidiInMulti()
midi_in.open_ports("*")
def callback(msg, timestamp):
msgtype, channel = splitchannel(msg[0])
print(msgtype2str(msgtype), msg[1], msg[2])
midi_in.callback = callback
You can also get the device which generated the event by changing your callback to:
def callback(src, msg, timestamp):
# src will hold the name of the device
print("got message from", src)
Send multiple notes at once
# send a cluster of ALL notes with a duration of 1 second
midi_out = MidiOut()
midi_out.open_port()
notes = range(127)
velocities = [90] * len(notes)
midi_out.send_noteon_many(0, notes, velocities)
time.sleep(1)
midi_out.send_noteon_many(0, notes, [0] * len(notes))
License
rtmidi2 is licensed under the MIT License, see LICENSE.
It uses RtMidi, licensed under a modified MIT License, see RtMidi/RtMidi.h.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rtmidi2-1.0.1.tar.gz
(183.4 kB
view hashes)
Built Distributions
rtmidi2-1.0.1-cp310-cp310-win32.whl
(104.9 kB
view hashes)
rtmidi2-1.0.1-cp39-cp39-win_amd64.whl
(117.7 kB
view hashes)
rtmidi2-1.0.1-cp39-cp39-win32.whl
(104.8 kB
view hashes)
rtmidi2-1.0.1-cp38-cp38-win_amd64.whl
(117.8 kB
view hashes)
rtmidi2-1.0.1-cp38-cp38-win32.whl
(104.7 kB
view hashes)
Close
Hashes for rtmidi2-1.0.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ebcafa330311c761b2564f459d39d9906a51b60e8ab21638a0ca2815a9c41a0 |
|
MD5 | 5b51548a6211a6f0b0f7c2d16c3d2e39 |
|
BLAKE2b-256 | 973a5b39b710e2c85914f3291f1558488577e8bfe1dfb039b9a534e3aa753e39 |
Close
Hashes for rtmidi2-1.0.1-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c02dce873ddb7e2da20e2f759ffccaf8300e720ae40568abafe63bf4be8af92 |
|
MD5 | b7c7991a1305b6919399e545adffd483 |
|
BLAKE2b-256 | 06d0a1a086558dc0d04230153daca53d5ecaa35c9175ced38f7a8d86d6232777 |
Close
Hashes for rtmidi2-1.0.1-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c473fa386dc1c5a5f4b34162ac13e6c65c2f1fa6681b080606cf9dcfd3da349e |
|
MD5 | 531c379816a92fdda0a87225a3ca7f13 |
|
BLAKE2b-256 | 31d5058c0b54aba828213644b777db9285877c005058136d4fad1e50a13581a4 |
Close
Hashes for rtmidi2-1.0.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99814691f630231d2dfaeb43c3e8d30d850f1fd21ade7c239e38f88a808e3d7f |
|
MD5 | d37f318d100850b8dddcb44d276f4d19 |
|
BLAKE2b-256 | 3376a8b8038932df3a1252c5a398295e3c68f48c8ee4d060423f5bd98bf1a4a3 |
Close
Hashes for rtmidi2-1.0.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e41324cce28bfc334a6cdc1457f00fdb8f59324f011c55cf2a67090bbb4f949e |
|
MD5 | 5efcd33b0d9f31c080fafc5b9530de43 |
|
BLAKE2b-256 | 4e3c67c8d9f4f4eed1f8fbb143881d97b84511c7c4d7bdb4352f5ba5ca322150 |
Close
Hashes for rtmidi2-1.0.1-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8fc6352a2e4333a54cb947ad00ad1d0f1f192c23d9933a9a41a8c0d1d75cbd67 |
|
MD5 | 1c9a9760a258ff6ae50197397fac229d |
|
BLAKE2b-256 | 2a3b54792cf4a7f63b70995cfeb221f13a09d64fdb213943ac67873ef6183ff9 |
Close
Hashes for rtmidi2-1.0.1-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb8e846444f00e89a58eca1a454f61019257c3b7dff87a9a5ce9d1ecd8e786e3 |
|
MD5 | 1d06e7d1dad7eb323b8d48cb658eac30 |
|
BLAKE2b-256 | 521a1f097ac643d5d60816804ae4ffe241d887078176ce4250cd8aa1d5cf8f06 |
Close
Hashes for rtmidi2-1.0.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d66e294f84f6d63291a50c6f7451ca1061977dbc99e48b79117428b2cf014635 |
|
MD5 | 4069414a0491e90cbdb9a91f67114eb9 |
|
BLAKE2b-256 | dc8819bed06c9df730dfd58fafeeae403f19476f73abeaf3b771f8bec3cad283 |
Close
Hashes for rtmidi2-1.0.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6cf2f73b6175b7dd03e03132472ba3a3f72fe23fbb1509c99b93ed983ac88df |
|
MD5 | 16f971c9774889363284f06d880817c6 |
|
BLAKE2b-256 | 75e1f7fd092bb6982004d02aecaeab3d520f25db983a5029a41f3edc0352fa5e |
Close
Hashes for rtmidi2-1.0.1-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 624e53445867480520b9a45c26173c48d22a16c5527033c7e1a558a6d9c0aa88 |
|
MD5 | 43975704393d57d624bef9a79862cd4d |
|
BLAKE2b-256 | e4c4efa28c6ba8f4c89d3a17a4ab0d9faf274b1a4bc0c0741a93fb6ed0895b45 |
Close
Hashes for rtmidi2-1.0.1-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6948f37d6bff94b2fe6f9e31562cabab4f94218009ccf3c3f607d0f4ba26376 |
|
MD5 | 7cc86fd968aef62e1d6f318b5edfa235 |
|
BLAKE2b-256 | e0996f517ba8b10dbe3bc32a60322388bdb816418c16cc0da1aeec1bb4bd4e8e |
Close
Hashes for rtmidi2-1.0.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de510e9dabce47619077a95bb003be931c30c5ebd078b2e98618c7b95449b978 |
|
MD5 | 5dd9203f16d2b908115c2773ffa1850d |
|
BLAKE2b-256 | 53adfe867a8fc975ade144455c99d789361e7c6d837def2ae1efdcef4c3f7a36 |