Skip to content

Chords

The chords module computes chord notes and diatonic chord relationships across 11 chord types:

  • Triads: major-triad, minor-triad, diminished-triad, augmented-triad
  • 7th chords: major-7th, minor-7th, dominant-7th
  • 6th chords: major-6th, minor-6th
  • 9th chords: major-9th, minor-9th

getChordNotes(root, chordType) returns the notes of any chord type built on a root.

getDiatonicChords(root, mode) returns the 7 diatonic triads for a key/mode, one per scale degree, in degree order (defaults to Ionian/major). getChordByDegree(degree, root, mode) returns just the chord at one degree (1-7).

getAvailableInversions(chordType) returns the valid inversion numbers for a chord type - a triad has 3 (0-2), a 9th chord has 5 (0-4). getChordInversion(chord, inversion) reorders a chord’s notes so the given inversion’s tone is lowest, throwing a RangeError if the inversion is out of range for that chord’s type.

getChordNotes

getChordNotes(root: Note, chordType: ChordType): Note[]

Returns the notes of a chord type built on a root.

ResultC, E, G

getDiatonicChords

getDiatonicChords(root: Note, mode?: ModeName): Chord[]

Returns the 7 diatonic triads for a key/mode, one per scale degree.

Result
[
  {
    "root": "C",
    "type": "major-triad"
  },
  {
    "root": "D",
    "type": "minor-triad"
  },
  {
    "root": "E",
    "type": "minor-triad"
  },
  {
    "root": "F",
    "type": "major-triad"
  },
  {
    "root": "G",
    "type": "major-triad"
  },
  {
    "root": "A",
    "type": "minor-triad"
  },
  {
    "root": "B",
    "type": "diminished-triad"
  }
]

getChordByDegree

getChordByDegree(degree: number, root: Note, mode?: ModeName): Chord

Returns the diatonic chord at a specific scale degree (1-7).

Result
{
  "root": "C",
  "type": "major-triad"
}

getAvailableInversions

getAvailableInversions(chordType: ChordType): readonly ChordInversion[]

Returns the valid inversion numbers for a chord type, based on its note count.

Result[0, 1, 2]

getChordInversion

getChordInversion(chord: Chord, inversion: ChordInversion): Note[]

Reorders a chord's notes so the given inversion's chord tone is lowest.

ResultC, E, G