@libraz/libcantus - v1.1.0
    Preparing search index...

    Function classifyMelodyTones

    • Classify a melody's ornaments from the melody and the metre alone.

      This is deliberately chord-free: a harmonizer needs to know which notes the chords must explain before it can choose them, so nothing here may consult a harmony. What remains is the melodic and metric evidence — stepwise approach and departure, repeated pitches, leaps, and the relative metric weight and length of a note against its neighbours.

      The figures are recognized in the order suspension, passing, neighbor, anticipation, appoggiatura, escape. A note is judged ornamental only when it is metrically and rhythmically subordinate to the neighbours that frame it (or, for the accented figures, when it leans on a stronger beat than its approach and gives way to a resolution). A note without an adjacent predecessor and successor has no figure to belong to and stays structural, so the first and last notes of a phrase are always structural.

      Parameters

      • melody: readonly NoteEvent[]

        The melody, in ascending onset order.

      • ts: MeterLike

        Time signature used to weight metric accents.

      Returns ClassifiedMelodyTone[]

      One classification per input note, in input order.

      import { classifyMelodyTones } from '@libraz/libcantus';
      const melody = [60, 62, 64, 60].map((pitch, i) => ({
      pitch,
      startBeat: i,
      durationBeat: 1,
      }));
      classifyMelodyTones(melody, { numerator: 4, denominator: 4 })[1];
      // { noteIndex: 1, role: 'passing', ornamental: true }