Skip to content

Constants

Every constant below is exported from @playbykey/theory. The catalog covers the 12 chromatic CHROMATIC_NOTES, the 7 diatonic MODES, the full INTERVAL_DEFINITIONS map, SCALE_DEFINITIONS for derived scale types, and Notations for display mapping. Select inputs to see live values and the exact function call.

NOTES is the ordered list of all 12 chromatic notes. ENHARMONIC_LABELS maps each accidental note to its flat/sharp display string.

Enharmonic label
Natural - no enharmonic equivalent
ENHARMONIC_LABELS[Notes.C]

MODES describes each of the 7 diatonic modes - name, scale degree, and character. MODE_INTERVALS and MODE_SEMITONE_OFFSETS give the step sizes and absolute offsets from the root.

Ionian

Degree 1

Bright and resolved - the familiar major sound

Step intervals[2, 2, 1, 2, 2, 2, 1]
Semitone offsets[0, 2, 4, 5, 7, 9, 11]
NotesC, D, E, F, G, A, B
MODE_INTERVALS[Modes.Ionian]MODE_SEMITONE_OFFSETS[Modes.Ionian]getModeNotes(Notes.C, Modes.Ionian)

INTERVAL_DEFINITIONS maps each of the 14 interval IDs to a label and semitone count. half_step and whole_step describe scale motion between adjacent degrees; minor_2nd and major_2nd are named intervals from the root with the same semitone distances. resolveIntervalEndpoints uses this data to find the actual notes that bound an interval at a given root. See the Intervals page for the full distinction and live resolution.

INTERVAL_DEFINITIONS[Intervals.Perfect5th]  // { label: 'Perfect 5th', semitones: 7 }resolveIntervalEndpoints({ root: Notes.C, interval: Intervals.Perfect5th })
resolveIntervalEndpoints result
{
  "from": "C",
  "to": "G",
  "semitones": 7,
  "label": "Perfect 5th"
}

SCALE_DEFINITIONS maps each scale kind to a label and how its notes are computed. getScaleNotes uses this to return the correct note set for any root and scale type.

SCALE_DEFINITIONS[ScaleTypes.Major]getScaleNotes(Notes.C, ScaleTypes.Major)
getScaleNotes resultC, D, E, F, G, A, B

buildNoteMap(root, scaleType) returns one entry per in-scale note with note, scaleDegree (1-based), and semitoneOffset (0–11, distance from root). Notation is left to the consumer - use entry.note for letter labels or String(entry.scaleDegree) for numeric labels.

buildNoteMap(Notes.C, ScaleTypes.Major)
buildNoteMap result
[
  {
    "note": "C",
    "scaleDegree": 1,
    "semitoneOffset": 0
  },
  {
    "note": "D",
    "scaleDegree": 2,
    "semitoneOffset": 2
  },
  {
    "note": "E",
    "scaleDegree": 3,
    "semitoneOffset": 4
  },
  {
    "note": "F",
    "scaleDegree": 4,
    "semitoneOffset": 5
  },
  {
    "note": "G",
    "scaleDegree": 5,
    "semitoneOffset": 7
  },
  {
    "note": "A",
    "scaleDegree": 6,
    "semitoneOffset": 9
  },
  {
    "note": "B",
    "scaleDegree": 7,
    "semitoneOffset": 11
  }
]