@tonaljs/scale
is a collection of functions to create and manipulate musical scales
ES6:
import { Scale } from "@tonaljs/tonal";
nodejs:
const { Scale } = require("@tonaljs/tonal");
Single module:
import Scale from "@tonaljs/scale";
List all known scale names. Same as ScaleType.names()
See scale-type
Get a scale from a scale name. Scale.get
accepts tonics in the scale name and returns a scale type with two more properties: tonic
and notes
:
Scale.get("c5 pentatonic");
// =>
// {
// empty: false,
// name: "C5 pentatonic",
// type: "major pentatonic",
// tonic: "C5",
// notes: ["C5", "D5", "E5", "G5", "A5"],
// intervals: ["1P", "2M", "3M", "5P", "6M"],
// aliases: ["pentatonic"],
// setNum: 2708,
// chroma: "101010010100",
// normalized: "101010010100"
// }
Get all chords that fits a given scale:
Scale.scaleChords("pentatonic");
// => ["5", "64", "M", "M6", "Madd9", "Msus2"]
Get all scales names that has the same notes and at least one more:
Scale.extended("major");
// => ["bebop", "bebop dominant", "bebop major", "chromatic", "ichikosucho"]
Find all scales names that are a subset of the given one (less notes but all from the given scale)
Scale.reduced("major");
// => ["ionian pentatonic", "major pentatonic", "ritusen"]
Given an array of notes, return the scale: a pitch class set starting from the first note
Scale.scaleNotes(["C4", "c3", "C5", "C4", "c4"]); // => ["C"]
Scale.scaleNotes(["D4", "c#5", "A5", "F#6"]); // => ["D", "F#", "A", "C#"]
Find mode names (if any) of a given scale:
Scale.modeNames("C pentatonic"); // => [
// ["C", "major pentatonic"],
// ["D", "egyptian"],
// ["E", "malkos raga"],
// ["G", "ritusen"],
// ["A", "minor pentatonic"]
// ]
Scale.rangeOf
returns a function to create scale ranges:
const range = Scale.rangeOf("C pentatonic");
range("C4", "C5"); // => ["C4", "D4", "E4", "G4", "A4", "C5"]
Please note that the scale name must have tonic:
const range = Scale.rangeOf("pentatonic");
range("C4", "C5"); // => []
This function also works with a collection of notes:
const range = Scale.rangeOf("C", "Db", "G");
range("C4", "C5"); // => ["C4", "Db4", "G4", "C5"]