PerformanceMidiLoader

loader.midi.performance.PerformanceMidiLoader(
    parse_durations=True,
    on0_means_off=True,
    include_controls=True,
    include_program_changes=True,
    unit=None,
    number_type=NumberType.float,
    **kwargs,
)

Load performance MIDI files using mido.

This loader parses raw MIDI messages, preserving the performance characteristics (timing, velocity, control changes) without attempting structural analysis.

It pairs note_on/note_off events into Note intervals and stores control changes as Instant events.

Attributes

Name Description
ticks_per_beat Return the ticks per beat (PPQ) of the loaded file.

Methods

Name Description
from_file Create a loader and load a MIDI file in one step.

from_file

loader.midi.performance.PerformanceMidiLoader.from_file(
    path,
    *,
    parse_durations=True,
    on0_means_off=True,
    include_controls=True,
    include_program_changes=True,
)

Create a loader and load a MIDI file in one step.

Convenience constructor for loading a single file.

Parameters

Name Type Description Default
path Path | str Path to the MIDI file. required
parse_durations bool Whether to pair note_on/off into intervals. True
on0_means_off bool Treat note_on with velocity 0 as note_off. True
include_controls bool Include Control Change events. True
include_program_changes bool Include Program Change events. True

Returns

Name Type Description
'PerformanceMidiLoader' A new PerformanceMidiLoader instance with the file already loaded.

Examples

>>> loader = PerformanceMidiLoader.from_file("performance.mid")
>>> loader.ticks_per_beat
480