The chord timeline to scan.
The prevailing key, or the key in force at a given beat.
The cadences found, in time order.
import { chordTimelineFromNotes, detectCadences } from '@libraz/libcantus';
const notes = [
{ pitch: 67, startBeat: 0, durationBeat: 4 }, // G, a dominant
{ pitch: 60, startBeat: 4, durationBeat: 4 }, // C, the tonic
];
const { timeline, prevailingKey } = chordTimelineFromNotes(notes);
const cadences = detectCadences(timeline, prevailingKey);
Find cadences between consecutive segments of a chord timeline.
Each temporally adjacent segment pair is classified with detectCadence; pairs forming no cadence are skipped. Segments separated by a gap (a rest in the timeline) are not a chord-to-chord progression, so they are never paired.
The segment before the pair is passed as the approach, which is what tells a cadential six-four from an inverted tonic:
I I64 V Iis one cadence arriving on the final tonic, described from the six-four the dominant was already sounding under, rather than a half cadence onto the dominant followed by an authentic one. A passing six-four — one whose dominant is not what follows it — is unaffected, and so is a pair whose predecessor is separated from it by a rest.