JSPM

  • Created
  • Published
  • Downloads 22
  • Score
    100M100P100Q68537F
  • License MIT

A dictionary of musical chords

Package Exports

  • @tonaljs/chord-dictionary

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@tonaljs/chord-dictionary) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@tonaljs/chord-dictionary tonal npm version

A dictionary of musical chords.

Usage

import { chordType } from "@tonaljs/chord-dictionary";
// or
const { chordType } = require("@tonaljs/chord-dictionary");

API

chordType(type: string) => ChordType

Given a chord type name, return a ChordType object with the following properties:

  • name: the chord type name
  • aliases: a list of alternative names
  • quality: Major | Minor | Augmented | Diminished | Unknown
  • num: the pcset number
  • chroma: the pcset chroma
  • length: the number of notes
  • intervals: the interval list

Example:

chordType("major"); // =>
// {
//   name: "major",
//   aliases: ["M", ""],
//   quality: "Major",
//   intervals: ["1P", "3M", "5P"],
//   num: 2192,
//   chroma: "100010010000",
//   length: 3
// });

entries() => ChordType[]

Return a list of all available chord types

add(intervals: string[], names: string[], fullName?: string) => ChordType

Add a chord type to dictionary:

add(['1P', '3M', '5P'], ['M'], 'mayor');

HOW TO

Get all chord names

entries()
  .map(chordType => chordType.name)
  .filter(chordType => chordType)

How to get triad chord names?

entries()
  .filter(chordType => chordType.length === 3)
  .map(chordType => chordType.name);

How to add a chord type to the dictionary?

add(['1P', '3M', '5P'], ['M', 'may'], 'mayor')
chordType('mayor') // => { name: 'mayor', quality: "Major", chroma: ... }
chordType('may') // => { name: 'mayor', quality: "Major", chroma: ... }

How to know if a collection of notes is a known chord?

A poor's man version of chord detection. Only detects chord in first inversion.

import { pcset } from "@tonaljs/pcset";

const notes = ["C4", "f#3", ...]
chordType(pcset(notes).chroma).name