Skip to content

key_to_notes

key_to_notes(key, unicode?): string[]

Defined in: packages/pleco-xa/src/scripts/xa-notation.js:149

List all 12 note names in the chromatic scale, as spelled according to a given key. The returned array is indexed by pitch class (0 == C), NOT rotated to the tonic, and the sharp/flat choice follows the key’s position on the circle of fifths (explicit accidental in the tonic forces the side). Unknown keys THROW \u2014 the legacy silent C:maj fallback is repaired.

string

Key signature (e.g., ‘C:maj’, ‘Eb:min’, ‘F\u266F:maj’)

boolean = true

If true, use unicode symbols (\u266F/\uD834\uDD2A/\u266D/\uD834\uDD2B)

string[]

List of 12 note names indexed by pitch class

key_to_notes('C:maj', false) // ['C','C#','D','D#','E','F','F#','G','G#','A','A#','B']
key_to_notes('Eb:maj', false) // ['C','Db','D','Eb','E','F','Gb','G','Ab','A','Bb','B']
key_to_notes('A:min', false) // same spelling as C:maj (relative keys share a signature)