music-scale
music-scale
is a module to create music scales. To create scales you can use intervals and tonic, type and tonic or scale name:
var scale = // get scale from namescale // => ['A', 'B', 'C#', 'D', 'E', 'F#', 'G#'] // get scale from type and tonic // => ['A4', 'B4', 'C#4', 'D4', 'E4', 'F#4', 'G#4'] // get scale from intervals and tonic // => ['A', 'B', 'C#', 'D', 'E', 'F#', 'G#'] // partially appliedvar major = // => ['A', 'B', 'C#', 'D', 'E', 'F#', 'G#'] // => ['A4', 'B4', 'C#4', 'D4', 'E4', 'F#4', 'G#4']
This is part of tonal:
var tonal = tonalscale // => ...
Install
Via npm: npm i --save music-scale
Usage
Scales are a pitch sets with a tonic. Scales can be created from a list of intervals and a tonic, from a scale type and tonic, or from scale name.
Create scales from name
You can use scale.get
function to obtain scale notes from scale name:
scale // => ['C', 'D', 'E', 'F', 'G', 'A', 'B']
With scale
function, you should pass the scale type and tonic as two parameters:
// => ['C', 'D', 'E', 'F', 'G', 'A', 'B']
Or partially apply it:
var major = // => ['A', 'B', 'C#', 'D', 'E', 'F#', 'G#']
Get available names
The scale.names
function returns available names:
scale // => ['Maj7', 'm7', ...]scale // => ['Maj7', 'm7', ...] <= with aliases
Create scale from intervals
// => ['D', 'E', 'F', 'G', 'A', 'Bb', 'C#']
This function can be partially applied:
var dorian = // => [ 'Eb', 'F', 'Gb', 'Ab', 'Bb', 'C', 'Db' ]
The source can be also another scale:
// => ['A', 'B', 'C#' 'D', 'E', 'F#', 'G#']
Or even a collection of notes:
// => ['C', 'D', 'G', 'A']
Scale tonics
If the tonic of a scale is a pitch class (a note without octave) the notes of the scale are pitch classes:
var major = // => ['A', 'B', 'C#' 'D', 'E', 'F#', 'G#']
If the tonic of the scale is a note with octave, the notes of the scale will have octave numbers:
// => ['A4', 'B4', 'C#5' ,'D5', 'E5', 'F#5', 'G#5']
If the tonic is null and the source are notes, the first pitch class of the scale source will be the tonic:
// => ['C', 'D', 'E', 'F', 'G', 'A', 'B'] // => [ 'D', 'F', 'G', 'A', 'C' ]
Get scale intervals
If the tonic of a scale is false, the intervals are returned:
// => ['P1', 'M2', 'M3', 'P4', 'P5', 'M6', 'M7']
License
MIT License