Skip to main content

Framework for scripting MIDI, Open Sound Control, keyboard and mouse input and output

Project description

MIDI Scripter

PyPI - Python Version GitHub License For

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.

MIDI Scripter listens to input ports and sends incoming messages to subscribed callables such as functions or methods. These callables, along with other Python code, can send modified or new 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 only octave_selector widget enabled

Screenshot with service Ports and Log and Message Sender widgets:

Screenshot with all the widgets visible

The average latency for the script above is less than 0.25 milliseconds.

Currently, MIDI Scripter is at "beta" development stage. It is fully functional but needs more user feedback.

Use cases

  • 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.

Examples

Documentation

MIDI Scripter has fully documented and type hinted API.
Overview and API documentation is available here.

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 MIDI port support.

Quick Start Guide

  1. Paste the script template into your Python IDE or a plain text editor. Using IDE is recommended.
  2. 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.
  3. 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.
  4. 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.
  5. Rewrite 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 new callables to input messages using the @input_port.subscribe decorator.

License

MIDI Scripter assets and code is under LGPL 3.0 license.
The code that use it can have any license.

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.8.1.tar.gz (94.5 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.8.1-py3-none-any.whl (116.8 kB view details)

Uploaded Python 3

File details

Details for the file midiscripter-0.8.1.tar.gz.

File metadata

  • Download URL: midiscripter-0.8.1.tar.gz
  • Upload date:
  • Size: 94.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for midiscripter-0.8.1.tar.gz
Algorithm Hash digest
SHA256 8c8911b5e0d2be163b40101c5c002e08969903134c0e8d9ca9bbdaf4bfc9b958
MD5 504f4a59182f5bba090a4e437fcbda33
BLAKE2b-256 3ea49ec363bc8be7d08f8fc65025022b0d9a4d98204aa177d9a0da26d55009b8

See more details on using hashes here.

Provenance

The following attestation bundles were made for midiscripter-0.8.1.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.8.1-py3-none-any.whl.

File metadata

  • Download URL: midiscripter-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 116.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for midiscripter-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 faa76f6f3a90e2c11f679f17538053db2b4d4a170954ce5efcca14d1f91c1212
MD5 fc68a8a20bffede7c1973e9cc8b0b580
BLAKE2b-256 98c2c18ddc91cc15ac68909361b43b627906d44d96779f7daf79438073bf65b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for midiscripter-0.8.1-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