Skip to content

Keys & Modes

Compute scale notes for any root and diatonic mode, traverse key relationships, and look up note positions and scale degrees.

getModeNotes(root: Note, mode: ModeName): Note[]

Returns all notes in a diatonic mode for the given root.

ResultC, D, E, F, G, A, B
FlatC, D, E, F, G, A, B
EnharmonicC, D, E, F, G, A, B

getCircleOfFifthsOrder returns all 12 chromatic notes in ascending-fifths order starting from C.

ResultC, G, D, A, E, B, F#, C#, G#, D#, A#, F
FlatC, G, D, A, E, B, Gb, Db, Ab, Eb, Bb, F
EnharmonicC, G, D, A, E, B, Gb/F#, Db/C#, Ab/G#, Eb/D#, Bb/A#, F
getCircleOfFifthsOrder()

getKeySignatureCount returns the sharp or flat count for a key. quality defaults to major; pass 'minor' to resolve a minor key’s signature via its relative major. It always answers with whichever enharmonic spelling is conventionally written - pick A# and it returns Bb major’s 2 flats, since that’s the key signature actually used in practice.

For the count of the root exactly as spelled - which is what a handful of keys like A# major actually need, sharps and double-sharps included, not their conventional flat-spelled twin - see getSpelledAccidentalCount on the Constants page. The explorer below shows both side by side.

getKeySignatureCount (conventional spelling)
{
  "sharps": 0
}
Spelled as C (sharp)0 sharps
getKeySignatureCount(Notes.C, KeyQualities.Major)getSpelledAccidentalCount(notes, getRootLetter(Notes.C, 'sharp'))
  • Scale and mode: getModeNotes, getParentScaleModes, and getModalRoot compute the note set and modal rotations for any root and mode combination.
  • Key relationships: getRelativeMinorKey and getRelativeMajorKey find relative keys. See Circle of fifths and Key signatures above for getCircleOfFifthsOrder and getKeySignatureCount.
  • Note utilities: getSemitoneDistance computes the ascending semitone gap between any two notes. For scale degree lookup and membership checks across all scale types, see getScaleDegree and isNoteInScale on the Scales page. See the Constants page for the full note and mode constant catalog.
  • Type guards: isNote, isModeName, parseNote, and parseModeName narrow untrusted strings - URL params, user input, or external data - to typed Note or ModeName values before passing them to engine functions. isNote and isModeName are case-insensitive; parseNote and parseModeName return canonical values. parseNote and the stricter, exact-match parseNoteToken also accept flat-spelled note names (Db, Eb, Gb, Ab, Bb), normalizing them to their canonical sharp equivalent.
  • Note spelling: getSharps, getFlats, and getEnharmonicLabels respell already-computed note output as sharps, flats, or combined enharmonic labels. spellDiatonicScale and getRootLetter go further, producing full letter-correct spelling for 7-note diatonic scales - see the Constants page.