Skip to main content

finish

Function finish 

Source
pub fn finish(input: &FinishInput<'_>) -> FinalNotes
Expand description

Rewrites the note list with the layer report.

The steps run in this order:

  1. Each pitch drop merges the notes that start from DROP_SLACK before its onset until it settles, touch each other and lie on keys from f_end to its start pitch, into one note at the key of f_end.
  2. A note that a vibrato covers for more than half its length takes the key of the vibrato’s mean pitch, when that lies within a semitone.
  3. On a polyphonic line a note ends at its pad end where it has one. Otherwise it ends at its knee, else NO_KNEE_CUT before its end in the list. No note ends after its end in the list. A cut never makes a note shorter than min_note_length; a note the list gives shorter keeps its length.
  4. Times become ticks with round(seconds * BPM / 60 * 480), and each note lasts at least one tick. A note without a level reads it over this written span, which on a mono line stops at the next later onset.
  5. In a mono line, of the notes that start on one tick only one stays: a note without the transcriber’s octave flag before one with it, then the longer, then the lower key.
  6. In a mono line, a glide joins the pair of neighbours whose interval lies within a semitone of its own and whose later onset lies within GLIDE_SLACK of its motion, the nearest to its start. The later note starts at the glide’s start, or at its own onset when the glide starts after it, and the earlier one ends GLIDE_OVERLAP after that start, rounded up to whole ticks, whatever its knee says. Every other note of a mono line ends no later than the next note starts.
  7. With level velocity, the loudest note gets 127 and a note d dB under it round(127 * 10^(-d / 40)), at least 1; a note without a level, and every note otherwise, gets DEFAULT_VELOCITY.
  8. On a mono line, a note whose contour leaves its key by BEND_MIN or more, of one sign, over adjacent frames that span the tracker’s reach (a quarter frame plus one period), outside every glide, drop and vibrato span, gets a bend at each contour point outside those spans, clamped to BEND_RANGE, and a centred bend at its end.