Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
tonal-key
is a collection of functions to create and manipulate music keys.
This is part of tonal music theory library.
You can install via npm: npm i --save tonal-key
Array
Get scale of a key
Get relative of a key. It can be partially applied.
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.
Array
Get a list of valid mode names. The list of modes will be always in increasing order (ionian to locrian)
Boolean
Check if the given string is a valid mode name
Key
Build a key object from tonic a mode.
A key object is an array with the mode name and the tonic (or false if no tonic specified)
Key
Create a major key from alterations
Key
Create a major key from accidentals
Key
Create a key from key name
Key
Try to interpret the given object as a key. Given an object it will try to parse as if it were a name, accidentals or alterations.
Integer
Get key alteration. The alteration is a number indicating the number of sharpen notes (positive) or flaten notes (negative)
Get the signature of a key. The signature is a string with sharps or flats.
An alias for signature()
Array
Get scale of a key
Kind: global function
Returns: Array
- the key scale
Param | Type |
---|---|
key | String | Object |
Example
var key = require('tonal-key')
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' ]
Get relative of a key. It can be partially applied.
Kind: global function
Param | Type | Description |
---|---|---|
mode | String | the relative destination |
key | String | the key source |
Example
var key = require('tonal-keys')
key.relative('dorian', 'C major') // => ['dorian', 'D']
// partially application
var minor = key.relative('minor')
minor('C major') // => ['minor', 'A']
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: global function
Param | Type |
---|---|
key | String | Nunber |
Example
var key = require('tonal-keys')
key.alteredNotes('Eb major') // => [ 'Bb', 'Eb', 'Ab' ]
Array
Get a list of valid mode names. The list of modes will be always in increasing order (ionian to locrian)
Kind: global function
Returns: Array
- an array of strings
Param | Type | Description |
---|---|---|
alias | Boolean | true to get aliases names |
Boolean
Check if the given string is a valid mode name
Kind: global function
Param | Type |
---|---|
m | String |
Key
Build a key object from tonic a mode.
A key object is an array with the mode name and the tonic (or false if no tonic specified)
Kind: global function
Returns: Key
- a key data object
Param | Type | Description |
---|---|---|
tonic | String | the key tonic (or null or false to no tonic) |
mode | String | the keymode |
Example
var key = require('tonal-key')
key.build('g3', 'minor') // => ['minor', 'G']
key.build(false, 'locrian') // => ['locrian', false]
Key
Create a major key from alterations
Kind: global function
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) // => ['major', 'D']
Key
Create a major key from accidentals
Kind: global function
Returns: Key
- the key object
Param | Type | Description |
---|---|---|
acc | String | the accidentals string |
Example
var key = require('tonal-key')
key.fromAlter('bb') // => ['major', 'Bb']
Key
Create a key from key name
Kind: global function
Returns: Key
- the key object or null if not valid key
Param | Type | Description |
---|---|---|
name | String | the key name |
Example
var key = require('tonal-key')
key.fromName('C3 dorian') // => ['dorian', 'C']
key.fromName('blah') // => null
Key
Try to interpret the given object as a key. Given an object it will try to parse as if it were a name, accidentals or alterations.
Kind: global function
Returns: Key
- the key object or null
Param | Type |
---|---|
obj | Object |
Integer
Get key alteration. The alteration is a number indicating the number of sharpen notes (positive) or flaten notes (negative)
Kind: global function
Param | Type |
---|---|
key | String | Integer |
Example
var key = require('tonal-keys')
key.alteration('A major') // => 3
Get the signature of a key. The signature is a string with sharps or flats.
Kind: global function
Example
var key = require('tonal-keys')
key.signature('A major') // => '###'
An alias for signature()
Kind: global function
FAQs
Conversion between key numbers and note names
The npm package tonal-key receives a total of 735 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.