MIDIToolkit
Enhanced MIDI manipulation library with immutable, chainable operations built on the classic MIDI.py module by Peter Billam
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
MIDIFileinstance. - Typed event wrappers —
NoteEvent,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:
MIDI.py— classic MIDI parserMIDIToolkit.py— enhanced toolkit
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
Metadata
Release files for MIDIpyToolkit 26.3.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| midipytoolkit-26.3.7.tar.gz | 37.3 kB | Without provenance | Details for midipytoolkit-26.3.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| midipytoolkit-26.3.7-py3-none-any.whl | Python 3 | none | any | Details for midipytoolkit-26.3.7-py3-none-any.whl |
Total release size: 77.7 kB
Release files / midipytoolkit-26.3.7.tar.gz
| Download URL | midipytoolkit-26.3.7.tar.gz |
|---|---|
| Size | 37.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d92143c8cb33757529ca670a1568a498cd9318dd0bd6b44f99cc7a53466d6cd6
|
|
BLAKE2b-256 checksum How to use checksums |
c0a43ec3fec296fc72c9f4e410aac6675d7af7e51494ee2fc00a896cfdd890b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Release files / midipytoolkit-26.3.7-py3-none-any.whl
| Download URL | midipytoolkit-26.3.7-py3-none-any.whl |
|---|---|
| Size | 40.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d6b1f07e4efaffec1be8d59daa4abd0f9f0e52ae3064e7b6cc1845dfe34295b0
|
|
BLAKE2b-256 checksum How to use checksums |
4851a794d2d75b44382da928f1e931f65248829026eb9c49d39a66f2b4f03610
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.5
|
Security for MIDIpyToolkit 26.3.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.