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
import time
midi_in = rtmidi.MidiIn()
midi_in.open_port(0)
while True:
message = midi_in.get_message()
if message:
print(message, delta_time)
else:
time.sleep(0.01)
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.3.0.tar.gz
(213.3 kB
view hashes)
Built Distributions
rtmidi2-1.3.0-cp311-cp311-win32.whl
(115.4 kB
view hashes)
rtmidi2-1.3.0-cp310-cp310-win32.whl
(115.7 kB
view hashes)
rtmidi2-1.3.0-cp39-cp39-win_amd64.whl
(128.2 kB
view hashes)
rtmidi2-1.3.0-cp39-cp39-win32.whl
(115.9 kB
view hashes)
Close
Hashes for rtmidi2-1.3.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f421f81e8dba1e6d00819adca952e39acb219fc27b3192f1fe0f20ba9107bd1 |
|
MD5 | fb5922727f6506379a449b1165f1758b |
|
BLAKE2b-256 | 8d40134a1ee54b88e347fbb2f10ba6e056bba75ec9ba1e26e4e1f09eea42509a |
Close
Hashes for rtmidi2-1.3.0-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9fa810c13a2f5b39b38973a5b402a714af2ebde23eb1a03eadcb31925b827b5f |
|
MD5 | 12b6b0a2ff7b8bfa2fd5b1994fefc3f6 |
|
BLAKE2b-256 | a4b47b2e3b65af88e4edc0cd2a6b3215817341b13c6ca61e32e37d7def11f46c |
Close
Hashes for rtmidi2-1.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 037573613206e92ceb3a9763348b6515fdd811d00b53cd32a60043780601f05b |
|
MD5 | 9e91c1daa172e5794bae379df13ed3be |
|
BLAKE2b-256 | e36df6027e0438079500d2cdbc9a355590d2cf7031ed96de53d4ba75fa22b664 |
Close
Hashes for rtmidi2-1.3.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2508f1212e68175ea9a2aa7aada4289b45bee3f46be3d2b25766ab0d0e23b3e7 |
|
MD5 | 9ea76e127ae4ce5ff26f5b18d45f6263 |
|
BLAKE2b-256 | a90a13473477fe5e71b8c4c23a563c4376935e5047a2ff42e6e5cf4719b43452 |
Close
Hashes for rtmidi2-1.3.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77146f12bdc2f923761f9323a8be39d435b289f7e7290d7b4c4b60374d89ae3b |
|
MD5 | 008ebbc41ac98dc18019f4310b9169cf |
|
BLAKE2b-256 | 5b2ec35efaf7abd1f70c78558b19d78f7448369b994459d8f6f387984ec65b61 |
Close
Hashes for rtmidi2-1.3.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c557ec81c0ba210fec6ec33af904f7d762f257143ff65a5e6f3c53505d4e19a6 |
|
MD5 | 4a2297759e81b81e38354eef7b8ea949 |
|
BLAKE2b-256 | 9b742f28ec1b3fa98765c87f8535cab7ae68c3f54cc9104754571af8473da15a |
Close
Hashes for rtmidi2-1.3.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fd6b8e96f0aef0dfc9bc9a8fb6b3740853815bb884becea876380414eab6e4f |
|
MD5 | 36edb0ab3d6258a4712e1a48f7e69ec0 |
|
BLAKE2b-256 | a24ebf6462fbffe7c7687a4dbcbcba42a6d7989f5099855ddc7733b3fecfcd2a |
Close
Hashes for rtmidi2-1.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a36d20523a7c1e274ed6aacd67f968e5eee22fe90a4b3e4fe7043a88b3d4b36 |
|
MD5 | 39042eeb40af586a27403ea565068627 |
|
BLAKE2b-256 | 617f0063cad2a3d705a3588763c61933291b73471f8174b673508ebb2b1889df |
Close
Hashes for rtmidi2-1.3.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c32f731fb4bf20ccaede50a06203b989beae6b5fa5676213e34f2702fd33dfb7 |
|
MD5 | 14d2b4ca4d80e20555a996de80803b4c |
|
BLAKE2b-256 | ddec31944626bed05b99c50cd2bb87833b02cca5833a80bd3160ddc48533c9bd |
Close
Hashes for rtmidi2-1.3.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc45b95a432e2162cbe9744a05132fb947578698229dff9c91491473219df7f9 |
|
MD5 | 668ecfefa6ffcc3054281335a8b74ab7 |
|
BLAKE2b-256 | f0b32932f211125da4ce88952c5e98357240cbc68b60f0449ed6586e266de025 |
Close
Hashes for rtmidi2-1.3.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9176f9181a0de6ac3916391a141e403b783412ce82b25788da6a4ca7e10b24e1 |
|
MD5 | 68a54a9c48313046b4ad8e1c7296c03f |
|
BLAKE2b-256 | edcfc6570462abd2044071fbb8f79ce6096544d4abf867c1970935191e9c123f |
Close
Hashes for rtmidi2-1.3.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05b9b1bf3acb3283ec025b42f728ac177123f67c53be62d09cd77239e2d45b61 |
|
MD5 | 8d363a22415c4bef6d68d52ebfa836c9 |
|
BLAKE2b-256 | fad71331506ab9965c9edb59feb608fae5582c98bf8dcdc38c854427d422ed44 |
Close
Hashes for rtmidi2-1.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0d08402e351a18b7428180f978ef85118669ffa7030293ca5f029d242e54845 |
|
MD5 | ed1d2dacaead508747eb6b7765abe276 |
|
BLAKE2b-256 | 78b007cad1f6b693616c0d902a48d54e37663e2a3c0b7bb21367c2bfc557b46a |
Close
Hashes for rtmidi2-1.3.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cc20e267fd1905ca4a6518dc91dafbec73f071519ca61e9224510cc8ad6b377 |
|
MD5 | acb1c6bc3d14925206fdba1ef41b633f |
|
BLAKE2b-256 | 10c813c33788b96d67c5dd356e4335c3ec634be74ba850a06d16aed0442a31dc |
Close
Hashes for rtmidi2-1.3.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1db0e6de47634d3b60ca8f6af5477986e1b7951b6a36df00c6aeb0dbe196638f |
|
MD5 | d6c18230b16a4cde1e85c410d5b5dab3 |
|
BLAKE2b-256 | 3f6fc3c448b30591b59611ade6df356f15b1cc06f7128afa78daa963c6ecd9ad |