Skip to main content

Module midi

Module midi 

Source
Expand description

Standard MIDI Files as a table of events. A hand-written parser (MThd/MTrk chunks, variable-length deltas, running status, sysex, meta events) checks every stated length against the remaining bytes, so a hostile file errors rather than panics or over-allocates. Rows are a small eager frame made lazy; the header, track names and tempo range go to a MidiSummary for Info’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.

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 a RIFF RMID wrapper). Strict where leniency would fake a whole table: an overrunning track, a cut event, a data byte without status, or fewer tracks than the header says are errors. Non-MTrk chunks and anything after the promised tracks are skipped; a missing End of Track is fine.
read_midi
Read paths as one events table (with a file column for several). One unreadable file is an error; among several, unreadable ones are skipped and named in the summary unless all fail. One file’s bytes are held at a time.