Universal Music Theory Library - v0.12.0
    Preparing search index...

    Class CircleOfFifths

    Circle of Fifths utility. Convention: major keys use uppercase ('C', 'G'...), minor keys use lowercase ('a', 'e'...). Methods that return keys follow this same convention - callers should use case to distinguish mode.

    Index

    Constructors

    Properties

    majorKeys: string[] = ...

    Major keys clockwise from C, in upper case.

    minorKeys: string[] = ...

    Minor keys clockwise from A, in lower case ('a' is A minor), aligned with their relative majors.

    Methods

    • Shortest distance (0–6) between two keys on the same circle. Returns -1 if keys are of different modes or unrecognized.

      Parameters

      • key1: string
      • key2: string

      Returns number

    • Gets the dominant key (perfect fifth up / one step clockwise).

      Parameters

      • key: string

      Returns string

    • Returns the circle-of-fifths distance between the parent major keys of two modal keys. Distance 0 means both modes share the same parent major key.

      Parameters

      Returns number

    • Returns the ModalKey for a given root and mode name, computing the parent major key (the major scale from which this mode is derived).

      For example, D dorian → parent major key = C (D is degree 2 of C major). Only the 7 diatonic modes of the major family are supported.

      Parameters

      • root: string
      • mode: string

      Returns ModalKey

    • Returns modal keys with the same root and adjacent brightness (within radius steps). Neighbors are modes of the same root note that are brighter or darker than the input.

      Parameters

      Returns ModalKey[]

    • Returns keys within radius steps on the same circle, sorted closest first. Clockwise neighbor before counter-clockwise at each distance. Excludes key itself.

      Parameters

      • key: string
      • radius: number = 1

      Returns string[]

    • Returns the parallel key - same root, opposite mode. 'C' → 'c', 'a' → 'A', 'F#' → 'f#'.

      Parameters

      • key: string

      Returns string

    • Returns the 0–11 index of the key on its circle (C/a = 0, G/e = 1…). Returns -1 if the key is not recognized.

      Parameters

      • key: string

      Returns number

    • Returns all tonally related keys sorted by distance ascending. Covers: relative, parallel, dominant, subdominant, and ±2 neighbors.

      Parameters

      • key: string

      Returns RelatedKey[]

    • Gets the relative minor for a major key, or relative major for a minor key.

      Parameters

      • key: string

      Returns string

    • Returns the key signature of a key as written: Gb → 6 flats, F# → 6 sharps, C# → 7 sharps, eb → 6 flats. Theoretical keys go past 7 (G# → 8 sharps). Unrecognized keys → no accidentals.

      Parameters

      • key: string

      Returns { flats: number; sharps: number }

      • flats: number

        Number of flats in the key signature.

      • sharps: number

        Number of sharps in the key signature.

    • Gets the subdominant key (perfect fourth up / one step counter-clockwise).

      Parameters

      • key: string

      Returns string

    • Moves steps positions clockwise (positive) or counter-clockwise (negative). Returns empty string if key is not recognized.

      Parameters

      • key: string
      • steps: number

      Returns string