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

Uploaded Python 3

File details

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

File metadata

  • Download URL: midipytoolkit-26.3.7.tar.gz
  • Upload date:
  • Size: 37.3 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.7.tar.gz
Algorithm Hash digest
SHA256 d92143c8cb33757529ca670a1568a498cd9318dd0bd6b44f99cc7a53466d6cd6
MD5 f8c5a41257099388977eb1b0c5ded9cd
BLAKE2b-256 c0a43ec3fec296fc72c9f4e410aac6675d7af7e51494ee2fc00a896cfdd890b4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: midipytoolkit-26.3.7-py3-none-any.whl
  • Upload date:
  • Size: 40.4 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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d6b1f07e4efaffec1be8d59daa4abd0f9f0e52ae3064e7b6cc1845dfe34295b0
MD5 b621d38ee292c704d59ad2c14dbfe3d4
BLAKE2b-256 4851a794d2d75b44382da928f1e931f65248829026eb9c49d39a66f2b4f03610

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