Math

Usine provides a comprehensive set of mathematical modules for arithmetic, logic, trigonometry, bitwise operations, rounding, and unit conversions. Most modules work equally on single values and arrays.

Categories

Category Modules Description
Arithmetic 26 Basic operations (+, -, *, /), power, sqrt, log, exp, abs, sign, mod, distance, random, variable assignment
Trigonometry 12 Sin, cos, tan, arcsin, arccos, arctan, arctan2, triangle wave, degree/radian conversion, PI and 2PI constants
Logical 13 AND, OR, NOT, XOR, comparisons (=, <, >, <=, >=, !=), same-value with epsilon, multi-compare
Bitwise 14 AND, OR, NOT, XOR, SHL, SHR, CRC32, and conversions between bitwise, integer, string, and bit-array
Rounding 4 Round, ceil, truncate, and fractional part
Conversion 11 dB/coeff, frequency/linear/MIDI note, pitch/coeff, exponential/power scale, round frequency

Arithmetic

Basic math operations, logarithms, powers, distance calculations, random generators, and variable assignment.

Module Description
Math + Addition: A + B
Math - Subtraction: A - B
Math * Multiplication: A * B
Math / Division: A / B
Math ABS Absolute value
Math SIGN Sign: 1 if positive, -1 if negative
Math - X Negation: -X
Math 1 - X Complement: 1 - X
Math 1 / X Inverse: 1 / X
Math X + 1 Increment: X + 1
Math X - 1 Decrement: X - 1
Math 2 * X - 1 Bipolar: 2X - 1
Math (X + 1) / 2 Unipolar: (X + 1) / 2
Math A * X + B Linear: A * X + B
Math SQR Square: X * X
Math SQRT Square root
Math POWER Power: A^B (A > 0)
Math Int POWER Integer power: A^B (B integer)
Math EXP Exponential
Math LN Natural logarithm
Math LOG10 Base-10 logarithm
Math MOD Integer modulo
Math FMOD Float modulo
Math FMOD Circular Float modulo with positive output [0..B]
Math Int DIV Integer division
Math MIN Minimum of two values
Math MAX Maximum of two values
Math HYPOT Hypotenuse: sqrt(X^2 + Y^2)
Math ODD Returns 1 if odd, 0 if even
Math DELTA Variation: current - previous
Math RANDOM Random value [0..1]
Math RANDOM Block Array of random values (block-size length)
Math Constant Constant value output
Math Variable Conditional assignment: output = input when affect = 1
Math Multiple Variable Multiple variable assignment with separate affect triggers
Math Formula Formula parser: expressions like A * Log(B) + Sqrt(C) with 50+ operators
Math Quadratic Distance 2D 2D Euclidean distance (supports arrays)
Math Quadratic Distance 3D 3D Euclidean distance (supports arrays)

Trigonometry

Trigonometric functions, angle conversions, and constants.

Module Description
Trigonometric SIN Sine
Trigonometric COS Cosine
Trigonometric TAN Tangent
Trigonometric ARCSIN Arc sine
Trigonometric ARCCOS Arc cosine
Trigonometric ARCTAN Arc tangent
Trigonometric ARCTAN2 Arc tangent with quadrant correction: arctan(Y/X)
Trigonometric TRIANGLE Triangle wave function
Trigonometric Degree to Radian Convert degrees to radians
Trigonometric Radian to Degree Convert radians to degrees
Trigonometric PI Constant: PI (3.14159...)
Trigonometric 2PI Constant: 2*PI (6.28318...)

Logical

Boolean logic and comparison operators. All support optional "null flow if false" output.

Module Description
Logical AND A AND B
Logical OR A OR B
Logical NOT NOT A (inverts 0/1)
Logical XOR A XOR B
Logical EQUAL A = B
Logical Diff A != B
Logical INFERIOR A < B
Logical INFERIOR OR EQUAL A <= B
Logical SUPERIOR A > B
Logical SUPERIOR OR EQUAL A >= B
Logical Same Value Floating-point equality with epsilon tolerance
Logical Not Same Value Floating-point inequality with epsilon tolerance
Logical Multi Compare Multi-range comparator with between/equal index outputs

Bitwise

Bitwise logic operations and format conversions between bitwise, integer, string, and bit-array.

Module Description
Bitwise AND Bitwise AND
Bitwise OR Bitwise OR
Bitwise NOT Bitwise NOT (inversion)
Bitwise XOR Bitwise XOR
Bitwise SHL Shift left
Bitwise SHR Shift right
Bitwise CRC32 CRC32 checksum
Bitwise Constant Constant bitwise value
Bitwise Integer to Bitwise Integer to bitwise conversion
Bitwise to Integer Bitwise to integer conversion
Bitwise String to Bitwise Binary string to bitwise conversion
Bitwise to String Bitwise to binary/hex string conversion
Bitwise Bit Array to Bitwise 0/1 array to bitwise conversion
Bitwise to Bit Array Bitwise to 0/1 array conversion

Rounding

Round, truncate, and extract fractional parts.

Module Description
Rounding ROUND Standard rounding (round-to-even)
Rounding CEIL Round up (toward positive infinity)
Rounding TRUNC Truncate decimal part
Rounding FRAC Extract fractional part

Conversion

Unit conversions for audio (dB, frequency, MIDI notes, pitch) and curve scaling.

Module Description
Conversion dB to Multiplication Coeff dB to linear coefficient: 10^(dB/20)
Conversion Multiplication Coeff to dB Linear coefficient to dB: 20*log10(coeff)
Conversion Frequency to Linear Frequency to linear [0..1]
Conversion Linear to Frequency Linear [0..1] to frequency
Conversion Frequency to MIDI Note Frequency to MIDI note number (with scale/root options)
Conversion MIDI Note to Frequency MIDI note number to frequency
Conversion Multiplication Coeff to Pitch Coefficient to pitch: 12*log2(coeff)
Conversion Pitch to Multiplication Coeff Pitch to coefficient: 2^(pitch/12)
Conversion Round Frequency Round frequency to nearest well-tempered note
Conversion Exponential Scale Exponential scale factor
Conversion Power Scale Power scale factor

See also

version 7.0.250121

Edit All Pages