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

    Function figuredBassOf

    • Write a chord as the figures a bass would carry under it, in a key.

      The inverse of realizeFiguredBass for every chord the figure grammar reaches: the conventional abbreviation for the inversion (6, 64, 7, 65, 43, 42, or nothing at all for a root-position triad), with an accidental on any interval the key does not already give. The accidental is the sign the score prints in front of that note, so the third of the dominant in C minor — a B natural under a signature carrying B flat — is written n3 rather than as a raise from the flat the key gives. An altered interval the abbreviation would leave implied is written out, so the figure names the interval it lands on rather than the bare accidental a score puts under the bass — the figures this returns read back as the same chord.

      What this returns is read back before it is returned, so the two directions cannot disagree: a chord the digits would name only approximately has no figures rather than figures that fail to realize. What that excludes is a stack, not a family of chords — the Italian and German sixths stack in thirds over no root of their own and have no figures, while the French sixth stacks from its lowered supertonic and is written #643, which realizes back to the chord it was written from.

      Parameters

      • chord: ChordLike

        The chord to figure, as a chord symbol, chord data, or a Chord; its bassPc, when present, is the bass the intervals are measured above.

      • key: SpelledKeyLike

        The prevailing key, which decides which intervals need no accidental, as a key name, a key/scale, or a Key.

      Returns string

      The figures, as realizeFiguredBass accepts them.

      If the key is not heptatonic (InvalidInputError), or if no figure names the chord — its bass is not one of its tones, its tones do not stack in diatonic thirds above that bass, or it is an added-tone or extended chord the notation has no abbreviation for (NoSolutionError).

      import { figuredBassOf, majorKey, makeChord } from '@libraz/libcantus';
      figuredBassOf(makeChord(7, 'maj', 11), majorKey(0)); // '6' — G major over B
      figuredBassOf(makeChord(7, 'dom7', 2), majorKey(0)); // '43' — G7 over D