JSPM

  • Created
  • Published
  • Downloads 14
  • Score
    100M100P100Q67551F
  • 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 { get } from "@tonaljs/chord-dictionary";
// or
const { get } = require("@tonaljs/chord-dictionary");

API

get(name: 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:

get("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

You can get (long) chord names:

entries()
  .map(type => type.name)
  .filter(name => name);

Or the first (short) name:

entries()
  .map(type => type.aliases[0])
  .filter(name => name);

How to get triad chord names?

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

How to add a chord type to the dictionary?

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