Cantabile includes and expression evaluation engine that is used for evaluating the expressions in Gain Control Curves.
The expression engine only supports double precision floating point numbers.
For boolean operations, any non-zero value is considered true and any function or operator that returns a boolean value will return 1 for true and 0 for false.
Functions are called by name with parameters enclosed in round brackets and separated by commas.
Functions are defined with a function prototype as the JSON key and the value the expression:
Constants are simply functions with no parameters and may be defined as JSON numeric value:
or as an expression:
The expression engine supports the following operators:
- Subtract and negative
- Ternary (aka conditional) operator
- Logial Not
- Logical And
- Logical Or
The expression engine includes the following built-in functions. The unit for all angles is radians.
- Absolute value
- Arc-tangent of (x,y)
- Round to more positive value
- Hyperbolic Cosine
eraised to the power of
- Round to less positive value
- Natural (base e) logarithm
- log(x, b)
- Base 10 logarithm
- The smaller value of x and y
- The larger value of x and y
- pow(x, y)
xraised to the power
- Round x to the closest whole enumber
- Returns -1, 0, or 1 matching the sign of x
- Hyperbolic Sine
- The square root of 'x'
- Hyperbolic Tangent
- Remove the fractional part of a
- Returns 1 if x is not a number, else 0
- returns 1 if x is infinity, else 0
- The constant +infinity
- The constant for non a number
- The smallest expressible double precision number
- The most positive supported double precision number
- The most negative supported double precision number
- The smallest expressible single precision number
- The most positive supported single precision number
- The most negative supported single precision number
- Converts a scalar value to decibels
- Converts a scalar value x to decibels with a floor of y dB. (ie: a smaller value will be returned as negative infinity)
- Converts decibels to scalar
- fromDb(x, y)
- Converts decibels to scalar with a floor of y dB (ie: a smaller value will be returned as 0);