Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
tonal-key
is a collection of functions to query about tonal keys.
This is part of tonal music theory library.
Example
const key = require('tonal-key')
key.scale('E mixolydian') // => [ 'E', 'F#', 'G#', 'A', 'B', 'C#', 'D' ]
key.relative('minor', 'C major') // => 'A minor'
.modeNames(alias)
⇒ Array
.fromAlter(alt)
⇒ Key
.props(name)
⇒ Object
.scale(key)
⇒ Array
.alteration(key)
⇒ Integer
.accidentals(key)
⇒ String
.alteredNotes(key)
⇒ Array
.chords(name)
⇒ Array
.secDomChords(name)
⇒ Array
.relative(mode, key)
.tokenize(name)
⇒ Array
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
Param | Type | Description |
---|---|---|
alias | Boolean | true 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
Param | Type | Description |
---|---|---|
alt | Integer | the alteration number (positive sharps, negative flats) |
Example
var key = require('tonal-key')
key.fromAlter(2) // => 'D major'
key.props(name)
⇒ Object
Return the a key properties object with the following information:
Kind: static method of key
Returns: Object
- the key properties object or null if not a valid key
Param | Type | Description |
---|---|---|
name | String | the key name |
Example
var key = require('tonal-key')
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
Param | Type |
---|---|
key | String | 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.alteration(key)
⇒ Integer
Get key alteration. The alteration is a number indicating the number of sharpen notes (positive) or flaten notes (negative)
Kind: static method of key
Param | Type |
---|---|
key | String | Integer |
Example
var key = require('tonal-keys')
key.alteration('A major') // => 3
key.accidentals(key)
⇒ String
Get key accidentals: a string with sharps or flats
Kind: static method of key
Param | Type |
---|---|
key | String |
Example
import * as key from 'tonal-keys'
key.accidentals('A major') // => "###"
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
Param | Type | Description |
---|---|---|
key | String | the key name |
Example
var key = require('tonal-keys')
key.alteredNotes('Eb major') // => [ 'Bb', 'Eb', 'Ab' ]
key.chords(name)
⇒ Array
Get key chords
Kind: static method of key
Param | Type | Description |
---|---|---|
name | String | the key name |
Example
key.chords("A major") // => ["AMaj7", "Bm7", "C#m7", "DMaj7", ..,]
key.secDomChords(name)
⇒ Array
Get secondary dominant key chords
Kind: static method of key
Param | Type | Description |
---|---|---|
name | String | the 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
Param | Type | Description |
---|---|---|
mode | String | the relative destination |
key | String | the 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]
Param | Type |
---|---|
name | String |
Example
key.tokenize('C major') // => ['C', 'major']
FAQs
Conversion between key numbers and note names
The npm package tonal-key receives a total of 0 weekly downloads. As such, tonal-key popularity was classified as not popular.
We found that tonal-key demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.