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

    Function generateProgression

    • Generate a chord progression laid out one chord per bar.

      A preset is chosen by presetId when given, otherwise deterministically from the presets matching style, seeded by the context's seed. An unknown presetId, or a style no preset claims, is a caller error and throws rather than silently falling back to a random preset. The preset's degrees cycle to fill bars; a bar is one bar of ts, so startBeat is barIndex bars of it — four beats apart in 4/4, three in 3/4 and in 6/8 alike. Chord roots come from the key's diatonic scale-degree mapping. When ext is omitted or 'auto', each chord takes its diatonic triad quality; otherwise ext is forced on every chord — except a reharmonized chord, which is a secondary dominant and is therefore always a dom7. With complexity.harmonic above 0, some chords are deterministically replaced with the secondary dominant (V7) of the following chord, flagged with secondaryDominant. Only a chord the key can make a local tonic is given one: nothing tonicizes a diminished triad, so the supertonic of a minor key takes no dominant of its own.

      Parameters

      Returns ChordSpan[]

      One chord per bar in timeline order.

      If presetId matches no built-in preset, or style matches none.

      import { generateProgression, majorKey } from '@libraz/libcantus';
      const chords = generateProgression({ key: majorKey(0), style: 'dance', bars: 4 });
      // Deterministic for a given seed (defaults to 0); one ChordSpan per bar.
      const richer = generateProgression({
      key: majorKey(0),
      style: 'dance',
      bars: 4,
      ctx: { seed: 3, complexity: { harmonic: 0.5 } },
      });
      // Some chords are now the secondary dominant of the chord that follows.