Skip to Content
Tonal
Dictionaries

Scale dictionary

@tonaljs/scale-type on npm

A dictionary of musical scales.

@tonaljs/scale-type is a dictionary of musical scales.

API

ScaleType.get

get(name: string) => ScaleType

Given a scale type name, return a ScaleType object with the following properties:

  • empty: true if the scale type is not found
  • name: the scale type name
  • aliases: a list of alternative names
  • setNum: the pcset number
  • chroma: the pcset chroma
  • normalized: the pcset chroma rotated to start with its first note
  • intervals: the interval list

Example:

ScaleType.get("major"); // =>
// {
//   empty: false,
//   name: "major",
//   setNum: 2773,
//   chroma: "101011010101",
//   normalized: "101010110101",
//   intervals: ["1P", "2M", "3M", "4P", "5P", "6M", "7M"],
//   aliases: ["ionian"],
// }

ScaleType.names

names() => string[]

Return a list of all scale names

ScaleType.all

all() => object[]

Return a list of all scale types

ScaleType.add

add(intervals: string[], name: string, aliases?: string[]) => ScaleType

Add a scale type to dictionary:

ScaleType.add(["1P", "5P"], "fifth", ["5"]);

ScaleType.addAlias

addAlias(scaleType: ScaleType, alias: string) => void

Add an alias to get a scale type from the dictionary. The alias is only used to find it (it's not added to its aliases):

ScaleType.addAlias(ScaleType.get("major"), "dur");
ScaleType.get("dur").name; // => "major"

ScaleType.keys

keys() => string[]

List every key that finds a scale type: names, aliases, set numbers and chromas:

ScaleType.keys().includes("ionian"); // => true

ScaleType.removeAll

removeAll() => void

Remove every scale type from the dictionary. Other modules that use it (Scale, Chord.chordScales...) won't find any scale afterwards.

How to...

How to get all pentatonics names?

ScaleType.all()
  .filter((scaleType) => scaleType.intervals.length === 5)
  .map((scaleType) => scaleType.name);

How to add a scale to the dictionary?

ScaleType.add(["1P", "5P"], "quinta", ["quinta justa", "diapente"]);
ScaleType.get("quinta"); // => { name: "quinta", intervals: ...}
ScaleType.get("quinta justa"); // => { name: "quinta", intervals: ... }

References

Some sources explaining various scale systems:

On this page