music-key

    0.1.1 • Public • Published

    music-key npm

    license tonal

    music-key is a collection of functions to create and manipulate music keys:

    var key = require('music-key')
    key('###') // => 'A major'
    key.signature('A major') // => '###'
    key.altNotes('A major') // => ['F#', 'C#']
    key.relative('minor', 'A major') // => '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:

    key('C major') // => 'C major'
    key('C') // => 'C major'
    key('#') // => 'G major'
    key('bb') // => 'Eb major'

    Relative keys

    You can get relative keys:

    key.relative('minor', 'C major') // => 'A minor'
    key.relative('minor', key('#')) // => 'E minor'

    This function can be partially applied:

    var minor = key.relative('minor')
    minor('C major') // => 'A minor'

    Get key signature and altered notes

    The key signature is a string with the flats or sharps:

    key.signature('F major') // => 'b'
    key.signature('Eb major') // => 'bbb'
    key.signature('A major') // => '###'
    key.altNotes('F major') // => ['Bb']
    key.altNotes('Eb major') // => ['Bb', 'Eb', 'Ab']
    key.altNotes('A major') // => ['F#', 'C#', 'G#']

    The altered notes are returned in its proper order:

    key.altNotes('F major') // => ['Bb']
    key.altNotes('Eb major') // => ['Bb', 'Eb', 'Ab']
    key.altNotes('A major') // => ['F#', 'C#', 'G#']

    Get key scale

    key.scale('C major') // => ['C', 'D', 'E', 'F', 'G', 'A', 'B']

    License

    MIT License

    Install

    npm i music-key

    DownloadsWeekly Downloads

    0

    Version

    0.1.1

    License

    MIT

    Last publish

    Collaborators

    • avatar