Transform Reference Guide
|User Guide | Transform Guide | OSW on the Web|
Evaluate a mathematical expression.
Expr evaluates mathematical expressions in a format resembling programming languages like C, Java or Tcl. The expression is composed of numbers, arithmetic operators, math functions like sin or log and variables.
Integer, floating-point, and complex numbers can be used as constants within an expression.
Variables are alphanumeric strings preceded by a $. The first letter or pair of letters after the $ determine the type of the variable:
For example $i1 would be an integer variable and $sfoo would be a audio-sample variable. For each variable used in the expression, an inlet of the same name and type is created for the Expr transform. So the expression $i1 + $f2 / $f3 would have one Integer inlet and two Float inlets.
If a variable name does not use any of the above prefixes, it is treated as an ordinary OSW variable (i.e., as used by Get/Put or the $ operator in transform arguments). If the variable exists elsewhere in the patch (e.g., as a transform variable or a free variable), it is used in the expression. Otherwise, a new inlet of type Any is added to the Expr transform is created.
The valid operators are listed below, in order of decreasing precedence:
Operator precedence can of course be overriden using parentheses.
Expr understands the following math functions:
See the documentation for the standalone versions of these functions for their valid argument types. It is possible to extend the set of available functions via special external libraries.
The expression is evaluated whenever a new value is received via any of the inlets. A single outlet is provided to transmit the result of the expression evaluation. If no variables are specified in the expression (i.e., the expression is constant), a single inlet of type unit is created. When this inlet receives a unit value, the constant expression is evaluated.