Keys & Modes
Compute scale notes for any root and diatonic mode, traverse key relationships, and look up note positions and scale degrees.
Live Playground
Section titled “Live Playground”getModeNotes(root: Note, mode: ModeName): Note[]Returns all notes in a diatonic mode for the given root.
C, D, E, F, G, A, BC, D, E, F, G, A, BC, D, E, F, G, A, BCircle of fifths
Section titled “Circle of fifths”getCircleOfFifthsOrder returns all 12 chromatic notes in ascending-fifths order starting from C.
C, G, D, A, E, B, F#, C#, G#, D#, A#, FC, G, D, A, E, B, Gb, Db, Ab, Eb, Bb, FC, G, D, A, E, B, Gb/F#, Db/C#, Ab/G#, Eb/D#, Bb/A#, FgetCircleOfFifthsOrder()Key signatures
Section titled “Key signatures”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.
{
"sharps": 0
}0 sharpsgetKeySignatureCount(Notes.C, KeyQualities.Major)getSpelledAccidentalCount(notes, getRootLetter(Notes.C, 'sharp'))
Scale & Mode Functions
Section titled “Scale & Mode Functions”- Scale and mode:
getModeNotes,getParentScaleModes, andgetModalRootcompute the note set and modal rotations for any root and mode combination. - Key relationships:
getRelativeMinorKeyandgetRelativeMajorKeyfind relative keys. See Circle of fifths and Key signatures above forgetCircleOfFifthsOrderandgetKeySignatureCount. - Note utilities:
getSemitoneDistancecomputes the ascending semitone gap between any two notes. For scale degree lookup and membership checks across all scale types, seegetScaleDegreeandisNoteInScaleon the Scales page. See the Constants page for the full note and mode constant catalog. - Type guards:
isNote,isModeName,parseNote, andparseModeNamenarrow untrusted strings - URL params, user input, or external data - to typedNoteorModeNamevalues before passing them to engine functions.isNoteandisModeNameare case-insensitive;parseNoteandparseModeNamereturn canonical values.parseNoteand the stricter, exact-matchparseNoteTokenalso accept flat-spelled note names (Db,Eb,Gb,Ab,Bb), normalizing them to their canonical sharp equivalent. - Note spelling:
getSharps,getFlats, andgetEnharmonicLabelsrespell already-computed note output as sharps, flats, or combined enharmonic labels.spellDiatonicScaleandgetRootLettergo further, producing full letter-correct spelling for 7-note diatonic scales - see the Constants page.