Skip to main content

Miditoolkit

A Python package for working with MIDI files.

PyPI version fury.io Python 3.7 GitHub CI GitHub license Downloads Code style

Miditoolkit works by loading/writing MIDIs with mido in a user-friendly way. It is inspired from pretty_midi, with similar usage and core features, but handles the MIDI events in native ticks time unit instead of seconds. It also comes with a few optimizations and speed-ups, and can parse MIDI tracks into piano-rolls for computation or visualization purposes. If you are working with seconds time units (for e.g. music transcription), you'll be likely better with pretty_midi. Otherwise, if you are working solely on MIDI and symbolic music, miditoolkit should provide slightly faster performances.

Main Features

  • MIDI
    • Global
      • ticks per beat
      • tempo changes
      • key signatures
      • time signatures
      • lyrics
      • markers
    • Instruments
      • control changes
      • pitch bend
    • Editing
      • chunk/cropping
    • IO
      • BytesIO
  • Piano-rolls
    • Tools
      • notes to piano-rolls
      • piano-rolls to notes
      • chromagram
    • Visualization
  • External Library

TODO

  • better documentation;
  • finish the code cleaning of the pianoroll methods (vis);
  • a way to switch the time in seconds across the whole MidiFile object;
  • cropping Control Changes and bars;
  • symbolic features
  • new structural analysis

Installation

You can install miditoolkit via PYPI:

pip install miditoolkit

... or directly from git if you want to get the latest features or fixes (only recommended if you need it):

pip install git+https://github.com/YatingMusic/miditoolkit

Example Usage

from miditoolkit import MidiFile
from miditoolkit.midi.utils import example_midi_file

path_midi = example_midi_file()
midi_obj = MidiFile(path_midi)

print(midi_obj)

Output:

ticks per beat: 480
max tick: 72002
tempo changes: 68
time sig: 2
key sig: 0
markers: 71
lyrics: False
instruments: 2

A. Parse and create MIDI files B. Piano-roll Manipulation

Philosophy

  • mido processes MIDI files in the lower level such as messages and ports, and is the backend pretty_midi and miditoolkit;
  • pretty_midi parses MIDI files and pianorolls in seconds time unit, plus has audio related features;
  • pypianoroll parses MIDI files into pianorolls in ticks time unit.

Miditoolkit is designed for handling MIDI in ticks, the native time unit of the MIDI protocol. We keep the midi parser as simple as possible, and offer several important functions to complete the versatility. For example, piano-rolls, tick-to-second, chromagram, etc.

Metadata

Release files for pozalabs-miditoolkit 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pozalabs-miditoolkit 1.2.0
File Size Uploaded Provenance Actions
pozalabs-miditoolkit-1.2.0.tar.gz 20.3 kB Without provenance Details for pozalabs-miditoolkit-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pozalabs-miditoolkit 1.2.0
File Interpreter ABI Platform Actions
pozalabs_miditoolkit-1.2.0-py3-none-any.whl Python 3 none any Details for pozalabs_miditoolkit-1.2.0-py3-none-any.whl

Total release size: 41.1 kB

Release files / pozalabs-miditoolkit-1.2.0.tar.gz

Download URL pozalabs-miditoolkit-1.2.0.tar.gz
Size 20.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f37d822b14881720ee07508acd20f537413e82e56fdf215f731eaa348cf787c8
BLAKE2b-256 checksum
How to use checksums
adb50b23e4147f2d4cbc35b82fa5f17c5f24078822a8e9920463759054d92d21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.0 CPython/3.9.20 Linux/6.5.0-1025-azure

Release files / pozalabs_miditoolkit-1.2.0-py3-none-any.whl

Download URL pozalabs_miditoolkit-1.2.0-py3-none-any.whl
Size 20.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3af741cfcd735bcabb978b0b8c1de6ff4fa9ebd5309c3c0267306cb0ca77e8a9
BLAKE2b-256 checksum
How to use checksums
5700056134932c7e2a766099e392fb7a939214577a284811ad602c7871ed6c7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.2.0 CPython/3.9.20 Linux/6.5.0-1025-azure

Security for pozalabs-miditoolkit 1.2.0

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page