Expand description
Segment a per-frame (f0, confidence) pitch track into MIDI note ON/OFF
events.
Each voiced frame is quantised to a MIDI note number (via
hz_to_midi). A note is a maximal run
of consecutive frames that quantise to the same note number; the run ends
when the pitch crosses the half-semitone quantisation boundary into a
different note (the pitch-change threshold) or when a low-confidence /
unvoiced gap interrupts voicing. Runs shorter than min_note_frames are
discarded as transients, so a single glitchy frame does not become a note.
Epistemic contract: every emitted NoteEvent is a proposal, not an
authoritative transcription. It carries the mean voicing confidence of its
frames, and velocity is derived from that same confidence — downstream code
can weight or reject a proposal on it. Transcribed MIDI must never be treated
as ground truth the way imported MIDI is.
Zero-heap hot path: note events are written into the caller-supplied out
slice; the function allocates nothing.
Structs§
- Note
Event - One transcribed note proposal.
Constants§
- MIN_
VOICED_ CONFIDENCE - Minimum voicing confidence for a frame to count as pitched. Frames below this
(or with
f0 <= 0) are treated as an unvoiced gap that ends the current note.
Functions§
- segment_
notes - Segment a per-frame pitch track into note events.