Skip to main content

read_midi

Function read_midi 

Source
pub fn read_midi(path: &Path, bpm: Bpm) -> Result<NoteList, MidiError>
Expand description

Reads the notes of a MIDI file at path, checking its tempo against bpm.

Every note-on with a velocity above 0 starts a note, and the next note-off of the same key on the same channel and track ends it, first in, first out. A note still sounding at the end of its track ends there. A note of zero length carries no sound and is left out. Notes on the percussion channel, channel 10 (DRUM_CHANNEL counted from 0), are drums whose keys are no pitch, so they are left out too.

ยงErrors

Returns a MidiError that names the file and the cause: an unreadable or malformed file, a sequential (format 2) file, a tempo that differs from bpm, or a file without notes.