music-key
music-key
is a collection of functions to create and manipulate music keys:
var key = // => 'A major'key // => '###'key // => ['F#', 'C#']key // => 'F minor'
This is part of tonal
Installation
Via npm: npm i --save music-key
User guide
Valid keys
A key in music-key
is a string with a tonic and (optionally) a mode: 'C'
, 'C major'
,'C minor'
,'Ab dorian'
are valid keys. The valid modes are: major
, minor
, ionian
, dorian
, phrygian
, lydian
, mixolydian
, aeolian
and locrian
(major
if not specified).
Create keys
The key function returns a key from a name or from a signature:
// => 'C major' // => 'C major' // => 'G major' // => 'Eb major'
Relative keys
You can get relative keys:
key // => 'A minor'key // => 'E minor'
This function can be partially applied:
var minor = key // => 'A minor'
Get key signature and altered notes
The key signature is a string with the flats or sharps:
key // => 'b'key // => 'bbb'key // => '###'key // => ['Bb']key // => ['Bb', 'Eb', 'Ab']key // => ['F#', 'C#', 'G#']
The altered notes are returned in its proper order:
key // => ['Bb']key // => ['Bb', 'Eb', 'Ab']key // => ['F#', 'C#', 'G#']
Get key scale
key // => ['C', 'D', 'E', 'F', 'G', 'A', 'B']
License
MIT License