MIDI Scripter is a Python framework for filtering, modifying, routing and any other handling of MIDI, Open Sound Control (OSC), keyboard and mouse input and output.
It works on Windows and Linux and should work on macOS.
MIDI Scripter listens input ports and send incoming messages 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. MIDI Scripter can serve as a proxy that filters, transforms, and converts incoming messages.
In addition, MIDI Scripter features a customizable graphical user interface (GUI) that provides logging, coding assistance, various controls and indicators to use in the script.
All that with no boilerplate and only a few lines of code.
An octave transposer with GUI controls in 10 lines of code:
from midiscripter import *
midi_keyboard = MidiIn('MIDI Keyboard') # GUI will provide you the port names
proxy_output = MidiOut('To DAW', virtual=True) # virtual proxy port for output
# GUI widget 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__':
start_gui() # opens helpful customizable GUI
Screenshot with only octave_selector
widget enabled:
Screenshot with service Ports and Log and Message Sender widgets:
The average 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.
- Programming MIDI input/output handling scripts that may also use OSC, keyboard and mouse input/output.
- Mapping your MIDI controller in your own custom way, from simple MIDI message filtering or conversion to mostly anything you can imagine.
- Controlling Ableton Live with Python, without diving into it's complex MIDI remote scripting or Max for Live.
- Add extra banks for the MIDI controllers.
- Launch an app or run any Python code with a MIDI message.
- Show pressed chord description.
- Control Ableton Live with remote script or AbletonOSC.
- Make custom mapping overlay on top of Ableton Live built-in MIDI controller integration.
- Run Python code with Ableton Live clips.
- Save and load global presets for Ableton Live devices.
MIDI Scripter has fully documented and type hinted API.
Overview and API documentation is available here.
- Install Python 3.11+ including pip.
- Run
pip install midiscripter
.
Extra steps for Windows:
- Enable
Add python .exe to PATH
option in Python installer. - Install loopMIDI for virtual MIDI port support.
- Paste the script template into your Python IDE or a plain text editor. Using IDE is recommended.
- Run the template script directly from the IDE or by
python your_script.py
. This will open the GUI, 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 open them. Monitor the log for incoming messages.
- Click on the port names and messages in the log or port list to copy their declarations to the clipboard. You can paste the declarations into your script.
- Rewrite 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 new callables to input messages using the
@input_port.subscribe
decorator.
MIDI Scripter assets and code is under LGPL 3.0 license.
The code that use it can have any license.