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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distributions
rtmidi2-0.9.4-cp310-cp310-win32.whl
(104.9 kB
view hashes)
rtmidi2-0.9.4-cp39-cp39-win_amd64.whl
(117.7 kB
view hashes)
rtmidi2-0.9.4-cp39-cp39-win32.whl
(104.8 kB
view hashes)
rtmidi2-0.9.4-cp38-cp38-win_amd64.whl
(117.8 kB
view hashes)
rtmidi2-0.9.4-cp38-cp38-win32.whl
(104.7 kB
view hashes)
Close
Hashes for rtmidi2-0.9.4-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1864dfd8f25bdfd3b9e3386eb85b466b6fa5c66a43569f975f556cbd5bcd9cb0 |
|
MD5 | b0eb1c659bebdf030745989579e6aef3 |
|
BLAKE2b-256 | 9d969c5cdb5a6ceb299ae6d045903f03dc32f5203a5daca3920c1be04369c6a3 |
Close
Hashes for rtmidi2-0.9.4-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 913f854f04608a968b3969ba3864a0bbd63c88b3eb1e42d5d2004cd827dbac82 |
|
MD5 | 44026473bc63790e1aff78101b9820bf |
|
BLAKE2b-256 | d2c369fdd07e45bee1645a903d8a4fa20e2ed5981aab14e41300ddc05ccd6e06 |
Close
Hashes for rtmidi2-0.9.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21d25a5bb2fa5b37b5b491521c084b635388d6b20a4396bc2f3ca0583bba1649 |
|
MD5 | b0e12062b3fb28876ceba555a98c5c68 |
|
BLAKE2b-256 | 19fcadb6f2653d5d77af0dc62f2379a388a3f70933eb386e7b1771ca46a08fd0 |
Close
Hashes for rtmidi2-0.9.4-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01b61fa0f6b26a3d3a90e577cea7a17f705a95622e05e3b5a7320e9fa8e5a43e |
|
MD5 | 1f89e27eb1174cc771de18dfb34b7fa1 |
|
BLAKE2b-256 | c16283dfe058e6b3a3598b8e066a4977ce19d27183602b83d6ec7d79cae19be8 |
Close
Hashes for rtmidi2-0.9.4-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b151772b5f3a3c34785cbbd45844c858217dd14977844a59d152264287c8ff8d |
|
MD5 | 77652c51673a19bd9b03c9eb1cbcbb08 |
|
BLAKE2b-256 | 42800020e10e81f332d2905cb43c11544a75ad22d3f3a7a327d3a9d8b1d7fe89 |
Close
Hashes for rtmidi2-0.9.4-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c66a5cb778a1cbd9a8734808ca16243a05a2893efd817a3fd15b8efad97a1e2b |
|
MD5 | 2a744923ffeaa788c17d7fa1b288028e |
|
BLAKE2b-256 | 6f61b9cc20527696a8905c99bee703a0377304704aea2cc1b232e55ef9f2524f |
Close
Hashes for rtmidi2-0.9.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b702c9fdb4d1c7407a191e7ec8f601881da0d71dbfe6b83b8098e89ff7652d2c |
|
MD5 | 29c543ae2839aa7c69951af11abfacd6 |
|
BLAKE2b-256 | 51285df69582ed9613a266b1cbce0b13f1f8297d085c5e6124e9f948f96ef116 |
Close
Hashes for rtmidi2-0.9.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f7c64cc1533c0e58b3c748afb5fb89bcb50b3a953708e80b44b2900ac37a5e5 |
|
MD5 | 15ed5bc46c74dbcb3fcb238c68b711e1 |
|
BLAKE2b-256 | 0043bf5deb54bd25c0a2e5a4fb0440a677dc0c52d3bd6525ab86eea733d9d677 |
Close
Hashes for rtmidi2-0.9.4-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75eb98b25cd608af134f24907af396f6044eec28baea9ed1c5953d6464e427d5 |
|
MD5 | 4cf689e9dfe0259a56be5bafe7e5b90b |
|
BLAKE2b-256 | e9d709fe8eedbef087a90a21679f97fa8177ca05629176743bbe7abed6a8db66 |
Close
Hashes for rtmidi2-0.9.4-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63542e044af62f59e9488c3fab95248ad495fc921219de3524ae9c7aa45d9f53 |
|
MD5 | 4f0af77712dc2b1073ed18bcc7a9572c |
|
BLAKE2b-256 | 316b70d448ab6cb514fc658dc00b0b8cf90398e84cfe342ca720c550e29e4304 |
Close
Hashes for rtmidi2-0.9.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a20d6255d7e13cbc81a212d57a7b5364ea74c25b784a36bbddcab94148bda55 |
|
MD5 | 91ed8b625f5fe87e6028f12167d65eed |
|
BLAKE2b-256 | 443a316cfa5e78ac96ecf854379e5da3b19a16febcada747519b5172f9243e05 |
Close
Hashes for rtmidi2-0.9.4-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44653557f9e732aa9b114661f05fce08ee0f6a064546b7a97a256162438cd331 |
|
MD5 | 186de0eb585c06aa9922dfa65ee93cf5 |
|
BLAKE2b-256 | 327948f9f18987115af53c9a3e4afd7560842463028afc675507dfa24dd8b824 |