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 only a few lines of Python code.
MIDI Scripter listens to selected input ports and feed incoming messages to subscribed callables (functions, methods, etc.). These callables or any other Python code can send modified or brand-new messages with output ports. MIDI Scripter can act as a proxy to filter and transform and convert the input.
MIDI Scripter included customizable GUI that provides messages logging, "ready to paste" port and message declarations and one line of code widgets for monitoring / controlling scripts.
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') # using virtual 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
You can find more examples here.
Scripting guide and API documentation available.
Currently MIDI Scripter is at "beta" development stage. It's fully functional but needs more user feedback. It works on Windows and Linx and should work on macOS.
What it can do
For writing Python code:
- Prepare MIDI, OSC and keyboard inputs and outputs with a single line, without boilerplate code.
- Feed input messages to functions or any callables by "decorating" them.
- Work with common message objects instead of raw data different for each port type.
- Send MIDI, OSC and keyboard output messages.
- Create GUI widgets with one line and arrange them with mouse on your script's dashboard.
For live performance setups:
- Make extra layers to multiply MIDI controls.
- Organize mappings into sets / scenes with GUI dashboard.
- Make an extra overlay mappings on top of MIDI controller's DAW integration by using proxies.
- Create and map complex macros.
For MIDI related apps:
- Make custom sequencers or MIDI output generators.
- Make basic music training GUI applications based on MIDI input.
For software control and automation:
- Use MIDI controllers or keyboard shortcuts to run any Python code.
- Use keyboard macros to control apps.
Installation
- 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 and set required virtual MIDI ports inside it.
Quick Start
- Paste script template to Python IDE or plain text editor. IDE is greatly recommended.
- Run unaltered template script from IDE or by
python
command to open GUI for more info on available ports and their input. - Turn on available 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 input 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 to check how in works.
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.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7dc61bd141755def167301b3e088c2f725acbacf623e9d49a6d9c3f36bcf304d |
|
MD5 | 28a90da924c268f3f368dd5149f6c8d7 |
|
BLAKE2b-256 | 92081830f35e499b61defbda9a1d966e4eb1c4f0714dc5af2e0ce0571bf491b0 |