Expression CHOP

From TouchDesigner 099 Wiki


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.

The corresponding input values are me.inputVal in the expressions. me.inputs[1][0] gets from the first channel of the second input.

See also Evaluate DAT for easy evaluation of any 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. The input values are me.inputVal in the expressions. me.inputs[1]['chan1'] gets from the channel chan1 of the second input

Using Expression Functions to Access Other Input CHOPs

The corresponding input values are me.inputVal in the expressions. me.inputVal*2 in an expression doubles the values of the input.

To get a channel from the second input, me.inputs[1] is the second input, and me.inputs[1]['chan1'] gets from the channel chan1 of the second input.

Older Tscript:

  • ic(input#, channel#, index)

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

Other 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.


Subtract 1 from the values of the incoming samples:


$V - 1


me.inputVal - 1

Square root of incoming values:





maximum of two CHOP inputs:


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


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