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, uses rtmidi version 6.0
Installation
pip install rtmidi2
This module is compatible with Python 3 >= 3.9
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.4.0.tar.gz
(227.6 kB
view hashes)
Built Distributions
rtmidi2-1.4.0-cp312-cp312-win32.whl
(114.0 kB
view hashes)
rtmidi2-1.4.0-cp311-cp311-win32.whl
(115.5 kB
view hashes)
rtmidi2-1.4.0-cp310-cp310-win32.whl
(116.2 kB
view hashes)
rtmidi2-1.4.0-cp39-cp39-win_amd64.whl
(128.1 kB
view hashes)
rtmidi2-1.4.0-cp39-cp39-win32.whl
(116.3 kB
view hashes)
Close
Hashes for rtmidi2-1.4.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba7d1bb0216a1d9db0df4dd23bcbc154994325581b88747e8f6bd15f424e548a |
|
MD5 | ec01908c2c8afb9cd8f41cc4c363df78 |
|
BLAKE2b-256 | e0cfbe6886fcb5b09ad70cdeddbfddd62882a46dafea8eed30259a793728cd54 |
Close
Hashes for rtmidi2-1.4.0-cp312-cp312-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca7826d75298335fbb3746f5284f0678ce32deb2dc0ce1febbef1ec879e8af54 |
|
MD5 | 66a967a6df77c782286dbaeb3b306b48 |
|
BLAKE2b-256 | 00aef81d67a7385a5a1118846e00ec42284f13375c7973d5420a910d099b4667 |
Close
Hashes for rtmidi2-1.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02e01c14a32d85f5c182305c0ec6ab39c683ecf097d0dbeee3fde992efa87e99 |
|
MD5 | 5129cf430866925f9d94ddf5b2d969a8 |
|
BLAKE2b-256 | 97762932c4e77b26cee56df601dfcf489c402cd444293a5581b0a83bd1aeabe9 |
Close
Hashes for rtmidi2-1.4.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 461b452e1c3c6b7ec85838c7c4ea523403938d10b7a757141fa293aecbcfa07b |
|
MD5 | fbbcf303ddd4d63fe26a0c03eb4332f2 |
|
BLAKE2b-256 | 275a9ab632df0f1f82ae7f642aa6088d3d98611682e2cc6bc9c5964d725f9388 |
Close
Hashes for rtmidi2-1.4.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9d7185c795853a0925d3b1e62c7f8dd4c5414b9b00fa6bfe0c8ba2858b777cd |
|
MD5 | e1fbbf43b3bb17c56d3aadf5af1678ea |
|
BLAKE2b-256 | d03502662dde3384a65126416a7fd6b3fdba033380584af3cc97af8536e8c4f5 |
Close
Hashes for rtmidi2-1.4.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf43184aac9dce54ccb4db06ff6305ab7467f31aa8bc905bca51bf96b3e3162b |
|
MD5 | c7bf33c06aedab2cde733869c91bc414 |
|
BLAKE2b-256 | 6e92eb586d901c9134360f3fb23627ec0d1e40caacbdab6238b19e37552c0f84 |
Close
Hashes for rtmidi2-1.4.0-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8307655414bc393aca5e64a0573e37e8a68958857a5c71356550f1df961003f |
|
MD5 | e1f58acd888be5c1e0b6199e44495132 |
|
BLAKE2b-256 | 9d2222238a31e5bfb781dc8ee18b3b9415b778cc121401f1504c69eccd841adf |
Close
Hashes for rtmidi2-1.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d70168328435dc39ce632cd213b7866d3a128106c6c239f2bff66dda9dd33c1 |
|
MD5 | 25c1d43ede59623c73792ed8bc8496ce |
|
BLAKE2b-256 | f056d5ac7fd6230ed854e8f77f8a614f6cf671a072ab2a90ecfbffe1d8a3dbc6 |
Close
Hashes for rtmidi2-1.4.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68f6d6ea68df04849ed761d781097e1693c8e7eaef715cf8a616667712d8dad7 |
|
MD5 | 1e34d80cf7c5cc1af669e72526df6dcc |
|
BLAKE2b-256 | ac6207d1ec553944dceea6fcefdfd753a2de86230f8b6e69003c2e361a3ec570 |
Close
Hashes for rtmidi2-1.4.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50351d526bda2332a0a6a169cefabfdce4949921cd3cbd2f15fff5e632a46d43 |
|
MD5 | 6023965d0327675a0fda1029ca3c8d43 |
|
BLAKE2b-256 | 464c44aaa9cd99a7fd0b4340e6681a1bafff767e9efb230893c4f8b6134585bd |
Close
Hashes for rtmidi2-1.4.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae052b911b62d0166d984a9ad37e8b27e38cf9d371023a65368e6ebcacd9a32e |
|
MD5 | 85dab670d82a05d29bca0d746192da1a |
|
BLAKE2b-256 | 72f7a94deead495952a4018f9870737a772e96db65e1e55f3e7cdfa65eba325b |
Close
Hashes for rtmidi2-1.4.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22446edff7c4b3a8618caf99593f847d90619866a66cabc0e7fa6c9a438d519c |
|
MD5 | bcffbd1cb3470ce64b37bc3cd142e9f1 |
|
BLAKE2b-256 | a066870bf59df2b3eeaf40697aab12c466a7a1d1183bdd90e2dfeffe7baad30c |
Close
Hashes for rtmidi2-1.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48a8a8e27f29daf81030326a62c9daaeed9a372665fe95765011357017f8d7df |
|
MD5 | b79530e2ec7b4390bd6bb9187acfa321 |
|
BLAKE2b-256 | d1cdb542ea14d7f4dc797f570d01a9bb9cbad40c520870016362043c1e99a14c |
Close
Hashes for rtmidi2-1.4.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d0aa7a5692f8ad03391b1360003ba8c6375c4aa9b130b73c1848a3fe69ecf12 |
|
MD5 | ca3e483176bb84fd0402f52af2cc1233 |
|
BLAKE2b-256 | 7a8c63e321c875c943bbe598ca12457698a1b91c137fd20bf768a2f56799dbae |
Close
Hashes for rtmidi2-1.4.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95ec2f2d48e8ea0c37bd31c3125738989b14999de62203c0dd52efecb00387e5 |
|
MD5 | e7e4f7d516db6b215b1af252fcfebe36 |
|
BLAKE2b-256 | d7508ab4be502750652f24c045584e15c3725feb00fffa47eb60a5e61a5a42e6 |
Close
Hashes for rtmidi2-1.4.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 749580d935326f75a7041d15fd74baaa358f2ca7939842b332f6c3532c1c8cf5 |
|
MD5 | bb6dc222ceb7e4d853f82edac5b50c08 |
|
BLAKE2b-256 | f3a119694bfbf04c3e6a1f9f4d01248667180969259e58798733c1fac1ce17ab |
Close
Hashes for rtmidi2-1.4.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 871723166f5f47ffde084666b13138b6c673b0d95fb277083f5b2c6857cd8d7f |
|
MD5 | 9da2022421ffffd3055ff411a09ce0d0 |
|
BLAKE2b-256 | cfcf673a1b6ebcb905520cb40684f8a0b6fcc8ef68458d38fdb24a795c381902 |
Close
Hashes for rtmidi2-1.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e7dedd4aa09e06e3b0b881f705aacf7051144c4aa2de7b17fcaa5d0c44291de |
|
MD5 | 85f54e753a90954a1d455d87dd9f3cdc |
|
BLAKE2b-256 | 90ff8ed8c54d0fdd5cca2687c76631eb517d47d4c2a48a3fdb0df80f47b5680e |
Close
Hashes for rtmidi2-1.4.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd9a4cb3479e210d0ff07a12558c255dd0d86ac80f9d6ad79e4d0b2b4d15d9bb |
|
MD5 | ff648cbd16bbae223687d869f30ef472 |
|
BLAKE2b-256 | c39bd255586d835a341458e389818e17828251aaa1acb58d657310ea7d961690 |
Close
Hashes for rtmidi2-1.4.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 080969c4a5fa98782f03403056cfa2bc408ce5e0178369c3c7ed083701f5053e |
|
MD5 | ea12fec5a00385c424e3e8346baa50b3 |
|
BLAKE2b-256 | d9875b08e195194e0cdd2f72c53b74bb63b4b834d4a3d772f6933c2d804cbb1f |