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.

Release files for miditoolkit 1.0.1

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

Source distribution (sdist)

Source distribution for miditoolkit 1.0.1
File Size Uploaded
miditoolkit-1.0.1.tar.gz 22.4 kB Details

Built distribution (wheel)

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

Total release size: 46.8 kB

Release files / miditoolkit-1.0.1.tar.gz

Download URL miditoolkit-1.0.1.tar.gz
Size 22.4 kB
Tags Source
SHA-256 checksum
How to use checksums
88f7ba5bcf6438bd303a0654f808a6eef6f573bcb6b9f5ebd649e78fc786b2c5
BLAKE2b-256 checksum
How to use checksums
ed8567eb411c91e5b3ff1c04c2396c1ca4464acad533905b7998283844739242
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / miditoolkit-1.0.1-py3-none-any.whl

Download URL miditoolkit-1.0.1-py3-none-any.whl
Size 24.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b2067e896e99b2f33934678202853664324eb2ad51999bbfc909d85c8e665e2d
BLAKE2b-256 checksum
How to use checksums
173ad2c741e404efe31700e971b5b93c96eb5a8e9a5100dc69cb7fef39f83d80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files

1.0.0

2 release files

0.1.17

2 release files

0.1.16

2 release files

0.1.14

1 release file

0.1.13

1 release file

0.1.12

1 release file

0.1.11

1 release file

0.1.10

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.2

1 release file

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