Expression

An expression is a simple mathematical formula, combining values such as inputs, outputs (Task triggering expressions only) and numeric constants using operators in a way that yields a numeric result.

Expressions are used to:

In its most basic form, an expression consists of a single value, such as an input (this example assumes that an input with the name “ModWheel” exists in the Input window):

ModWheel

If this expression is used in the Trigger column of the Task window, that task will be started when the ModWheel’s value becomes non-zero (that is, when the modulation wheel on the attached MIDI device is moved from its zero position).

Likewise, if this expression is used as a formula for an Opacity tween track, the opacity will be controlled only by the modulation wheel (that is, the value of the tween track itself will have no effect).

Using Numeric Operators

In some cases, you may want to combine multiple values. For instance, in the previous example, you may change the expression so that the modulation wheel modulates the value of the cue’s Opacity tween track by entering the following expression into its formula dialog box:

Parameter
Enter an expression for a tween track by clicking its formula button (see “Controlling Tween Tracks”).

This expression combines the value of the ModWheel input with the value coming from the tween track itself by using the TweenValue identifier, which provides the enclosing tween track’s current value. Since both values are in the range 0 through 1, multiplying them in this way will work as desired.

Alternatively, you may want to combine the two values so that the opacity can be controlled by either the tween track or the modulation wheel. This can be accomplished by changing the formula to

TweenValue + ModWheel

Now the resulting image will appear on stage if the tween track or the external input says so. Note that if both the tween track and the input are at their maximum value, the result of the expression will be 2. However, the opacity value is effectively clipped to the range 0 through 1 (as the image can’t be more than fully opaque or fully transparent). Most parameters work in this way, with the notable exception of the color hue, as it allows the color wheel to be rotated multiple revolutions

Using Relational Operators

When using expressions to trigger tasks, it is often useful to specify a threshold for the triggering value. If the input is used on its own, the task will be triggered as soon as the input leaves zero. If you prefer the input to exceed a certain value, you can use a “greater than” operator to test for this:

ModWheel > 0.5

This operator yields a value that is 1 if the value on the left hand side is greater than the value on the right hand side, otherwise its value is 0. Likewise, if you want to trigger the task when the value becomes zero (rather than when it leaves zero), you can write:

ModWheel = 0

This uses the “equals” operator, yielding 1 if the value on the left is the same as the value on the right, or else yielding 0.

Using Local Operators

Occasionally you may want to create more complex triggering conditions, combining multiple inputs, so that the task will only be triggered when all conditions are met. That can be accomplished using the “and” operator:

ModWheel > 0.5 && MiddleC

This will trigger the task when the modulation wheel is above 50% and the MiddleC key is pressed (assuming here that MiddleC is a MIDI Note input).

HINT: Expressions in the Task window can use both numeric input and output values. This can be used to create complex logic conditions, governed by WATCHOUT itself, using logical operations together with the “Generic Variable”.

List of Operators

This is a list of the operators supported by WATCHOUT, shown in their order of precedence.

OperatorDescription
( )

Parenthesis. Used to group sub-expressions.

-Unary Minus.

* / %

Mutiplications, Division and Modulo.
+ -Addition and Subtraction.

< <= > >= =

!=

Less Than, Less Than or Equal To, Greater Than, Greater Than or Equal To, Equal,

Not Equal.

&&Logical And.

||

Logical Or.

Most operators work as expected. The Modulo operator yields the remainder of an integer division. All other numeric operators may yield results with fractional digits. All relational operators (<, >, etc) yield 1 if the relation is true, 0 if it is false. Likewise, the logical operators yield 1 for true and 0 for false.

Back to top