This example shows you how pre-established functions can be used as expressions to drive animation—see Expression Reference Tables.
The goal of this example is to create random noise using the Noise tool—see Noise Tool. You could create the appearance of random noise by modifying the Noise Seed attribute using periodic keyframes. However, a more simple approach is to use a random number function. In this case, the TrueRand function is used.
To create random noise using a random number function:
The Expresso Calculator appears along with a dashed green line at the top of the Noise Seed value field. This indicates that an expression is about to be applied, or has already been applied.
(a) Dashed green line appears
An empty expression appears in the text field.
If you are familiar with the syntax of expressions, you can type them directly into the text field.
As the TrueRand function description indicates (see Random Number Functions) the function returns a truly random value between two given numbers. Since the Noise Seed value can range from 0 to 1, it is suggested that these values be used as the range.
You can view the expression in a graph view at any time by right-clicking the attribute's value field containing the expression, and then selecting Edit Expression from the menu. The Expresso Calculator appears. Select the Graph button to view the expression in a graph.
There are other expressions, and combinations of expressions that you can use to achieve the same results. For example, you can create random noise (with the Noise tool) by using the Rand function where the seed is calculated as time (t) multiplied (*) by the number of frames in the composition. Therefore, if the composition is 100 frames long, the expression would look like this:
Another expression that can be used to create random noise with the Noise tool is the Abs math function.
This expression indicates the Noise Seed is based on an absolute value (anything between 0 and 1) of the angle (in radians) of the sine wave created by the current time (t). It is then multiplied (*) by a frequency of 50. The expression would still be valid if the Abs math function were not part of the string.