Framework for scripting MIDI, keyboard and Open Sound Control input and output
Project description
MIDI Scripter
MIDI Scripter is a framework for scripting MIDI, keyboard and Open Sound Control (OSC) input and output with a few lines of Python code.
MIDI Scripter is intended for digital audio workstation (DAW) controls scripting but can also be used for general input conversion and automation. It fits where controller mappings are not enough but rewriting DAW controller integration is too much.
An octave transposer with GUI controls in 10 lines of code:
from midiscripter import * # safe * import with no bloat
midi_keyboard = MidiIn('Port name') # GUI will provide you with port names
proxy_output = MidiOut('loopMIDI Port') # using loopMIDI virtual port for output
# GUI control in a single line, many widget available, custom widgets supported
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
Scripting guide and API documentation available
Easy tasks for MIDI Scripter:
- Filter, modify and route MIDI, OSC and keyboard messages in any way.
- Map MIDI, OSC and keyboard to each other.
- Map any Python code to input message.
- Make extra "shift" keys to multiply MIDI controls.
- Organize mappings into sets / scenes with GUI controls.
- Make an extra overlay mappings on top of MIDI controller's default DAW integration by using proxy.
Complex tasks for MIDI Scripter:
- Create and map complex macros involving multiple hardware or virtual MIDI controllers.
- Make custom sequencer or MIDI input generator.
- Make music education ot trainer GUI application based on MIDI input.
Currently MIDI Scripter is at "beta" development stage. It's fully functional but needs some more testing. It targets only Windows for now but Linux and macOS support will follow.
Installation
- Python 3.11+ with "Add python.exe to PATH" option.
- loopMIDI for virtual MIDI output ports on Windows.
pip install midiscripter
in console.
Setup
Run loopMIDI and add virtual ports you want to send MIDI messages. You can enable its autostart option.
Enable virtual MIDI output ports as MIDI inputs in DAW.
Quick Start
- Paste script template to Python IDE or plain text editor. IDE is greatly recommended.
- Run unchanged template script from IDE or by
python .\script_template.py
to open GUI for more info on available ports and their input. - Turn on the ports' checkboxes to enable them and watch the log for input messages.
- Click on port names and messages to copy their declarations to the clipboard. Paste the declarations to your script.
- Write the functions you need. Subscribe them to messages with
@input_port.subscribe
decorator. Uselog('messages')
for debugging. Useoutput_port.send(msg)
to send modified or created messages from a function. - Restart the script from GUI.
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
Hashes for midiscripter-0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1942094a061f36d6b467f755e62521ef4f10b8b8c98db5f641fe4f1b8f1bb9f2 |
|
MD5 | 239bd92da77b099c3c2071b96bdfba59 |
|
BLAKE2b-256 | 20b9cf687af8f0e2682f2e4cf1c0ff0f5ff0e81c78d79de777be37d19a7ad24d |