Framework for scripting MIDI, Open Sound Control, keyboard and mouse input and output
Project description
MIDI Scripter
MIDI Scripter is a framework for filtering, modifying, routing and any other scripting of MIDI, Open Sound Control (OSC), keyboard and mouse input and output with Python.
MIDI Scripter monitors input ports and processes incoming messages by sending them to subscribed callables such as functions or methods. These callables, along with any other Python code, can send out modified or newly created messages through output ports. Essentially, MIDI Scripter serves as a proxy that can filter, transform, and convert incoming data.
In addition, MIDI Scripter features a customizable graphical user interface (GUI) that provides message logging, coding assistance, and various controls and indicators to use in the script.
An octave transposer with GUI controls in 10 lines of code:
from midiscripter import *
midi_keyboard = MidiIn('MIDI Keyboard') # GUI will provide you with port names
proxy_output = MidiOut('To DAW', virtual=True) # virtual proxy port for output
# GUI control in a single line
octave_selector = GuiButtonSelectorH(('-2', '-1', '0', '+1', '+2'), select='0')
@midi_keyboard.subscribe # decorated function will receive port's messages
def transpose(msg: MidiMsg) -> None:
if msg.type == MidiType.NOTE_ON or msg.type == MidiType.NOTE_OFF: # filter
msg.data1 += 12 * int(octave_selector.selected_item_text) # modify
proxy_output.send(msg) # route
if __name__ == '__main__': # combine multiple scripts by importing them
start_gui() # opens helpful customizable GUI
The average measured roundtrip latency for the script above is less than 0.25 milliseconds.
Currently MIDI Scripter is at "beta" development stage. It's fully functional but needs more user feedback. It works on Windows and Linux and should work on macOS.
Documentation and Examples
Overview and full API documentation is available here.
You can find more examples here.
Features
Basic Functionality:
- Create proxy MIDI ports.
- Receive input messages from MIDI, OSC, keyboard and mouse.
- Filter, modify and manipulate messages using Python.
- Send modified or generated MIDI, OSC, keyboard, and mouse messages.
For Music Performance MIDI Setups:
- Create additional banks and layers to enhance MIDI controllers.
- Organize mappings into sets or scenes using with GUI dashboard.
- Add overlay mappings on top of your MIDI controller’s DAW integration using proxy ports.
- Combine multiple MIDI controllers into a single unit with any logic.
- Control Ableton Live through a special remote script or AbletonOSC.
For Software Control and Automation:
- Map or convert messages on specific conditions and logic.
- Use MIDI controllers or keyboard shortcuts to run any Python code.
- Implement keyboard and mouse macros.
For Writing MIDI-Related Python Code:
- Prepare MIDI, OSC, keyboard, and mouse inputs and outputs with a single line of code, without boilerplate.
- Use decorators to feed input messages to functions or other callables.
- Work with message objects rather than raw data, which varies by port type.
- Create GUI widgets with just one line of code and arrange them with mouse.
- Fully type-annotated API for better code clarity.
Installation
- Install Python 3.11+ including pip.
- Run
pip install midiscripter.
Extra steps for Windows:
- Enable
Add python .exe to PATHoption in Python installer. - Install loopMIDI for virtual ports support.
Quick Start Guide
- Paste the script template into your Python IDE or a plain text editor. Using an IDE is recommended.
- Run the template script directly from the IDE or by
python your_script.py. This will open the GUI (as shown in the screenshot below), providing information about available ports and incoming input. - Ensure that the “Show Unused Ports” button located under the port list is activated. Enable the checkboxes for any available ports to activate them, monitor the log for incoming messages.
- Click on the port names and messages in the log to copy their declarations to the clipboard. You can paste the declarations into your script.
- Adjust the template function to achieve desired functionality. Use
log('messages')for debugging purposes. - Restart the script from the GUI to see how it performs.
- Develop more complex scripts by utilizing additional inputs, outputs and functions (callables). Subscribe callables to input messages using the
@input_port.subscribedecorator.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file midiscripter-0.7.tar.gz.
File metadata
- Download URL: midiscripter-0.7.tar.gz
- Upload date:
- Size: 89.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc0ef218eac333e480269363757979030486267f126946ec7d34f2288f503252
|
|
| MD5 |
2670c86d961e554643cfd6e053365e77
|
|
| BLAKE2b-256 |
124a3f8fa18cca6729f4c3959837459dd00673454f5cce4d455795c5d178e849
|
Provenance
The following attestation bundles were made for midiscripter-0.7.tar.gz:
Publisher:
publish-to-pypi.yml on Maboroshy/midi-scripter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
midiscripter-0.7.tar.gz -
Subject digest:
fc0ef218eac333e480269363757979030486267f126946ec7d34f2288f503252 - Sigstore transparency entry: 255584576
- Sigstore integration time:
-
Permalink:
Maboroshy/midi-scripter@e5ccf71d0656470e0a6e7c7b29f31394937419c7 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/Maboroshy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@e5ccf71d0656470e0a6e7c7b29f31394937419c7 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file midiscripter-0.7-py3-none-any.whl.
File metadata
- Download URL: midiscripter-0.7-py3-none-any.whl
- Upload date:
- Size: 109.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c44b1fc2b4aa317ea223b34d66307bc152e242e1ec522460ecb94a5b3ac6492
|
|
| MD5 |
241427ad8dade04bec94b62c944d59e5
|
|
| BLAKE2b-256 |
e21f34c14c0e3358083afb3719fb0b6b5e4e6459ae3a04a640c7345a9d076ebc
|
Provenance
The following attestation bundles were made for midiscripter-0.7-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on Maboroshy/midi-scripter
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
midiscripter-0.7-py3-none-any.whl -
Subject digest:
7c44b1fc2b4aa317ea223b34d66307bc152e242e1ec522460ecb94a5b3ac6492 - Sigstore transparency entry: 255584577
- Sigstore integration time:
-
Permalink:
Maboroshy/midi-scripter@e5ccf71d0656470e0a6e7c7b29f31394937419c7 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/Maboroshy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@e5ccf71d0656470e0a6e7c7b29f31394937419c7 -
Trigger Event:
workflow_dispatch
-
Statement type: