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 seed. An unknown presetId is a
caller error and throws rather than silently falling back to a random preset.
The preset's degrees cycle to
fill bars; each bar is four beats, so startBeat is barIndex * 4. 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. When reharmonize is set, some chords are
deterministically replaced with the secondary dominant (V7) of the following
chord, flagged with secondaryDominant.
If presetId is given but does not match any built-in preset.
Example
import { generateProgression, majorKey } from'@libraz/libcantus'; constchords = generateProgression({ key:majorKey(0), style:'dance', bars:4 }); // Deterministic for a given seed (defaults to 0); one ChordSpan per bar.
Generate a chord progression laid out one chord per bar.
A preset is chosen by
presetIdwhen given, otherwise deterministically from the presets matchingstyle, seeded byseed. An unknownpresetIdis a caller error and throws rather than silently falling back to a random preset. The preset's degrees cycle to fillbars; each bar is four beats, sostartBeatisbarIndex * 4. Chord roots come from the key's diatonic scale-degree mapping. Whenextis omitted or'auto', each chord takes its diatonic triad quality; otherwiseextis forced on every chord. Whenreharmonizeis set, some chords are deterministically replaced with the secondary dominant (V7) of the following chord, flagged withsecondaryDominant.