Expression functions

The functions that can be used in an expression

Common functions

Name Description
abs(x) Absolute value of 'x'
sin(x) sine of 'x'
cos(x) cosine of 'x'
tan(x) tangent of 'x'
sinh(x) hyperbolic sine of 'x'
cosh(x) hyperbolic cosine of 'x'
tanh(x) hyperbolic tangent of 'x'
asin(x) inverse sine of 'x'
acos(x) inverse cosine of 'x'
atan(x) inverse tangent of 'x'
atan(y, x) Inverse tangent of 'y' divided by 'x', with the correct angle for the quadrant of (x, y)
clamp(x, min, max) Clamps 'x' to the range 'min' and 'max', wrapping as needed
rescale(p, o1, o2, n1, n2) Rescales a point 'p' from the range 'o1' - 'o2' to the range 'n1' - 'n2'
deg(x) Return 'x' radians converted to degrees
length(x,y,z) Returns the length of a 2d or 3d vector
noise1(x) Return a noise value from a 1d location
noise2(x,y) Return a noise value from a 2d location
noise3(x,y,z) Return a noise value from a 3d location
smoothstep(min,max,value) Return value from 0-1 that is a smooth transition

Music functions

Name Description
beat(nomusic) Returns the strength of the current beat. If no music is playing 'nomusic' is returned
band(channel,damping,bandnr,nomusic) channel=-1-all,0-left,1-right, damping amount (0 short damping time, 3 long damping time), bandnr (0-bass, 1-middle, 2-high). If no music is playing 'nomusic' is returned
waveform(channel, pos, nomusic) Returns waveform data. channel -1=both,0-left/1-right, pos 0-1. If no music is playing 'nomusic' is returned
spectrum(channel, pos, nomusic) Returns spectrum data. channel -1=both,0-left/1-right, pos 0-1. If no music is playing 'nomusic' is returned

Randomization functions

Name Description
rand() Return a pseudo random number from 0 to 1 inclusive. Uses the seed value from a 'random seed' port on the node. Randomizer is reset to that seed value each frame. Random values generated this way are much more random than sending in your own seed
srand() Return a pseudo random number from -1 to 1 inclusive. Uses the seed value from a 'random seed' port on the node. Randomizer is reset to that seed value each frame. Random values generated this way are much more random than sending in your own seed
rand(&seed) Return a pseudo random number from 0 to 1 inclusive. 'seed' is used to generate the number and is updated with a new seed value. Note: Make sure seed value is a integer
srand(&seed) Return a pseudo random number from -1 to 1 inclusive. 'seed' is used to generate the number and is updated with a new seed value. Note: Make sure seed value is a integer
random(min,max) Return a 'true' random value from 0 to 1 or from min to max
srandom() Return a 'true' random value from -1 to 1

Conditional functions

Name Description
if(c, t, f) If 'c' is not zero, evaluates and returns 't', otherwise evaluates and returns 'f'. Only one of 't' or 'f' is evaluated.
select(c, n, z), select(c, n, z, p) If 'c' is less than zero, evaluates and returns 'n'. If 'c' is zero, evaluates and returns 'z'. If 'c' is greater than zero, evaluates and returns 'z' for three arguments and 'p' for four arguments. Only one of 'n', 'z', or 'p' is evaluated.
equal(x, y) Returns 1 if 'x' is equal to 'y', else returns 0
above(x, y) Returns 1 if 'x' is greater than 'y', else returns 0
below(x, y) Returns 1 if 'x' is less than 'y', else returns 0
and(x, y) Returns 0 if 'x' or 'y' is 0, else returns 1
or(x, y) Returns 0 if 'x' and 'y' is 0, else returns 1
not(x) Returns 1 if 'x' is 0, else returns 0
min(x, y, z, ...) Value of the smallest parameter
max(x, y, z, ...) Value of the largest parameter

Other functions

Name Description
time(period) Current time. Period can be 0=hour, 1=minutes, 2=sec, 3=millisecond
date(period) Current date. Period can be 0=year, 1=month, 2=day, 3=day of week
mod(x, y) Remainder of 'x' divided by 'y'
ipart(x) Interger portion of 'x'
fpart(x) Fraction portion of 'x'
sqrt(x) Square root of 'x'
log(x) Base 10 logarithm of 'x'
ln(x) Natural logarithm of 'x'
exp(x) Value of e raised to the power of 'x'
pow(x,y) x to the y power. ^ can also be used instead of pow
logn(x, y) Base 'y' logarithm of 'x'
ceil(x) Value of 'x' raised to the nearest integer
floor(x) Value of 'x' dropped to the nearest integer
rect2pol(x, y, &distance, &angle) Convert rectangular coordinates 'x' and 'y' to polar coordinates and stores the result in 'distance' and 'angle'. Returns distance.
pol2rect(distance, angle, &x, &y) Convert polar coordinates 'distance' and 'angle' to rectangular coordinates and stores the result in 'x' and 'y'. Returns x.
clip(x, min, max) Clips 'x' to the range 'min' and 'max'