2.2.2 • Published 5 years ago

tonal-key v2.2.2

Weekly downloads
274
License
MIT
Repository
github
Last release
5 years ago

Key

npm version tonal

tonal-key is a collection of functions to query about tonal keys.

This is part of tonal music theory library.

Example

// es6
import * as Key from "tonal-key"
// es5
const Key = require("tonal-key")

Example

Key.scale("E mixolydian") // => [ "E", "F#", "G#", "A", "B", "C#", "D" ]
Key.relative("minor", "C major") // => "A minor"

Key.degreesArray

Get a list of key scale degrees in roman numerals

Kind: static constant of Key

ParamType
keyNamestring

Example

Key.degrees("C major") => ["I", "ii", "iii", "IV", "V", "vi", "vii"]

Key.modeNames(alias)Array

Get a list of valid mode names. The list of modes will be always in increasing order (ionian to locrian)

Kind: static method of Key
Returns: Array - an array of strings

ParamTypeDescription
aliasBooleantrue to get aliases names

Example

Key.modes() // => [ "ionian", "dorian", "phrygian", "lydian",
// "mixolydian", "aeolian", "locrian" ]
Key.modes(true) // => [ "ionian", "dorian", "phrygian", "lydian",
// "mixolydian", "aeolian", "locrian", "major", "minor" ]

Key.fromAlter(alt)Key

Create a major key from alterations

Kind: static method of Key
Returns: Key - the key object

ParamTypeDescription
altIntegerthe alteration number (positive sharps, negative flats)

Example

Key.fromAlter(2) // => "D major"

Key.props(name)Object

Return the a key properties object with the following information:

  • name {string}: name
  • tonic {string}: key tonic
  • mode {string}: key mode
  • modenum {Number}: mode number (0 major, 1 dorian, ...)
  • intervals {Array}: the scale intervals
  • scale {Array}: the scale notes
  • acc {string}: accidentals of the key signature
  • alt {Number}: alteration number (a numeric representation of accidentals)

Kind: static method of Key
Returns: Object - the key properties object or null if not a valid key

ParamTypeDescription
namestringthe key name

Example

Key.props("C3 dorian") // => { tonic: "C", mode: "dorian", ... }

Key.scale(key)Array

Get scale of a key

Kind: static method of Key
Returns: Array - the key scale

ParamType
keystring | Object

Example

Key.scale("A major") // => [ "A", "B", "C#", "D", "E", "F#", "G#" ]
Key.scale("Bb minor") // => [ "Bb", "C", "Db", "Eb", "F", "Gb", "Ab" ]
Key.scale("C dorian") // => [ "C", "D", "Eb", "F", "G", "A", "Bb" ]
Key.scale("E mixolydian") // => [ "E", "F#", "G#", "A", "B", "C#", "D" ]

Key.alteredNotes(key)Array

Get a list of the altered notes of a given Key. The notes will be in the same order than in the key signature.

Kind: static method of Key

ParamTypeDescription
keystringthe key name

Example

Key.alteredNotes("Eb major") // => [ "Bb", "Eb", "Ab" ]

Key.leadsheetSymbols(symbols, keyName, [degrees])function

Get a lead-sheet symbols for a given key name

This function is currified (so can be partially applied)

From http://openmusictheory.com/triads.html

A lead-sheet symbol begins with a capital letter (and, if necessary, an accidental) denoting the root of the chord. That letter is followed by information about a chord’s quality:

  • major triad: no quality symbol is added
  • minor triad: lower-case “m”
  • diminished triad: lower-case “dim” or a degree sign “°”
  • augmented triad: lower-case “aug” or a plus sign “+”

Kind: static method of Key
See

  • Key.chords
  • Key.triads
ParamTypeDescription
symbolsArray.<string>an array of symbols in major scale order
keyNamestringthe name of the key you want the symbols for
degreesArray.<string>the list of degrees. By default from 1 to 7 in ascending order

Example

const chords = Key.leadsheetSymbols(["M", "m", "m", "M", "7", "m", "dim"])
chords("D dorian") //=> ["Dm", "Em", "FM", "G7", "Am", "Bdim", "CM"]
chords("D dorian", ['ii', 'V']) //=> [Em", "G7"]

Key.chords(name, [degrees])Array.<string>

Get key seventh chords

Kind: static method of Key
Returns: Array.<string> - seventh chord names

ParamTypeDescription
namestringthe key name
degreesArray.<(number|string)>can be numbers or roman numerals

Example

Key.chords("A major") // => ["AMaj7", "Bm7", "C#m7", "DMaj7", ..,]
Key.chords("A major", ['I', 'IV', 'V']) // => ["AMaj7", "DMaj7", "E7"]
Key.chords("A major", [5, 4, 1]) // => ["E7", "DMaj7", AMaj7"]

Key.triads(name, [degrees])Array.<string>

Get key triads

Kind: static method of Key
Returns: Array.<string> - triad names

ParamTypeDescription
namestringthe key name
degreesArray.<(string|number)>

Example

Key.triads("A major") // => ["AM", "Bm", "C#m", "DM", "E7", "F#m", "G#mb5"]
Key.triads("A major", ['I', 'IV', 'V']) // => ["AMaj7", "DMaj7", "E7"]
Key.triads("A major", [1, 4, 5]) // => ["AMaj7", "DMaj7", "E7"]

Key.secDomChords(name)Array

Get secondary dominant key chords

Kind: static method of Key

ParamTypeDescription
namestringthe key name

Example

Key.secDomChords("A major") // => ["E7", "F#7", ...]

Key.relative(mode, key)

Get relative of a key. Two keys are relative when the have the same key signature (for example C major and A minor)

It can be partially applied.

Kind: static method of Key

ParamTypeDescription
modestringthe relative destination
keystringthe key source

Example

Key.relative("dorian", "B major") // => "C# dorian"
// partial application
var minor = Key.relative("minor")
minor("C major") // => "A minor"
minor("E major") // => "C# minor"

Key.tokenize(name)Array

Split the key name into its components (pitch class tonic and mode name)

Kind: static method of Key
Returns: Array - an array in the form tonic, key

ParamType
namestring

Example

Key.tokenize("C major") // => ["C", "major"]
2.2.2

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.0

6 years ago

1.1.2

6 years ago

1.1.0

7 years ago

1.0.0

7 years ago

1.0.0-pre6

7 years ago

1.0.0-pre5

7 years ago

1.0.0-pre4

7 years ago

1.0.0-pre3

7 years ago

1.0.0-pre2

7 years ago

1.0.0-1

7 years ago

1.0.0-0

7 years ago

0.69.9

7 years ago

0.69.8

7 years ago

0.69.7

7 years ago

0.69.6

7 years ago

0.69.5

7 years ago

0.69.4

7 years ago

0.69.3

7 years ago

0.69.2

7 years ago

0.69.1

7 years ago

0.69.0

7 years ago

0.68.1

7 years ago

0.68.0

7 years ago

0.67.0

7 years ago

0.66.0

7 years ago

0.65.0

7 years ago

0.64.1

7 years ago

0.64.0

7 years ago

0.63.1

7 years ago

0.63.0

7 years ago

0.62.0

7 years ago

0.61.0

7 years ago

0.60.0

7 years ago

0.50.2

8 years ago

0.50.1

8 years ago

0.50.0

8 years ago