Generation options.
One chord per bar in timeline order.
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.
Generate a chord progression laid out one chord per bar.
A preset is chosen by
presetIdwhen given, otherwise deterministically from the presets matchingstyle, seeded by the context'sseed. An unknownpresetId, or astyleno preset claims, is a caller error and throws rather than silently falling back to a random preset. The preset's degrees cycle to fillbars; a bar is one bar ofts, sostartBeatisbarIndexbars 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. Whenextis omitted or'auto', each chord takes its diatonic triad quality; otherwiseextis forced on every chord — except a reharmonized chord, which is a secondary dominant and is therefore always adom7. Withcomplexity.harmonicabove 0, some chords are deterministically replaced with the secondary dominant (V7) of the following chord, flagged withsecondaryDominant. 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.