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

    Class Interval

    A pitch interval, held as its size in cents.

    Index

    Constructors

    • Create an interval from a value in cents. Prefer fromCents() or fromRatio() for clarity.

      Parameters

      • cents: number

        Size in cents (1200 = octave); negative for a descending interval.

      Returns Interval

    Properties

    cents: number

    Size in cents (1200 = octave); negative for a descending interval.

    Accessors

    • get ratio(): number

      The interval as a decimal frequency ratio (e.g. 1.5 for a perfect fifth).

      Returns number

    • get semitones(): number

      The interval in semitones (cents / 100). May be fractional for microtonal intervals.

      Returns number

    Methods

    • Compare two intervals within a tolerance.

      Parameters

      • other: Interval

        The interval to compare against.

      • toleranceCents: number = 1

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

      Returns boolean

    • Reduce the interval to a single octave (0–1200 cents). Useful for pitch-class equivalence and scale analysis.

      Returns Interval

    • Return the descending (negative) form of this interval. Useful for voice leading and downward transposition.

      Returns Interval

    • Create an interval from a frequency ratio.

      Parameters

      • ratio: Ratio

        Integer fraction [numerator, denominator] or decimal (e.g. [3,2] or 1.5 for a perfect fifth).

      Returns Interval

      if the ratio is zero, negative, or not finite.