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

    Function toChordData

    • Resolve any chord-shaped value to plain Chord data.

      The counterpart of toSpelledInterval for chords: an entry point takes whatever form the caller has — the symbol a chart holds, the data the chord module returns, or a Chord instance — and gets one shape back. An instance is accepted through its toJSON method rather than by its type, so the layers below the model can read a class without importing it.

      Parameters

      • value: ChordLike

        A chord symbol, plain chord data, or a value whose toJSON returns chord data.

      Returns ChordData

      The validated chord data, with root and bass reduced to pitch classes and any spelling hint carried through.

      If the value names no chord, or an interval, root, or bass is not a finite number.

      import { toChordData } from '@libraz/libcantus';
      toChordData('Cmaj7').intervals; // [0, 4, 7, 11]
      toChordData({ rootPc: 0, quality: 'maj', intervals: [0, 4, 7] }).rootPc; // 0