Function CHOP

From TouchDesigner 099 Wiki


The Function CHOP provides more complicated math functions than found in the Math CHOP : trigonometic functions, logarithmic functions and exponential functions, and also audio decibels (dB)-power-amplitude conversions.

Most of the functions require only one parameter, and they are applied as a unary operator to each input channel. Some functions take two parameters, and these require the use of the second input. The first parameter, X, is always a value from a channel in the first input. The second parameter, Y, is a value from a corresponding channel in the second input. Channels from each input are paired by name or index.

Since many of these functions can produce math errors, an error handling tab is provided for error handling and recovery. Errors can be handled by replacing the bad sample with a pre-defined value or by using the value of the previous sample. Alternatively, cooking can be aborted upon error for debugging networks.

PythonIcon.png functionCHOP_Class

Parameters - Function Page

Function - Which math function to apply to the channels. All of the functions are unary functions except for the binary functions 'arctan (Input1/Input2)' and 'Input1 ^ Input2'. In the cases of power functions, a negative base is inverted first to avoid imaginary numbers, and the result is negated.

  • sqrt(x)- Square Root of Input 1.
  • abs(x) - Absolute Value of Input 1.
  • sign(x) - Sign of Input 1.
  • cos(x) - Cosine of Input 1.
  • sin(x) - Sine of Input 1.
  • tan(x) - Tangent of Input 1.
  • acos(x) - Arccosine of Input 1.
  • asin(x) - Arcsine of Input 1.
  • atan(x) - Arctan of Input 1.
  • atan2(y,x) - Arctan of (Input 1 / Input 2).
  • cosh(x) - Hyperbolic Cosine of Input 1.
  • sinh(x) - Hyperbolic Sine of Input 1.
  • tanh(x) - Hyperbolic Tangent of Input 1.
  • log10(x) - Log base 10 of Input 1.
  • logN(x) - Log base Base Value of Input 1.
  • ln(x) - Natural Log of Input 1.
  • pow(10,x) - 10 to the power of Input 1.
  • exp(x) - e to the power of Input 1.
  • pow(x) - Base value to the power of Input 1. If Base value is negative result is -((-Base Value) ^ Input 1)
  • pow(x) - Input 1 to the power of Exponent value. If Input 1 is negative result is -((-Input 1) ^ Exponent Value)
  • pow(x,y) Input 1 to the power of Input 2. If Input 1 is negative result is -((-Input 1) ^ Input 2)
  • dB to Power - decibel (Input 1) to amplitude.
  • Power to dB - amplitude (Input 1) to decibel.
  • dB to Amplitude - decibel (Input 1) to amplitude.
  • Amplitude to dB - amplitude (Input 1) to decibel.

Base Value - The value of the base for 'Log base N' and 'Base ^ Input1'. parameter name /baseval

Exponent Value - The value of the exponent for 'Input1 ^ Exponent'. channel name /expval
Angle Units - For trigonometric functions, the angles can be measured in Degrees, Radians, or Cycles (0 to 1).

Match By - How to pair channels together from the two inputs for the binary functions, by name or by channel index.

Parameters - Error Page

Error Handling - How to correct samples with math errors:

  • Abort With Error Message - Cooking aborts.
  • Replace With Specified Values - Values specified below.
  • Use The Previous Value - Uses the last good result.

+ Infinity Value /pinfval

- Value to use when an infinity error occurs. Caused by sinh(), cosh() and tan(). 

- Infinity Value /ninfval - Value to use when a negative infinity error occurs. Caused by sinh() and tan().

Domain Error Value /domval - Value to use when a domain error occurs. Caused by asin(), acos(), log10(), logN(), ln() and sqrt().

Divide Error Value /divval - Value to use when a divide by zero error occurs. Caused by pow(x,y).

Standard Options and Local Variables