pub fn write_midi(
notes: &NoteList,
bpm: Bpm,
velocities: Velocities,
) -> Result<Vec<u8>, MidiWriteError>Expand description
Encodes the notes as a format 0 file at a BPM.
Times become ticks with round(seconds * BPM / 60 * 480), so each lies
within half a tick of the note. The tempo event at tick 0 holds
round(60,000,000 / BPM) microseconds per beat. A fractional pitch
rounds to the nearest key. Three rules any player needs come first: a
note shorter than MIN_NOTE_LENGTH or one tick is lengthened, of two
notes with one key and one start only the longer stays, and a note that
still sounds when its key starts again ends there. At one tick a
note-off comes before a note-on, so two touching notes of one pitch
stay two. The file has no program change and no pitch bend.
ยงErrors
Returns a MidiWriteError for an empty list, which no reader of ours
accepts, and when two events lie further apart than a MIDI delta time
holds, about nine hours at 1000 BPM.