This is TouchDesigner088 help and outdated. Please visit https://docs.derivative.ca

Expression CHOP

From TouchDesigner 088 Wiki

Summary

The Expression CHOP allows you to modify input channels by using math expressions. Up to six expressions are available. Each input channel is modified by exactly one expression, and the expressions are looped for multiple channels.

The output is the same length and set of channels as the first input, but its sample values are changed according to the expressions.

An expression is applied to each keyframe value or raw sample. There are up to six expressions. If there are more channels coming from input 0, the expressions are recycled. A repeat parameter controls how many channels to apply the first expression to before going on to the second expression.

PythonIcon.png expressionCHOP_Class

Parameters - Group Page

Channels Per Expr /chanperexpr - The number of channels that use the current expression before the next expression is selected.

Num Expressions /numexpr - The total number of expressions that are defined.

Parameters - Expr Page

Expression 1-6 /expr[0-5] - Enter your expressions here.

Using Expression Functions to Access Other Input CHOPs

NOTE: python equivalents coming soon.

The power of this CHOP extends when using special expression functions to access the other input CHOPs.

 ic(input#, channel#, index)

The above expression function gets the value at the specified index of the specified channel of the specified input CHOP (all 0-relative).

Some available functions include:

  • ic() - can use local variables: $C (channel #), and $I (index).
  • oc(chan_index, samp_index) - gets the output CHOP's samples as they are being built. Like in calculus integration, you need a value from the previous output sample to generate the next one.
  • ics(input#) - gets the start index of any input CHOP. Similarly for ice() and icl().
  • icr() - gives the sample rate.

For more details on CHOP-related expression functions, see CHOP Expression Functions.

Examples

Subtract 1 from the values of the incoming samples:

tscript:

$V - 1

Python:

me.inputVal - 1


Square root of incoming values:

tscript

sqrt(abs($V))

Python

math.sqrt(math.fabs(me.inputVal))


maximum of two CHOP inputs:

tscript:

 max(ic(0, $C, $I), ic(1, $C, $I))

Python:

max(me.inputs[0][me.chanIndex][me.sampleIndex], me.inputs[1][me.chanIndex][me.sampleIndex])

Standard Options and Local Variables

Local Variables: $C $NC $I $V