Skip to content

v0.3.0: Chord symbol parsing

Latest

Choose a tag to compare

@amaar-mc amaar-mc released this 17 Jun 20:11
· 1 commit to main since this release
80d956c

What is new

parseChord

Parse a standard chord symbol string into its root pitch class (C = 0), a canonical quality label, and a sorted set of pitch classes.

import { parseChord } from "tonnetz";

parseChord("C");       // { root: 0, quality: "major",   pitchClasses: [0, 4, 7] }
parseChord("Cm7");     // { root: 0, quality: "minor7",  pitchClasses: [0, 3, 7, 10] }
parseChord("F#maj7");  // { root: 6, quality: "major7",  pitchClasses: [1, 6, 10, 11] }
parseChord("Csus4");   // { root: 0, quality: "sus4",    pitchClasses: [0, 5, 7] }
parseChord("xyz");     // null

Accepts all 12 roots with sharps and flats (C, C#, Db, ..., B). Returns null for unrecognized input, including unsupported extensions (9ths, add9, etc.).

chordCandidates

The inverse: given a pitch-class set, return all recognized chord symbols that match exactly.

import { chordCandidates } from "tonnetz";

chordCandidates([0, 4, 7]);
// [{ root: 0, quality: "major", symbol: "C" }]

chordCandidates([0, 3, 6, 9]);
// Four entries (diminished 7 is symmetrical)

Supported qualities

major, minor, diminished, augmented, dominant7, major7, minor7, halfDiminished7, diminished7, sus2, sus4, minorMajor7.

Notes

  • npm publish of 0.3.0 is pending the maintainer OTP.
  • Seventh-chord neo-Riemannian transforms (Childs/Gollin) are planned for a future release.