Skip to main content

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

Screenshot after some widget arrangement

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

  1. Install Python 3.11+ including pip.
  2. Run pip install midiscripter.

Extra steps for Windows:

  1. Enable Add python .exe to PATH option in Python installer.
  2. Install loopMIDI for virtual ports support.

Quick Start Guide

  1. Paste the script template into your Python IDE or a plain text editor. Using an IDE is recommended.
  2. 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.
  3. 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.
  4. 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.
  5. Adjust the template function to achieve desired functionality. Use log('messages') for debugging purposes.
  6. Restart the script from the GUI to see how it performs.
  7. Develop more complex scripts by utilizing additional inputs, outputs and functions (callables). Subscribe callables to input messages using the @input_port.subscribe decorator.

Screenshot

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

midiscripter-0.7.tar.gz (89.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

midiscripter-0.7-py3-none-any.whl (109.1 kB view details)

Uploaded Python 3

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

Hashes for midiscripter-0.7.tar.gz
Algorithm Hash digest
SHA256 fc0ef218eac333e480269363757979030486267f126946ec7d34f2288f503252
MD5 2670c86d961e554643cfd6e053365e77
BLAKE2b-256 124a3f8fa18cca6729f4c3959837459dd00673454f5cce4d455795c5d178e849

See more details on using hashes here.

Provenance

The following attestation bundles were made for midiscripter-0.7.tar.gz:

Publisher: publish-to-pypi.yml on Maboroshy/midi-scripter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for midiscripter-0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7c44b1fc2b4aa317ea223b34d66307bc152e242e1ec522460ecb94a5b3ac6492
MD5 241427ad8dade04bec94b62c944d59e5
BLAKE2b-256 e21f34c14c0e3358083afb3719fb0b6b5e4e6459ae3a04a640c7345a9d076ebc

See more details on using hashes here.

Provenance

The following attestation bundles were made for midiscripter-0.7-py3-none-any.whl:

Publisher: publish-to-pypi.yml on Maboroshy/midi-scripter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page