Skip to main content

Module midi

Module midi 

Source
Expand description

Standard MIDI Files, read as a table of their events.

The parser is written by hand over the file’s bytes: MThd and MTrk chunks, variable-length deltas, running status, sysex and meta events. Every length the file states is checked against the bytes that remain before it is used, so a corrupt or hostile file is an error rather than a panic or an allocation sized by a number the file made up.

The rows are an eager DataFrame (one per event) made lazy, as ORC and Excel are: MIDI files are kilobytes. What is not a row — the header, the tracks’ names, the tempo range — is a MidiSummary, carried to the dataset for the Info panel’s MIDI tab.

Structs§

Event
One event as the file has it, its bytes borrowed from the file.
MidiSummary
What a MIDI file says besides its events, for the Info panel’s MIDI tab.
Smf
A Standard MIDI File, parsed.
TrackSummary
One track, as the Info panel lists it.

Enums§

Body
Division
How a file counts time: ticks per quarter note, or SMPTE frames.

Constants§

MAX_EVENTS
The most events read, across every file of one open. Each is a row of a dozen columns held in memory.
MAX_FILE_BYTES
The largest file read. MIDI files are kilobytes; a song with a dense controller stream is a few megabytes.

Functions§

build
The table and the summary for parsed files; names are their files, written to a file column when there is more than one.
detail
The MIDI tab: the header, timing and tempo, then the tracks; for a directory of songs, the totals, then the files that could not be read.
looks_like_midi
Whether head starts like a MIDI file: MThd with its length of 6, or a RIFF RMID wrapper.
note_name
A note number as a name, middle C (60) as C4.
notes
What the open has to say about the events: notes that never end, and files that could not be read.
parse
Parse a Standard MIDI File (or one in a RIFF RMID wrapper).
read_midi
Read paths as one table of events, with a file column when there is more than one.