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

    Function formatChordSymbol

    • Format a Chord as a lead-sheet chord symbol.

      The inverse of parseChordSymbol in every notation system: each quality maps to one canonical suffix spelling, the root and bass are written in system, and a slash bass is appended only when it differs from the root. Every symbol written here reads back through parseChordSymbol as the same root, sounding bass and tones apart from the degrees the chord omits — whatever combination of tensions it carries, and whether or not a quality name covers it. Those omissions are the one difference the round trip has: a chord that leaves a degree out is written without saying so, so reading the symbol back puts the degree in. When the chord carries rootSpelling/bassSpelling hints (as chords from parseChordSymbol do) and no explicit flats preference is given, the hints are reused so flat symbols round-trip unchanged.

      The suffix is written from the chord's own tones (see chordSpecOf), not from its quality name, so a chord carrying alterations no name covers is written out in full — C7(b9,#11) — rather than under the nearest name. A tone the chord leaves out is not written: the symbol names the harmony, so a fifth-less dominant is still C7.

      Parameters

      • chord: ChordLike

        The chord to format, as a chord symbol, chord data, or a Chord.

      • Optionalopts: ChordSymbolOptions

        system writes the root and bass in that notation system instead of English; flats chooses the side of the staff the whole symbol is written on, as ChordSymbolOptions describes.

      Returns string

      The chord symbol text.

      import { makeChord, formatChordSymbol, parseChordSymbol } from '@libraz/libcantus';
      formatChordSymbol(makeChord(0, 'min7')); // 'Cm7'
      formatChordSymbol(parseChordSymbol('Bb7'), { system: 'german' }); // 'B7'
      formatChordSymbol(parseChordSymbol('B7'), { system: 'german' }); // 'H7'