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

    Function substituteChord

    • Propose substitutions for a chord within a key.

      Candidates are generated by several relationships and deduplicated against the original chord and each other:

      • tritone: for a dominant-type chord, the dominant seventh a tritone away.
      • relative: a diatonic triad a third away that shares two common tones.
      • borrowed: a triad from the parallel mode with the same harmonic function.
      • chromaticMediant: a major/minor triad a third away sharing one common tone.

      These four are the whole vocabulary. An applied dominant is not proposed because the chord it applies to is the one that follows, which a call about a single chord cannot see; secondaryDominantOf builds one from a named target.

      Each result carries its Roman numeral and harmonic function in key. When opts.melodyPcs is given, only substitutions whose pitch classes contain all of those pitch classes are returned.

      Every substitution is spelled the way key writes it, as rootSpelling and bassSpelling hints, so a flat-side key keeps flat names: in C major the tritone substitute of G7 formats as Db7 and its chromatic mediants as Bb and Eb. Where the substitution's function and the bare pitch class disagree, the function decides — a tritone substitute is a bII7 and so is written on the flattened supertonic of the chord it resolves to, and a borrowed chord takes the spelling of the mode it is borrowed from.

      Parameters

      • chord: ChordLike

        The chord to reharmonize, as a chord symbol or as chord data.

      • key: SpelledKeyLike

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

      • Optionalopts: SubstituteOptions

        Optional melody-preservation constraint.

      Returns Substitution[]

      The deduplicated substitution candidates.

      import { substituteChord, makeChord, majorKey, formatChordSymbol } from '@libraz/libcantus';
      const subs = substituteChord(makeChord(7, 'dom7'), majorKey(0));
      subs
      .filter((sub) => sub.type === 'tritone')
      .map((sub) => formatChordSymbol(sub.chord)); // ['Db7'] — the bII7 of C major, not 'C#7'