sonic-weave
    Preparing search index...

    Class TimeMonzo

    Fractional monzo with multiplicative residue measured in time-related units (usually Hz).

    Used to represent the value of musical objects like 432Hz, 5/3 or 7\12 (N-of-EDO).

    Index

    Constructors

    • Construct a fractional monzo with multiplicative residue.

      Parameters

      • timeExponent: Fraction

        Exponent of the seconds unit.

      • primeExponents: FractionalMonzo

        Fractional monzo part.

      • Optionalresidual: Fraction

        Multiplicative residue that is too complex to fit in the vector part.

      Returns TimeMonzo

    Properties

    primeExponents: FractionalMonzo
    residual: Fraction
    timeExponent: Fraction

    Accessors

    • get numberOfComponents(): number

      Number of components in the monzo vector part.

      Returns number

    • set numberOfComponents(value: number): void

      Parameters

      • value: number

      Returns void

    • get octaves(): Fraction

      The first monzo component. The exponent of 2.

      Returns Fraction

    Methods

    • Linear space absolute value of the time monzo.

      Returns TimeMonzo

      The time monzo unchanged or negated if negative originally.

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

      Parameters

      • denominator: number

        Denominator of the harmonic series.

      Returns TimeMonzo

      The closest approximant in the series.

    • Simplify the time monzo using the given threshold.

      Parameters

      • Optionaleps: number

        Error threshold. Defaults to 0.001.

      Returns TimeMonzo

      Simple approximation of the time monzo.

    • Find the closest approximation of the time monzo 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 monzo as a cents literal.

      Returns CentsLiteral | undefined

      Cents literal or a hacky real cents literal if necessary.

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

      Returns DecimalLiteral | undefined

      Decimal literal or a real decimal literal if necessary.

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

      Parameters

      Returns FractionLiteral | undefined

      Fraction literal or undefined if representation fails.

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

      Returns IntegerLiteral | undefined

      Integer literal or undefined if representation fails.

    • 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 monzo as a monzo literal.

      Parameters

      • trimTail: boolean = true

      Returns MonzoLiteral

      Monzo literal.

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

      Parameters

      • Optionalnode: NedjiLiteral

        Reference node to infer formatting from.

      Returns NedjiLiteral | undefined

      NEDJI literal or undefined if representation fails.

    • Obtain a pseudo-AST node representing the time monzo as a radical.

      Returns RadicalLiteral | undefined

      Radical literal or undefined if representation fails.

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

      Returns ValLiteral

      Val literal.

    • Create a deep copy of this time monzo.

      Returns TimeMonzo

      A clone with independent vector part.

    • Compare this time monzo 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.

    • Find all divisors of a natural number (ignoring units of time).

      Returns number[]

      All divisors including 1 and the number itself.

      An error if this time monzo doesn't represent a positive integer.

    • Calculate the dot product of the vector parts of two time monzos.

      Parameters

      Returns Fraction

      The sum of the pairwise products of the vector parts.

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

      Parameters

      Returns boolean

      true if the time monzos are of equal size.

    • Factorize the time monzo into a Map instance with prime numbers as keys and their multiplicity as values.

      Returns Map<number, Fraction>

      A sparse monzo.

    • Calculate the geometric inverse of the time monzo.

      Returns TimeMonzo

      A time monzo whose dot product with this one is unitary.

    • Obtain a convergent of this time monzo.

      Parameters

      • depth: number

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

      Returns TimeMonzo

      Approximation of the time monzo.

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

      Returns TimeMonzo

      The frequency-space inverse of the time monzo.

    • Check if the time monzo represents a finite sum of powers of ten.

      Returns boolean

      true if the time monzo represents a decimal number ignoring units of time.

    • Check if the time monzo represents a generic EDJI interval.

      Returns boolean

      true if the time monzo can be interpreted as pitch-space fraction of a frequency-space fraction.

    • Check if the time monzo represents a musical fraction or fractional amount of time or frequency.

      Returns boolean

      true if the time monzo can be interpreted as a ratio in frequency-space.

    • Check if the time monzo represents a whole number.

      Returns boolean

      true if the time monzo represents an integer ignoring units of time.

    • Check if the time monzo is a power of two in frequency space.

      Returns boolean | 0

      true if the time monzo is a power of two.

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

      Returns boolean

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

    • Check if the time monzo represents a square root of a fraction or fractional amount of time or frequency.

      Returns boolean

      true if the square of time monzo can be interpreted as a ratio in frequency-space.

    • Check if the time monzo represents the number one.

      Returns boolean

      true if the time monzo represents musical unison ignoring units of time.

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

      Parameters

      Returns number | Fraction

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

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

      Returns TimeMonzo

      The frequency-space negative of the time monzo.

    • Pitch space absolute value of the time monzo.

      Returns TimeMonzo

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

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

      Parameters

      • other: TimeReal | TimeMonzo

        Another time monzo.

      • ceiling: boolean = false

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

      Returns TimeReal | TimeMonzo

      This reduced by the other.

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

      Returns TimeReal | TimeMonzo

      The pitch-space half of the time monzo.

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

      Parameters

      Returns boolean

      true if the time monzos share the same time exponent, prime exponents, residual and cents offset.

    • Obtain a higher prime tail of this time monzo.

      Parameters

      • index: number

        Prime index with 2 at #0.

      Returns TimeMonzo

      Multiplicative tail above the given limit.

    • Calculate the Tenney height of this time monzo ignoring units of time.

      Returns number

      The natural logarithm of the Benedetti height

    • Convert the time monzo to an integer in linear space.

      Returns bigint

      Musical ratio as an integer in linear space corresponding to the unit of time of the time monzo.

      An error if the time monzo cannot be represented as an integer.

    • Convert the time monzo to a BigInt numerator and denominator in linear space.

      Returns { denominator: bigint; numerator: bigint }

      Musical ratio as a fraction in linear space corresponding to the unit of time.

      An error if the time monzo cannot be represented as a ratio.

    • Convert the time monzo to cents.

      Parameters

      • ignoreSign: boolean = false

        Compute the size of the absolute value.

      Returns number

      Size of the time monzo in cents.

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

      Returns number[]

      Array of continued fraction coefficients.

    • Convert the time monzo to pitch-space fraction of a frequency-space fraction.

      Parameters

      • preferPositive: boolean = false

        Prefer a positive fraction of the equave.

      Returns EqualTemperament

      Pair of the pitch-space fraction and the equave as a frequency-space fraction.

      An error if the time monzo cannot be represented as an EDJI interval.

    • Convert the time monzo to a fraction in linear space.

      Returns Fraction

      Musical ratio as a fraction in linear space corresponding to the unit of time of the original time monzo.

      An error if the time monzo cannot be represented as a ratio.

    • Convert the time monzo to a simple monzo with integer coefficients.

      Parameters

      • Optionaltrim: boolean

        If true trim zero components from the tail.

      Returns number[]

      Array of prime exponents.

      An error if the time monzo cannot be represented as sufficiently simple ratio in frequency-space.

    • Serialize the time monzo to a JSON compatible object.

      Returns { p: number[]; r: UnsignedFraction; t: UnsignedFraction; type: string }

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

    • Convert the time monzo to a simple array of numbers.

      Parameters

      • Optionaltrim: boolean

        If true trim zero components from the tail.

      Returns number[]

      Array of prime exponents.

      An error if the time monzo cannot be represented as sufficiently simple ratio in frequency-space.

    • Faithful string representation of the time monzo.

      Parameters

      • domain: Domain = 'linear'

        Domain of representation.

      Returns string

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

    • Convert a relative time monzo to cents. Covert an absolute time monzo to the size in cents of the scalar of its time unit.

      Parameters

      • ignoreSign: boolean = false

        Compute the size of the absolute value.

      Returns number

      Size of the time monzo in cents.

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

      Returns number

      A real number.

    • Create a scalar from an array of prime exponents.

      Parameters

      • monzo: FractionValue[]

        Exponents of prime numbers starting from prime 2. Possibly fractional.

      Returns TimeMonzo

      Scalar in the relative echelon.

    • Construct a time monzo from a harmonic.

      Parameters

      • value: bigint

        Index of the harmonic with 1/1 starting from 1.

      • OptionalnumberOfComponents: number

        Number of components in the monzo vector part.

      Returns TimeMonzo

      Time monzo representing the harmonic.

    • Construct a time monzo from a rational number.

      Parameters

      • numerator: bigint

        Numerator of the number.

      • denominator: bigint

        Denominator of the number.

      • OptionalnumberOfComponents: number

        Number of components in the monzo vector part.

      Returns TimeMonzo

      Time monzo representing the just intonation interval.

    • Construct a time monzo from a pitch-space fraction of a frequency-space fraction.

      Parameters

      • fractionOfEquave: FractionValue

        Fraction of the equave measured in pitch-space.

      • Optionalequave: FractionValue

        Equave measured in frequency-space. Defaults to the octave (2/1).

      • OptionalnumberOfComponents: number

        Number of components in the monzo vector part.

      Returns TimeMonzo

      Time monzo representing N-of-EDO (default) or a generic EDJI interval.

    • Construct a time monzo from a rational number.

      Parameters

      • fraction: FractionValue

        Rational number to convert.

      • OptionalnumberOfComponents: number

        Number of components in the monzo vector part.

      Returns TimeMonzo

      Time monzo representing the just intonation interval.

    • Create a scalar from a rational number of cents (1 cent = 1 centisemitone or 1200th of an octave).

      Parameters

      • cents: FractionValue

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

      • OptionalnumberOfComponents: number

      Returns TimeMonzo

      Scalar in the relative echelon.

    • Construct a time monzo from a value that's a rational multiple of 1 Hz.

      Parameters

      • frequency: FractionValue

        Frequency measured in oscillations per second.

      • OptionalnumberOfComponents: number

        Number of components in the monzo vector part.

      Returns TimeMonzo

      Time monzo representing the frequency.

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

      Intended usage:

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

      Parameters

      • key: string

        Property name.

      • value: any

        Property value.

      Returns any

      Deserialized TimeMonzo instance or other data without modifications.