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

    Function ornament

    • Decorate existing notes with an ornament.

      Which notes are eligible follows from the style and the meter — ghosts fall on weak positions, drags on the weak position before a strong one, flams and accents on strong ones, slides on notes the line moves to, by a step or by a leap — and amount decides how many of those eligible notes are taken. The choice is addressed by each note's own position, so raising amount adds ornaments without moving the ones already there, and no onset is ever added or shifted: a decorated note is the same note carrying an Articulation. A note that already carries one is left alone, so ornament passes can be layered.

      With a difficulty ceiling and a tempo in the context, a passage whose strokes come too fast for that ceiling is left plain — the ornament is exactly the kind of candidate a ceiling exists to reject.

      Parameters

      Returns NoteEvent[]

      Copies of the sounding notes, in input order, with ornaments applied.

      import { generateBassLine, majorKey, makeChord, ornament } from '@libraz/libcantus';
      const line = generateBassLine({
      segments: [{ startBeat: 0, endBeat: 4, chord: makeChord(0, 'maj') }],
      key: majorKey(0),
      style: 'pop',
      });
      ornament(line, { style: 'ghost', amount: 0.4, ctx: 3 });

      Notes with a zero or negative duration never sound and are dropped, so the result can be shorter than the input.