sonic-weave
    Preparing search index...

    Class TimeReal

    Arbitrary (but inaccurate) value measured in time-related units (usually Hz).

    Used to represent irrational frequencies and values like pi.

    Index

    Constructors

    • Construct a time real.

      Parameters

      • timeExponent: number

        Exponent of the seconds unit.

      • value: number

        Multiplier of the time unit.

      Returns TimeReal

    Properties

    timeExponent: number
    value: number

    Methods

    • Linear space absolute value of the time real.

      Returns TimeReal

      The time real unchanged or negated if negative originally.

    • Find the closest approximation of the time real in a harmonic series.

      Parameters

      • denominator: number

        Denominator of the harmonic series.

      Returns TimeMonzo

      The closest approximant in the series.

    • Simplify the time real using the given threshold.

      Parameters

      • Optionaleps: number

        Error threshold. Defaults to 0.001.

      Returns TimeMonzo

      Simple approximation of the time real.

    • Find the closest approximation of the time real in a subharmonic series.

      Parameters

      • numerator: number

        Numerator of the subharmonic series.

      Returns TimeMonzo

      The closest approximant in the series.

    • Obtain an AST node representing the time real as a cents literal.

      Returns CentsLiteral | undefined

      Cents literal or a hacky real cents literal if necessary.

    • Obtain an AST node representing the time real as a decimal.

      Returns DecimalLiteral | undefined

      Real decimal literal.

    • Obtain an AST node representing the time monzo as a monzo literal suitable for interchange between programs.

      Returns MonzoLiteral

      Monzo literal.

    • Obtain an AST node representing the time real as a monzo literal.

      Parameters

      • interchange: boolean = false

        Boolean flag to use Hz basis for the absolute echelon.

      Returns MonzoLiteral

      Monzo literal.

    • Create a copy of this TimeReal instance.

      Returns TimeReal

      Independent clone.

    • Compare this time real with another.

      Parameters

      Returns number

      Result < 0 if other is larger than this. Result > 0 if other is smaller than this. Result == 0 if other is equal to this in size.

    • Divide the time real with another in linear space i.e. subtract in logarithmic space.

      Parameters

      Returns TimeReal

      This real divided by the other in linear space.

    • Calculate the product of this time real's time exponents with another's.

      Parameters

      Returns Fraction

      Product of the time exponents as a fraction.

    • Check if this time real has the same size as another.

      Parameters

      Returns boolean

      true if the inputs are of equal size.

    • Obtain a convergent of this time real.

      Parameters

      • depth: number

        How many continued fraction coefficients to use after the whole part.

      Returns TimeMonzo

      Approximation of the time real.

    • Return a pitch-space negative of the time real.

      Returns TimeReal

      The frequency-space inverse of the time real.

    • Check if the time real lacks units of time/frequency.

      Returns boolean

      true if the time real isn't expressed in units of time.

    • Perform harmonic addition according to the thin lens equation f⁻¹ = u⁻¹ + v⁻¹.

      Parameters

      Returns TimeReal

      The reciprocal of the sum of the reciprocals.

    • Perform harmonic subtraction f⁻¹ = u⁻¹ - v⁻¹ (a variation of the thin lens equation).

      Parameters

      Returns TimeReal

      The reciprocal of the difference of the reciprocals.

    • Calculate the logarithm in the given base if it exists.

      Parameters

      Returns number

      x such that this ** x === other.

    • Multiply the time real with another in linear space i.e. add in logarithmic space.

      Parameters

      Returns TimeReal

      The product of the time reals in linear space.

    • Return the frequency-space negative of the time real.

      Returns TimeReal

      The linear negative of the time real.

    • Pitch space absolute value of the time real.

      Returns TimeReal

      The time real unchanged or inverted if less than one originally.

    • Calculate modulus in pitch space with respect to another time real.

      Parameters

      • other: TimeReal | TimeMonzo

        Another time real.

      • ceiling: boolean = false

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

      Returns TimeReal

      This reduced by the other.

    • Return the frequency-space square root of the time real.

      Returns TimeReal

      The pitch-space half of the time real.

    • Check for strict equality between this and another time real.

      Parameters

      Returns boolean

      true if the time reals share the same time exponent, and value.

    • Returns { denominator: bigint; numerator: bigint }

    • Convert a relative scalar to cents.

      Parameters

      • ignoreSign: boolean = false

        Ignore the linear sign of of the scalar.

      Returns number

      Size of this interval in cents.

    • Obtain an array of the time real representing a continued fraction. The first element always contains the whole part.

      Returns number[]

      Array of continued fraction coefficients.

    • Serialize the time real to a JSON compatible object.

      Returns { t: number; type: string; v: string | number }

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

    • Faithful string representation of the time real.

      Parameters

      • domain: Domain = 'linear'

        Domain of representation.

      Returns string

      String that evaluates to the same value as this time real.

    • Convert value to cents ignoring the time exponent.

      Parameters

      • ignoreSign: boolean = false

        Ignore the linear sign of of the scalar.

      Returns number

      Size of this interval in cents (only makes sense if relative).

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

      Returns number

      A real number.

    • Create a real-valued scalar from cents (1 cent = 1 centisemitone or 1200th of an octave).

      Parameters

      • cents: number

        Width of a musical interval in cents i.e. logarithmic size.

      Returns TimeReal

      Scalar in the relative echelon.

    • Create a real-valued frequency.

      Parameters

      • frequency: number

        Frequency of a musical note measured in hertz.

      Returns TimeReal

      Frequency value in the absolute echelon.

    • Create a real-valued scalar.

      Parameters

      • value: number

        Linear value of the scalar.

      Returns TimeReal

      Scalar in the relative echelon.

    • Revive a TimeReal instance produced by TimeReal.toJSON(). Return everything else as is.

      Intended usage:

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

      Parameters

      • key: string

        Property name.

      • value: any

        Property value.

      Returns any

      Deserialized TimeReal instance or other data without modifications.