Skip to main content

Enhanced MIDI manipulation library with immutable, chainable operations built on the classic MIDI.py module by Peter Billam

Project description

MIDIToolkit

Enhanced MIDI manipulation library with immutable, chainable operations built on the classic MIDI.py module by Peter Billam

Copilot_20260302_161630

MIDIToolkit provides a high‑level, Pythonic interface for reading, transforming, and writing MIDI files. It wraps the classic MIDI.py parser with a modern layer of immutable objects, event wrappers, track abstractions, tempo mapping utilities, and a plugin system designed for expressive, safe, and reusable MIDI processing workflows.


Key Features

  • Immutable, chainable operations — Every transformation returns a new MIDIFile instance.
  • Typed event wrappersNoteEvent, TempoEvent, PatchChangeEvent, ControlChangeEvent, KeySignatureEvent, and more.
  • Track abstraction — Filter, map, sort, copy, and inspect metadata such as duration, pitch range, and channels used.
  • TempoMap utilities — Convert between ticks, milliseconds, and beats with full support for tempo changes.
  • Plugin system — Extend functionality with custom plugins; includes a registry for discovery and invocation.
  • Comprehensive transformations — Transpose, scale velocities, quantize, segment, time‑shift, merge, mix, concatenate, and grep channels.
  • Analysis & reporting — Statistics, instrument lookup, key signature lookup, text events, validation, and human‑readable summaries.
  • Flexible I/O — Load from file, bytes, opus list, or score list; save to disk or memory.
  • Lazy loading — Delay file parsing until data is accessed.
  • Playback — Cross‑platform MIDI playback using available system tools.

Installation

MIDIToolkit requires only Python 3

Install via pip:

!pip install midipytoolkit

Or download the two core files and place them in your project directory or Python path:

Or clone the repository:

git clone https://github.com/asigalov61/MIDIToolkit.git
cd MIDIToolkit

Import the toolkit:

from MIDIToolkit import MIDIFile

Quick Start

from MIDIToolkit import MIDIFile

# Load a MIDI file (lazy loading by default)
midi = MIDIFile("example.mid")

# Inspect basic properties
print(midi.ticks_per_quarter)   # e.g. 480
print(midi.num_tracks)          # number of tracks

# Get all notes
notes = midi.get_notes()
print(f"Total notes: {len(notes)}")

# Transpose all notes up by 2 semitones
transposed = midi.transpose(2)

# Save the result
transposed.save("transposed.mid")

Documentation & Examples

A complete reference with runnable examples is available in
EXAMPLES.md.

Topics include:

  • Loading and inspecting MIDI files
  • Event wrappers
  • Track manipulation
  • Tempo map conversions
  • Note transformations
  • Track‑level operations
  • Merging, mixing, concatenation
  • Segmentation and time shifting
  • Analysis and metadata
  • Plugin system
  • Validation and reporting
  • Playback and saving
  • Working from memory
  • Context manager and lazy loading

Project Structure

MIDIToolkit/
├── MIDI.py           # Classic low-level MIDI parser
├── MIDIToolkit.py    # Enhanced toolkit (main library)
├── EXAMPLES.md       # Comprehensive usage examples
└── README.md         # This file

Attribution and acknowledgements

  • MIDIToolkit class was passinatelly vibe-coded together with Microsoft Copilot and DeepSeek AI
  • README.md and EXAMPLES.md were co-written using Microsoft Copilot and DeepSeek AI
  • Artwork was created with Microsoft Copilot
  • Original MIDI.py module is a courtesy of Peter Billam

License

This project is open source. The original MIDI.py module is by Peter Billam and contributors; enhancements are provided under the same spirit of free use. See source files for individual notices.


Project Los Angeles

Tegridy Code 2026

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

midipytoolkit-26.3.3.tar.gz (37.1 kB view details)

Uploaded Source

Built Distribution

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

midipytoolkit-26.3.3-py3-none-any.whl (40.1 kB view details)

Uploaded Python 3

File details

Details for the file midipytoolkit-26.3.3.tar.gz.

File metadata

  • Download URL: midipytoolkit-26.3.3.tar.gz
  • Upload date:
  • Size: 37.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for midipytoolkit-26.3.3.tar.gz
Algorithm Hash digest
SHA256 693bc1dfbe2f9043e1a7c272223bf7f1adea10fc5e03717fc88f86f73147e886
MD5 6fadc269a01c3921a938cacc2bbd724a
BLAKE2b-256 9de7de28058339353d0e2dd8c0e45c98f6cc2d00474ed2049ac43fbb33fd3858

See more details on using hashes here.

File details

Details for the file midipytoolkit-26.3.3-py3-none-any.whl.

File metadata

  • Download URL: midipytoolkit-26.3.3-py3-none-any.whl
  • Upload date:
  • Size: 40.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for midipytoolkit-26.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c91d95984fc9ca8d9db60a803e2d91c529437b2902a563c11630c168090a4816
MD5 3e4b07f7297db5fcdc173acd6ff4ba90
BLAKE2b-256 8b953f2286870b18e9fbdc9d91d6955b850f697a629bb2a7e71f5ad403e2f950

See more details on using hashes here.

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