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

    Function detectCadence

    • Classify the cadence formed by moving from one chord to the next.

      • authentic: V (dominant a fifth above the tonic) to I
      • plagal: IV, the chord on the key's own fourth degree, to I
      • modal: bVII to I, the cadence of rock and modal writing
      • deceptive: V to the key's own submediant, plus the borrowed bVI of a major key
      • phrygian: iv6 to V of a minor key, the half cadence whose bass falls a semitone from b6 to 5
      • half: any other chord than the dominant itself to V, the cadential six-four standing on the dominant's own bass included

      These are read as scale degrees rather than as semitone distances, so a mode cadences from and onto the degrees it actually has: the deceptive arrival of dorian is a major sixth above the tonic and that of phrygian a minor sixth, and the subdominant a plagal cadence falls from is the tritone above the tonic in lydian. The two borrowed types are the exception, and are stated as the fixed offsets they name: modal is the flattened seventh whatever the key writes on that degree, and the Phrygian bass falls from the lowered submediant. A half cadence normally rests on the major third that carries the leading tone, but where the key's own dominant has no leading tone — the modal v of dorian, mixolydian and the pop writing built on them — the arrival's own third suffices as long as the key contains it. That relaxation belongs to the modes alone: a borrowed minor v in a major key is no half cadence, and neither is the v of a minor key, which cadences through the raised seventh it writes as an accidental rather than in its scale.

      A static V-to-V repeat with no root motion is not a cadence and yields a null type. The tonic six-four resolving onto the dominant it stands on is a half cadence, and the most ordinary one there is: I - I64 - V closes the antecedent of a period, and the six-four is a double appoggiatura over the dominant's own bass rather than a chord that keeps the motion going. Where that dominant goes on to resolve, the pair and the resolution are one event — passing the six-four as approach when the dominant is the from chord is what lets it be reported as one, with the type and the beat still the dominant's resolution while the rationale says the cadence began at the six-four. A six-four the bass leaves instead (IV-I64-IV, or a neighbouring one over the tonic) is an ordinary inverted tonic and is read as one.

      An authentic cadence is graded perfect or imperfect. Perfect takes the dominant to the tonic with both chords in root position and the tonic in the soprano; anything else authentic is imperfect, including the leading-tone cadence, which has no dominant root to stand on. Only a voicing names the soprano, so without one the grade is null — the pair could still be either, and reporting perfect would be a guess.

      The rationale says which motion the reading rests on, including for a pair that cadences not at all; alternatives is empty unless asked for, and then names the cadences the pair came close to forming.

      Parameters

      • from: ChordLike

        The penultimate chord, as a chord symbol, chord data, or a Chord.

      • to: ChordLike

        The final chord, in any of the same forms.

      • key: KeyLike

        The prevailing key, as a key name, a key/scale, or a Key.

      • opts: DetectCadenceOptions = {}

        Voice-leading detail, the chord before from, and whether to collect the rejected readings; see DetectCadenceOptions.

      Returns CadenceResult

      The cadence, its strength, and the facts behind them.

      import { detectCadence, makeChord, majorKey } from '@libraz/libcantus';
      detectCadence(makeChord(7, 'maj'), makeChord(0, 'maj'), majorKey(0));
      // { type: 'authentic', strength: null, rootPosition: true, evaded: false, ... }
      detectCadence(makeChord(7, 'maj'), makeChord(0, 'maj'), majorKey(0), {
      voicing: [[55, 62, 71], [48, 64, 72]],
      });
      // { type: 'authentic', strength: 'perfect', soprano: 'root', ... }
      const sixFour = detectCadence(makeChord(7, 'maj'), makeChord(0, 'maj'), majorKey(0), {
      approach: makeChord(0, 'maj', 7), // C/G, the cadential six-four
      });
      sixFour.type; // 'authentic'
      // The rationale says where the cadence began.
      sixFour.rationale?.includes('cadential six-four'); // true