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

    Class Note

    A single pitch in a given tuning system.

    Position is stored as stepsFromBase, an integer offset from A4 (step 0) within the tuning. The same step number means different frequencies in different tuning systems.

    Index

    Constructors

    • Parameters

      • tuningSystem: TuningSystem

        The tuning system this note belongs to.

      • stepsFromBase: number

        Steps from A4 (= 0). Can be negative (below A4) or positive (above).

      • Optional_name: string

        Optional explicit name including octave (e.g. "Db4"). When provided, overrides the computed name from the tuning system. Used by the parser to preserve the original user notation (e.g. "Db4" vs "C#4").

      • Optional_preferFlats: boolean

        Optional flat/sharp preference for computed names. Propagated by transpose() and set by Scale.getNotes() / Chord.getNotes() based on key context. Ignored when _name is provided (the explicit name takes precedence).

      Returns Note

    Properties

    stepsFromBase: number

    Steps from A4 (= 0). Can be negative (below A4) or positive (above).

    tuningSystem: TuningSystem

    The tuning system this note belongs to.

    Accessors

    • get centsFromBase(): number

      Interval from A4 to this note in cents.

      Returns number

    • get frequency(): number

      Frequency of this note in Hz.

      Returns number

    • get name(): string

      The full note name including octave number (e.g. "C4", "Bb3", "F#5"). In 12-TET, the octave follows scientific pitch notation: C4 = middle C. Uses the flat/sharp preference set at construction. For an explicit override use getName({ preferFlats: true/false }).

      Returns string

      UMT.parseChordSymbol('Cmaj7').getNotes().map(n => n.name)
      // → ['C4', 'E4', 'G4', 'B4']
    • get octave(): number

      Octave number relative to A4. A4–G#4 = octave 0, A5–G#5 = octave 1, A3–G#3 = octave −1.

      Returns number

    • get pitchClass(): number

      Step position within one period (0 to octaveSteps - 1). Equivalent to pitch class in 12-TET (0 = A, 3 = C, etc.).

      Returns number

    • get preferFlats(): boolean

      The flat/sharp preference for this note's computed name. Derived from the explicit _name (true if it contains a flat accidental) or from the stored _preferFlats flag (false by default). This value is propagated by transpose().

      Returns boolean

    • get scientificOctave(): number | null

      Octave number of the written name, in scientific pitch notation: C4 is middle C, B3 is the note below it, and B#3 (same pitch as C4) keeps octave 3. Not the same as octave, which counts from A4. Null when the name carries no octave.

      Returns number | null

    Methods

    • Returns true if this note has the same pitch as other, within a tolerance.

      Parameters

      • other: Note
      • toleranceCents: number = 1

        Maximum allowed frequency difference in cents (default: 1¢).

      Returns boolean

    • Returns the interval from this note to other. Works across different tuning systems by comparing frequencies.

      Parameters

      Returns Interval

      if either note's frequency is not a positive finite number.

    • Returns the full note name including octave (e.g. "C4", "Bb3"), optionally overriding the stored flat/sharp preference. If an explicit name was set at construction, it is returned as-is (no re-spelling). Otherwise, uses _preferFlats if set, then falls back to options.preferFlats, then sharps.

      Parameters

      • Optionaloptions: { preferFlats?: boolean }

      Returns string

    • The same note in another tuning: the step of tuning that stands for the same 12-TET note (TuningSystem.retuneStep). The written name and flat/sharp preference are kept.

      Parameters

      Returns Note | null

      The note in tuning, or null when this note stands for no 12-TET note or tuning has no step for it.

    • Returns a new note transposed by the given number of steps in the same tuning system. By whole octaves an explicit name keeps its letter (D#4 → D#5). Otherwise the name is computed again, with the flat/sharp preference of _name or _preferFlats.

      Parameters

      • steps: number

      Returns Note