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.2.1.tar.gz
(188.5 kB
view hashes)
Built Distributions
rtmidi2-1.2.1-cp311-cp311-win32.whl
(103.2 kB
view hashes)
rtmidi2-1.2.1-cp310-cp310-win32.whl
(104.0 kB
view hashes)
rtmidi2-1.2.1-cp39-cp39-win_amd64.whl
(119.7 kB
view hashes)
rtmidi2-1.2.1-cp39-cp39-win32.whl
(106.2 kB
view hashes)
Close
Hashes for rtmidi2-1.2.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 867e0f5d4f66aa7293da1fe4529ee7cb58104692d0925ff790098e9803c80281 |
|
MD5 | 4bd2685f9b4aa0dcf4945c8571d02419 |
|
BLAKE2b-256 | 8a1fe0cc7bbe252ffe867f549169aee324c7b688c6ac0095e02c47b3b05a7359 |
Close
Hashes for rtmidi2-1.2.1-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb189d9220b343724d4cf05f5d7014fe4c8a8f34078321d4073844fedd74d783 |
|
MD5 | b5fe2b31c9b1b0fa37fc26f8f58884cb |
|
BLAKE2b-256 | 9d5374d590c6f82054ccbb7f8b0dceac59997228a63632d63892f3152aeddfa3 |
Close
Hashes for rtmidi2-1.2.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5a8ee983f7232e1eba94536b1f19558737b913f080c27ff401d8f5d5add4726 |
|
MD5 | 612f68ef30216de5af9bb4b7c6eb8942 |
|
BLAKE2b-256 | 0555301670f413622f1de3c25830ceb0f854f44041cb651e90a0dbe9e0b1149f |
Close
Hashes for rtmidi2-1.2.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cf08e3209e8a5b66d22a34896a66c560a3b6314ab23773ecc2fea85d3318241 |
|
MD5 | 760c4528cc3f53be5f5c70335bacca04 |
|
BLAKE2b-256 | a6ec2dcf9b7d58057713e26794cbaf6ede79ef82ed79d1b3146d4d4f4fe23203 |
Close
Hashes for rtmidi2-1.2.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 630c49d16461ecf0bb51443614c395e0eddd6964d97b3a2cfbfc1bba43ef451b |
|
MD5 | 54a932b4d3d34f319616c1c5008f5316 |
|
BLAKE2b-256 | e6611e38e62da1b6d41fe8b321d916f9ff95052e06eb26b4441498094fc5745e |
Close
Hashes for rtmidi2-1.2.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c03b3009dff748579e73bf2c7f3c2fba9b17900bfaef99365256f830ccbfa230 |
|
MD5 | 8aaa2721ade1ac1d6cda71b83fb488b6 |
|
BLAKE2b-256 | 3d2ff600eeef37e7000dedad7dc93d3268ad653f12dd660793490cfb966a029c |
Close
Hashes for rtmidi2-1.2.1-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c361ee2a1dd41522724e2bdf55534ee7d442abab80eec8a0e556c45a29ef991 |
|
MD5 | 73a09db936759395728abb6e3401e705 |
|
BLAKE2b-256 | 0b651889c21a8c076d9c90ab2dba8aff2070f519ea736ef156a68818d4478f83 |
Close
Hashes for rtmidi2-1.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82b627fdc380839bf9597a118d2d3735c09f4ba9c2f236821bab1eb7d9bc60f5 |
|
MD5 | 6ff0f394c66f127f1efd2adaa9a16db4 |
|
BLAKE2b-256 | 1649012928a277f5214d8a354d518359535e4e20f00e08c3cfccc20edb8fc982 |
Close
Hashes for rtmidi2-1.2.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2abd44651f5794d69c7a2911a785ef1d6a078291842f380984ca147cea56ce8 |
|
MD5 | c92b371271330515d1741cbef8248a3b |
|
BLAKE2b-256 | f4f4e8cf6a9985ab65d2d0da82446ece8ddb193b3d19abf0bc0fda098090726b |
Close
Hashes for rtmidi2-1.2.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d2b09405653e83ad8d2832a4bdedc247a03f8322cff31fa5efb0a78b9fb3ed1 |
|
MD5 | 1c9666ceda8af903ebefa0d0b016a5f0 |
|
BLAKE2b-256 | eeb0d27e60b87f8a6a8fafd19a2c53a5a667cc556b1dcce60d0dd44a12ef0bfe |
Close
Hashes for rtmidi2-1.2.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32fd8882f5aea2ba38baa6b3a63b16ca015f563b2cda2334b5d37f3d87012a58 |
|
MD5 | 8dbc41f6cd882cdbb1fd6c76c53e429b |
|
BLAKE2b-256 | 470aa21efa42795a9a2bacd351bd34a04f64c420854a307fe7ebe878af1ab6ff |
Close
Hashes for rtmidi2-1.2.1-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9611f70fae6017b3d8646a435b38b060e3d4acd5b6f09ce7dc612817b2bf7151 |
|
MD5 | a86c0ddbd43f79f35befe95eb8f54ea9 |
|
BLAKE2b-256 | d2465d850ad445aa9a7f49dcae20cbef4497e18d5f3cbf464a7f9088a4451bd6 |
Close
Hashes for rtmidi2-1.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5d19419334d011048286156a319da53de4ecdf24febdc4eeaf4c31ac5d9ad6e |
|
MD5 | e3cd5e4a74c598e03b3b88e22f6d04ea |
|
BLAKE2b-256 | e1786b65d26070e53ed55c89a339d036eed95497649fac76806ab2e6f7234a61 |
Close
Hashes for rtmidi2-1.2.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42c4dcb8207ee886bf92340055db469e1797115471b48528d2298f0c017b4220 |
|
MD5 | b3a7a31b3dcbdc623cf4f50b582773b4 |
|
BLAKE2b-256 | eef99611f3c82849a0e760db704da33346b1b5caa2086b882a16b6e5326a33a5 |
Close
Hashes for rtmidi2-1.2.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 313dff2b7eddddb8992e44a2d6a1fb41efbb7b76254ecf4cb55f162954c25cab |
|
MD5 | eed096fa624c6db49c56971ff50b04a2 |
|
BLAKE2b-256 | 810acbbe57adf64d8ec37c3be682063c4ede865cd66cb925f78a270f3792fac5 |