3.1.0 • Published 3 months ago

chord-name v3.1.0

Weekly downloads
-
License
GPL-3.0
Repository
github
Last release
3 months ago

chord-name

A library to generate the potential chord names, given a set of notes.

An example app that uses this library is Chord-o-matic Chord Constructor.

Documentation

Below is a very brief overview. More complete documentation is on GitHub project wiki.

Additionally, if your editor recognizes typescript types, all methods/types are documented.

Types

Typescript type definitions are provided. No @types import is required.

Overview

const {Chord} = require('chord-name');

const chord = new Chord('A C E G');

// If you know the root note, use .getName(rootNote)
console.log(chord.getName('A'));

OUTPUT:
{
  "name": "Am7",
  "intervals": [
    {
      "interval": "R",
      "note": "A"
    },
    {
      "interval": "m3",
      "note": "C"
    },
    {
      "interval": "5",
      "note": "E"
    },
    {
      "interval": "7",
      "note": "G"
    }
  ],
  "score": 33
}


// If you want to get ALL POTENTIAL names for the set of notes, use .getNames()
console.log(chord.getNames());

OUTPUT:
[
  {
    "name": "Am7",
    "intervals": [
      {
        "interval": "R",
        "note": "A"
      },
      {
        "interval": "m3",
        "note": "C"
      },
      {
        "interval": "5",
        "note": "E"
      },
      {
        "interval": "7",
        "note": "G"
      }
    ],
    "score": 33
  },
  {
    "name": "C6",
    "intervals": [
      {
        "interval": "R",
        "note": "C"
      },
      {
        "interval": "3",
        "note": "E"
      },
      {
        "interval": "5",
        "note": "G"
      },
      {
        "interval": "6",
        "note": "A"
      }
    ],
    "score": 31
  },
  {
    "name": "Em(♯5)add11",
    "intervals": [
      {
        "interval": "R",
        "note": "E"
      },
      {
        "interval": "m3",
        "note": "G"
      },
      {
        "interval": "♯5",
        "note": "C"
      },
      {
        "interval": "11",
        "note": "A"
      }
    ],
    "score": 18
  },
  {
    "name": "G6/9sus4(no5)",
    "intervals": [
      {
        "interval": "R",
        "note": "G"
      },
      {
        "interval": "6",
        "note": "E"
      },
      {
        "interval": "9",
        "note": "A"
      },
      {
        "interval": "4",
        "note": "C"
      }
    ],
    "score": 2
  }
]

Methodology

Beyond well-defined chords like majors/minors/sevenths, there can be surprising variation in what a chord is called. What I've written reflects my best understanding of chord names, but I'm always open to feedback.

Two-note chords

I need to make a special mention of two-note chords. In the traditional definition of "chord", at least three notes are required to define a chord. But that completely ignores the ubiquitous power chord! Rather than throw an error, my algorithm will return the following names for two-note chords:

IntervalsNameExample
Root + minor third\<root>m(no5)C + E♭ = Cm(no5)
Root + major third\<root>(no5)C + E = C(no5)
Root + flat fifth\<root>dim5C + G♭ = Cdim5
Root + fifth\<root>5C + G = C5
Root + sharp fifth\<root>aug5C + G♯ = Caug5
All other combinations\<root>~\<other-note>C + A = C~A

I'm really not happy with that "All other combinations" row, but it's the best I could come up with. I'm certainly open to feedback if you have a better idea!

3.1.0

3 months ago

3.0.0

3 months ago

2.0.0-rc.1

3 months ago

1.1.0-rc.2

3 months ago

1.1.0-rc.5

3 months ago

1.1.0-rc.4

3 months ago

1.1.0-rc.1

3 months ago

2.0.0

3 months ago

1.0.2

9 months ago

1.0.1

2 years ago

1.0.0

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago