Skip to main content

note_events_to_timed

Function note_events_to_timed 

Source
pub fn note_events_to_timed(
    events: &[NoteEvent],
    frames_per_tick: f32,
    out: &mut [TimedEvent],
) -> Result<usize, AudioError>
Expand description

Convert transcribed NoteEvent proposals into paired note-on / note-off TimedEvents on the sequencer timeline.

For each input note two events are written to out, in order: a note-on at the tick its start_frame maps to (status 0x90, velocity from the note), then a note-off at the tick its end_frame maps to (status 0x80, release velocity NOTE_OFF_VELOCITY). Both carry PROPOSAL_CHANNEL.

The output is not re-sorted: it is emitted in input order as on/off pairs. Because segment_notes yields notes in start-frame order, callers who need a tick-sorted crate::midi::sequencer::Track should insert each event (which keeps the track sorted) rather than assume global tick order.

  • events: transcribed note proposals (see crate::features::pitch_midi).
  • frames_per_tick: analysis frames per PPQ tick; must be finite and > 0.
  • out: caller-owned destination; must hold 2 * events.len() events.

Returns the number of TimedEvents written (always 2 * events.len()).

Every emitted event is a proposal (see the module docs / PROPOSAL_NOTE).

§Errors