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.1.2.tar.gz
(183.1 kB
view hashes)
Built Distributions
rtmidi2-1.1.2-cp311-cp311-win32.whl
(102.5 kB
view hashes)
rtmidi2-1.1.2-cp310-cp310-win32.whl
(103.4 kB
view hashes)
rtmidi2-1.1.2-cp39-cp39-win_amd64.whl
(119.3 kB
view hashes)
rtmidi2-1.1.2-cp39-cp39-win32.whl
(105.7 kB
view hashes)
Close
Hashes for rtmidi2-1.1.2-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ef3ccbb3829cc0759fdfa6934bf65375aa3e967907346e3d11da8e31db4613b |
|
MD5 | e587a8c010ad4ed8f1d6b0e08ee9db7a |
|
BLAKE2b-256 | 38bc64a6137c4af379b42c2e0abe750183b401863adfefa167cd35ae2d6187a1 |
Close
Hashes for rtmidi2-1.1.2-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b117c24c9027b465873280eb66b3bcdb4db39fe29bdf8bd8fd6cfd3ad1e8389 |
|
MD5 | 0662f5402356b613bd4b93a1caccde1b |
|
BLAKE2b-256 | e6987b306fccbaf7dcbc0da30854b436e6249884e5ce55e4140c17b8431d3980 |
Close
Hashes for rtmidi2-1.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63f6e9bfe179357057b18827128eb78a6ba09307b94b9e5fbfcee059979061df |
|
MD5 | b60010f2c82a066ccb13773ae329566c |
|
BLAKE2b-256 | 71d0bddaee13eaf20a76c690e03ad28768448f15b3c88aedcf851ac9997683c3 |
Close
Hashes for rtmidi2-1.1.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fad80a836d05cfcaee41e1297aae86cf8990bc46d94d9227a5518cfbe0e3cdde |
|
MD5 | ecd451b70d0da662f78fcde038d26280 |
|
BLAKE2b-256 | 1fcf15b551bace89c6e90e72444a5c953987c146bbdc01df1706f6d782c49b3e |
Close
Hashes for rtmidi2-1.1.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1418fbff92401ee4a572ad665d74b2befb37ffa1793375ca553ec6dc557dd016 |
|
MD5 | ee32ab97661634a3155e46d4d0930bc4 |
|
BLAKE2b-256 | 2a07e2f49eada9d4ddeca925cf05e91ca7172604820875aee3d3cd68137f7dcb |
Close
Hashes for rtmidi2-1.1.2-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4d116edec597e4a58afce6ae63341efe06439b1fac4735c54f960e262980488 |
|
MD5 | e563eecc5850199d22412815935f4e54 |
|
BLAKE2b-256 | f50d87aa01b9dbe2068499151e560167dc1f72cc09bb76c8b8f4109d8b85ed60 |
Close
Hashes for rtmidi2-1.1.2-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d62cf16e0821120e1896d265250979632ce21fa3182d5f9594dc894c94c99223 |
|
MD5 | 73633e5258ceaf9f11173b195b2f3eb5 |
|
BLAKE2b-256 | 80520fd491dd5f0f94c7ca8249b2640ef0d489a70f56eb83af148dda249fd816 |
Close
Hashes for rtmidi2-1.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b678fddcd51918728210bea42c0f66e4230fa324907bec1605122b51c5af4026 |
|
MD5 | e83a20a258a2fe578f237ca4c5fd0f4b |
|
BLAKE2b-256 | 30ff3d3b5ac920107b8b6191ed17959635a2c93c112a25ba387fd155d88c9cec |
Close
Hashes for rtmidi2-1.1.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 190a923128eb245e5f50a37ebd218dbe4182a22c2e8b55cd3f78cf3b3c4da0bc |
|
MD5 | 2c22b5296057e46fd7e5f5eda593eea5 |
|
BLAKE2b-256 | b64c9bb6b5c33674681d6f4a03b38793e6185b204959ca02715f0f3d414d4735 |
Close
Hashes for rtmidi2-1.1.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08cc9531fed4d08b61dc7ee1f73006487c60b383e7828bca0ee705875cad5455 |
|
MD5 | 025876fc10126f1a9d9e00b86ba8c05c |
|
BLAKE2b-256 | 1aeff34c67837ba00aa67808d8dbe04afc567548c48904fd2969b7f05e8ff918 |
Close
Hashes for rtmidi2-1.1.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4153b241a131a229093fd70cbb5ce0a210789688c8dbf8258da2e3245dd8f667 |
|
MD5 | 50da0164c7e51411b6492b9867de2905 |
|
BLAKE2b-256 | e74dc8f9fbbe4086d77f580441bc0abe26b5d20903ca7338f92ac8142ae67c34 |
Close
Hashes for rtmidi2-1.1.2-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91bccef7c929af3f9ccc0728b39877c8ef71e197f8b0387aa1324322e3a323d3 |
|
MD5 | a175843d0d439f93eee1ed222e7f61ac |
|
BLAKE2b-256 | 6bb1ca07970903482cf23f8ae9b29b787bfd7918b25b2d557d3d934dcab6321e |
Close
Hashes for rtmidi2-1.1.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b809688fb90bcea92ad8912d6a9e78bfd1625b3519ec5e6116ceae3d33eaf1ab |
|
MD5 | 73a7da05cf43b5ae982d01911d33e7e1 |
|
BLAKE2b-256 | beb3524847ba64b102bf10efe5d57669a241eec7105a3d301552c8686200ca55 |
Close
Hashes for rtmidi2-1.1.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c41914ffb0f953ab38034f12b13ee8fc8f75da792c5f4e2d494c681b3c848e01 |
|
MD5 | 4779bddafedecb203e0c1cb9d8b1c63c |
|
BLAKE2b-256 | 31833cd0bca4e011b698acf37668a4991fa03e4258c2b04f06405b6bc87efa25 |
Close
Hashes for rtmidi2-1.1.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 691cf89b236682e942b4ec55dec66451c4683697da62f110c9e7202e6b917de7 |
|
MD5 | 4ad933dc4d6195d48331417bcf7454e3 |
|
BLAKE2b-256 | 00188bc12dd76cab5b9959da8d4b4867966ff7a873e2da856434600e32e4c08e |