@libraz/libcantus - v0.9.3
    Preparing search index...

    Function generateMotif

    • Generate a short seed motif over bars.

      The melody follows the requested contour in diatonic steps from the tonic, snapped to the key. When a chord is supplied, notes landing on bar downbeats are pulled to the nearest chord tone. An optional jitter adds balanced per-note variation without biasing the contour; it is off by default, so the contour is reproduced exactly. Output is deterministic for a given seed.

      Parameters

      • opts: MotifOptions

        Key, optional chord, length, contour, jitter, and seed.

      Returns MotifCell

      The generated motif cell.

      import { generateMotif, majorKey } from '@libraz/libcantus';
      const cell = generateMotif({ key: majorKey(0), bars: 2, contour: 'arch' });
      // cell.notes is a deterministic MotifCell (seed defaults to 0)