Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Python wrapper for RtMidi written in Cython. Allows sending raw messages, multi-port input and sending multiple messages in one call.
|sh-downloads|
.. |sh-downloads| image:: https://static.pepy.tech/badge/rtmidi2
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
pip install rtmidi2
This module is compatible with Python 3 >= 3.9
https://rtmidi2.readthedocs.io
rtmidi2
uses a very similar API as RtMidi
Print all in and out ports
.. code-block:: python
import rtmidi2
print(rtmidi2.get_in_ports())
print(rtmidi2.get_out_ports())
Send messages
~~~~~~~~~~~~~
.. code-block:: python
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
.. code-block:: python
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
.. code-block:: python
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python
# 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:
.. code-block:: python
def callback(src, msg, timestamp):
# src will hold the name of the device
print("got message from", src)
Send multiple notes at once
~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python
# 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`.
.. _RtMidi: http://www.music.mcgill.ca/~gary/rtmidi/
.. _Cython: http://www.cython.org
FAQs
Python wrapper for RtMidi written in Cython. Allows sending raw messages, multi-port input and sending multiple messages in one call.
We found that rtmidi2 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.