Repository navigation
Releases
v0.3.0: Chord symbol parsing
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"); // nullAccepts 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.
v0.2.0
Adds the named compound transformations n (Nebenverwandt) and s (Slide). Each is an involution that preserves one common tone, verified against its PLR composition (R, L, P for N; L, P, R for S) across all 24 triads. 29 tests.
Note: this release is on GitHub; the npm package is still at 0.1.0 pending a 2FA OTP publish.
v0.1.0
First release of tonnetz, a zero-dependency TypeScript library for neo-Riemannian music theory.
Includes the P, L, R transformations (with correct major and minor cases), arbitrary compositions, the hexatonic pole, hexatonic and octatonic cycles, shortest P/L/R paths between any two triads, common-tone counts, and the Tonnetz lattice coordinate map. Covered by exact textbook values and group-theoretic property tests (involutions, the two-common-tone property, reachability across all 24 triads). 25 tests.