@tonaljs/chord

Usage
ES6:
import { Chord } from "tonal";
Nodejs:
const { Chord } = require("tonal");
API
Chord.getChord(type: string, tonic?: string, root?: string) => Chord
Get the chord properties from a chord type and an (optional) tonic and (optional) root. Notice that the tonic must be present if the root is present. Also the root must be part of the chord notes.
It returns the same object that ChordType.get
but with additional properties:
- symbol: the chord symbol (a combiation of the tonic, chord type shortname and root, if present). For example:
Cmaj7
, Db7b5/F
. The symbol always uses pitch classes (note names without octaves) for both the tonic and root.
- tonic: the tonic of the chord (or an empty string if not present)
- root: the root of the chord (or an empty string if not present)
- rootDegree: the degree of the root. 0 if root not present. A number greater than 0 if present, where 1 indicates the tonic, 2 the second note (normally the 3th), 2 the third note (normally the 5th), etc.
- notes: an array of notes, or empty array if tonic is not present. If the root is pres
Example:
Chord.getChord("maj7", "G4", "B4");
Chord.get(name: string | [string, string]) => Chord
An alias of Chord.getChord
but accepts a chord symbol as parameter.
Chord.get("Cmaj7");
Chord.get(["C", "maj7"]);
Chord.getChord("maj7", "C");
Important: currently chord with bass are NOT allowed (will be implemented in next version):
Chord.get("Cmaj7/E");
Chord.degrees(chordName: string | [string, string]) => (degree: number) => string
Scale.degrees
returns a function to get a note name from a scale degree:
const c4m7 = Chord.degrees(["C4", "m7");
c4m7(1);
c4m7(2);
c4m7(3);
c4m7(4);
c4m7(1);
It can be used to find chord inversions:
[1, 2, 3, 4].map(chord);
[2, 3, 4, 5].map(chord);
[3, 4, 5, 6].map(chord);
[4, 5, 6, 7].map(chord);
Bear in mind that degree numbers starts with 1 and 0 returns an empty string:
c4m7(0);
See Scale.degrees
Chord.steps(chordName: string) => (degree: number) => string
Same as Chord.degrees
but 0 is the tonic. Plays better with numeric ranges:
import { Range, Chord } from "tonal";
Range.numeric([-3, 3]).map(Chord.steps(["C4", "aug"]));
Chord.detect(notes: string[]) => string[]
Given a list of notes, get the possible chord names:
Chord.detect(["D", "F#", "A", "C"]);
Chord.detect(["F#", "A", "C", "D"]);
Read more at chord-detect
Chord.transpose(chordName: string, intervalName: string) => string
Transpose a chord symbol by an interval:
Chord.transpose("Eb7b9", "5P");
Chord.chordScales(chordName: string) => string[]
Get all scales where the given chord fits:
Chord.chordScales("C7b9");
Chord.extended(chord: string) => string[]
Get all chords names that are a superset of the given one (has the same notes and at least one more)
Chord.extended("Cmaj7");
Chord.reduced(chord: string) => string[]
Find all chords names that are a subset of the given one (less notes but all from the given chord)
Chord.reduced("Cmaj7");