Skip to main content

pair_note_events

Function pair_note_events 

Source
pub fn pair_note_events(
    events: &[TimedEvent],
    out: &mut [PairedNote],
) -> Result<usize, AudioError>
Expand description

Pair a tick-ordered timed-MIDI stream into whole notes.

A note opens on a note-on with velocity > 0. It closes on the first subsequent note-off (0x8n) or velocity-0 note-on (0x9n vel 0) with the same channel and note; the newest matching open note is closed first (LIFO), which is the standard resolution for a repeated note re-struck before its first release. Unmatched note-ons still open at the end of the stream are dropped (no synthetic note-off is invented). Non-note events are ignored.

  • events: the timed MIDI stream (sequencer track / flattened SMF track).
  • out: caller-owned destination for completed PairedNotes.

Returns the number of notes written to out.

ยงErrors