sonic-weave
    Preparing search index...

    Class Interval

    A musical interval associated with a domain, an AST node, CSS color, note label and tracking identifiers.

    Index

    Constructors

    • Construct a musical interval.

      Parameters

      • value: TimeReal | TimeMonzo

        A time monzo representing the size and echelon (frequency vs. frequency ratio) of the interval.

      • domain: IntervalDomain

        Domain determining what addition means.

      • steps: number = 0

        A steps offset used in tempering.

      • Optionalnode: IntervalLiteral

        Node in the abstract syntax tree used for string representation.

      • Optionalconvert: Interval

        Another Interval instance to obtain CSS color, note label and tracking information from.

      Returns Interval

    Properties

    color?: Color
    label: string
    steps: number
    trackingIds: Set<number>

    Methods

    • Calculate the absolute value of a linear interval or obtain a logarithmic intervals distance to unison.

      Returns Interval

      Absolute value of this interval.

    • Add two linear intervals or multiply the underlying values of two logarithmic intervals.

      Parameters

      Returns Interval

      Sum of the intervals.

    • Convert the interval to a virtual AST node representing the universal type.

      Parameters

      • interchange: boolean = false

        Boolean flag to format everything explicitly.

      Returns MonzoLiteral

      A virtual monzo literal.

    • Calculate this many steps of the octave equally divided into other parts.

      Parameters

      • other: Interval

        Another interval (the edo).

      Returns Interval

      A logarithmic quantity representing two to the power of the ratio of the intervals.

    • Remove stored context-dependent formatting information. (Triggered by a context shift.)

      Parameters

      • force: boolean = false

      Returns void

    • Clone this instance including the value.

      Returns Interval

      An interval like this one but mutating the value won't change the original.

    • Return a number suitable for Array.sort() to indicate the size of this interval w.r.t. the other.

      Parameters

      Returns number

      A number that's less than zero if this is less than other, zero if equal and greater than zero otherwise.

    • Divide two linear intervals or take the root of the underlying value of a logarithmic interval with respect to a linear one. The ratio of two logarithmic intervals is a linear scalar equal to the logdivision of the underlying values.

      Parameters

      Returns Interval

      The ratio of the intervals.

    • Compute the dot product of the prime count vectors (monzos) associated with two intervals or an interval and a val.

      Parameters

      Returns Interval

      Linear domain interval representing the cosine of the unweighted angle between the prime counts.

    • Apply a down arrow to this interval.

      Parameters

      • context: RootContext

        Current root context with the value of "down" to apply.

      • count: number = 1

        How many down arrows to apply.

      Returns Interval

      A new interval with size decreased by the current "up" value.

    • Apply a drop to this interval.

      Parameters

      • context: RootContext

        Current root context with the value of "drop" to apply.

      Returns Interval

      A new interval with size decreased by the current "lift" value.

    • Check if this interval has the same size as another.

      Parameters

      Returns boolean

      true if this has the same size as the other.

    • Invert the value of a linear interval or convert a logarithmic interval to a val that maps it to unity.

      Returns Interval | Val

      Inverse of this interval.

    • Calculate the recipropower between two linear intervals.

      Parameters

      Returns Interval

      The root of this interval with respect to the other.

    • Return true if the interval could be interpreted as a frequency.

      Returns boolean

    • Return true if this interval is only composed of abstract edosteps.

      Returns boolean

      true if the interval is a unit scalar, possibly with edosteps, false otherwise.

    • Return true if the interval represents a ratio of frequencies.

      Returns boolean

    • Divide another interval by this one.

      Parameters

      Returns Interval

      The ratio of the intervals (with swapped arguments).

    • Harmonically add two intervals.

      Parameters

      Returns Interval

      The lens sum of the intervals.

    • Harmonically subtract two intervals.

      Parameters

      Returns Interval

      The lens difference of the intervals.

    • Apply a lift to this interval.

      Parameters

      • context: RootContext

        Current root context with the value of "lift" to apply.

      Returns Interval

      A new interval with size increased by the current "lift" value.

    • Calculate logdivision between two linear intervals.

      Parameters

      Returns Interval

      The logarithm of this in the base of the other.

    • Subtract this interval from another.

      Parameters

      Returns Interval

      Difference of the intervals (with swapped arguments).

    • Calculate the modulus of a linear interval with respect to another or reduce (repeatedly divide) the underlying value of a logarithmic interval by another.

      Parameters

      • other: Interval

        Another interval.

      • ceiling: boolean = false

        If true x.mmod(x) evaluates to x.

      Returns Interval

      This interval modulo other.

    • Multiply two linear intervals or raise the underlying value of a logarithmic interval to the power of a linear one.

      Parameters

      Returns Interval

      The product of the intervals.

    • Multiply two linear intervals or raise the underlying value of a logarithmic interval to the power of a linear one.

      Parameters

      • other: Val

        Another interval.

      Returns Val

      The product of the intervals.

    • Negate the frequency/value of a linear interval or reflect a logarithmic interval about the unison.

      Returns Interval

      Negative counterpart of this interval.

    • Calculate the geometric absolute value of a linter interval.

      Returns Interval

      Superunitary value.

    • Round a linear interval to a power of another.

      Parameters

      Returns Interval

      The closest power of the other to this one.

    • Raise a linear interval to the power of another.

      Parameters

      Returns Interval

      This interval exponentiated by the other.

    • Project the exponent of two to the given base.

      Parameters

      • base: Interval

        New base to replace prime two.

      Returns Interval

      N steps of equal divisions of the new base assuming this interval was N steps of an equally divided octave.

    • (This method is an optimization detail.) Convert aspiring nodes to true AST nodes for formatting.

      Parameters

      • context: RootContext

        Current root context with information about root pitch and size of ups and lifts.

      Returns IntervalLiteral | undefined

      A true AST node suitable for string conversion or undefined realization is impossible in the given context.

    • Equave-reduce a linear interval by another other.

      Parameters

      • other: Interval

        Another interval (the equave).

      • ceiling: boolean = false

        If true x.reduce(x) evaluates to x.

      Returns Interval

      This interval divided by the other until it's between it and unison.

    • Round a linear interval to a multiple of another or a logarithmic interval to a power of the underlying value of another.

      Parameters

      Returns Interval

      Closest multiple of the other to this one.

    • Clone this Interval instance without deeply copying any of the parts.

      Returns Interval

      An interval like this one but replacing any of the parts won't change the original.

    • Convert this interval to a string that faithfully represents it ignoring formatting, colors and labels. Doesn't depend on the current root context.

      Returns string

      String that has the same value and domain as this interval if evaluated as a SonicWeave expression.

    • Calculate the square root of the underlying value regardless of domain.

      Returns Interval

      The square root.

    • Convert this interval to a string that faithfully represents it ignoring colors and labels.

      Parameters

      • Optionalcontext: RootContext

        Current root context with information about root pitch and size of ups and lifts.

      Returns string

      String that has the same value and domain as this interval if evaluated as a SonicWeave expression.

    • Check for strict equality between this and another interval.

      Parameters

      Returns boolean

      true if the values share the same time exponent, prime exponents, residual and cents offset and the domains match.

    • Subtract two linear intervals or divide the underlying values of two logarithmic intervals.

      Parameters

      Returns Interval

      Difference of the intervals.

    • Convert the interval to a fraction in linear space.

      Returns Fraction

    • Convert the interval to an integer.

      Returns number

    • Serialize the time monzo to a JSON compatible object.

      Returns any

      The serialized object with property type set to 'Interval'.

    • Convert this interval to a string that faithfully represents it including color and label.

      Parameters

      • Optionalcontext: RootContext

        Current root context with information about root pitch and size of ups and lifts.

      • interchange: boolean = false

        Boolean flag to always include label and color.

      Returns string

      String that has the same value and domain as this interval if evaluated as a SonicWeave expression.

    • Return the size of the interval in cents.

      Parameters

      • ignoreSign: boolean = false

        Compute the size of the absolute value.

      Returns number

    • Apply an up arrow to this interval.

      Parameters

      • context: RootContext

        Current root context with the value of "up" to apply.

      Returns Interval

      A new interval with size increased by the current "up" value.

    • Convert a relative interval to a real number representing a ratio of frequencies. Convert an absolute interval to the scalar of its time unit.

      Returns number

      A real number.

    • Construct a linear domain interval from a fraction.

      Parameters

      • value: FractionValue

        Rational number to convert.

      • Optionalconvert: Interval

        Another Interval instance to obtain CSS color, note label and tracking information from.

      Returns Interval

      Musical interval representing a frequency ratio.

    • Construct a linear domain interval from an integer.

      Parameters

      • value: number | bigint

        Integer to convert.

      • Optionalconvert: Interval

        Another Interval instance to obtain CSS color, note label and tracking information from.

      Returns Interval

      Musical interval representing a harmonic.

    • Construct a linear domain interval from a real number.

      Parameters

      • value: number

        Real number to convert.

      • Optionalconvert: Interval

        Another Interval instance to obtain CSS color, note label and tracking information from.

      Returns Interval

      Musical interval representing a (possibly irrational) frequency ratio.

    • Revive an Interval instance produced by Interval.toJSON(). Return everything else as is.

      Intended usage:

      const data = JSON.parse(serializedData, Interval.reviver);
      

      Parameters

      • key: string

        Property name.

      • value: any

        Property value.

      Returns any

      Deserialized Interval instance or other data without modifications.