CHOP Expression Functions
Contents |
Expression Functions accessible from anywhere in Touch
-
chop("choppath/channelname")
- This evaluates
choppath/channelnameat the current time/frame. An example is "/ch/ch1/wave1/chan1".
-
chopf("choppath/channelname", frame)
- This evaluates the channel at the specified frame.
-
chopt("choppath/channelname", time)
- This evaluates the channel at the specified time, expressed in seconds.
-
chopi("choppath/channelname", index)
- This evaluates the channel at the specified index.
-
chopcf("choppath", channelnum, frame)
- Like chopf() this evaluates the channel at the specified frame, but the channel is specified with two fields: the CHOP name and the channel number, as an index that starts at 0. Example:
chopcf("/ch/ch1/wave1", 0, 61)
-
chopct("choppath", channelnum, time)
- Like
chopt()this evaluates the channel at the specified time, but the channel is specified with two fields: the CHOP name and the channel number.
-
chopci("choppath", channelnum, index)
- Like
chopi()this evaluates the channel at the specified index, but the channel is specified with two fields: the CHOP name and the channel number.
-
chopstr("choppath/channelname")
- Like
chop(), this evaluates a CHOP output channel at the current time/frame. It returns not a float (a raw number) like the other functions here, but a text string in ASCII containing the same number. (Both output out the same, so they appear similar.)
-
chopn("choppath")
- This returns the number of channels in the CHOP.
-
chops("choppath")
- This returns the start index of CHOP, expressed as samples. To express the start of the CHOP in seconds, divide this by
chopr().
-
chope("choppath")
- This returns the end index of CHOP.
-
chopl("choppath")
- This returns the length of the CHOP in samples.
-
chopr("choppath")
- This returns sample rate of the CHOP.
Functions Local To CHOPs
If you are working within the context of CHOPs - say by putting math expressions in the Expression CHOP and fetching channels from Expression's input - you should use the faster functions:
icn(input)- This returns the number of input channels at input, where 0 is the first input to the CHOP.
-
ics(input)- This returns the 'start index' of the input.
-
ice(input)- This returns the 'end index' of the input.
-
icl(input)- This returns the length of the input, expressed in samples.
-
icr(input)- This returns the sample rate of the input.
-
icmax(input, channelindex)- This returns the maximum value in the channelchannelindexof input.
-
icmin(input, channelindex)- This returns the minimum value in the channelchannelindexof input.
-
ic(input, channelindex, sampleindex)- This returns the value of the channel numberchannelindex, of input numberinput, at sample numbersampleindex. They all start at 0.
-
oc(channelindex, sampleindex)- This gets values from the output channel as the CHOP's output is being calculated. While, for example the Expression CHOP is computing its output at index$I, it can access the output values at the previous index,$I-1. This is useful when stepping forward frame-by-frame. Theoc()function is only valid forsampleindex<$I.
Note: ics, ice, icl, chops, chope, chopl return values in terms of 'sample index' and represent the entire CHOP.
Example
To get the value of a channel from a Wave CHOP at the previous frame:
As it is in unix, / is the root of all data, and in Touch, /ch is where the CHOP Networks are located. So if the CHOP Network is ch1, and the Wave CHOP is called wave1, you need: /ch/ch1/wave1 .
But this identifies the CHOP, not its channels. So you need to append the channel you want to this, resulting in: /ch/ch1/wave1/chan1 . So the channel function is:
-
chopf("/ch/ch1/wave1/chan1", $F-1)
Useful Expression Functions
-
opdigits()- The expression function,opdigits()gets the numbers that are in an OP name. For example, it returns 23 from an OP namedleg23right. This allows animators to make one CHOP Network for each of 100 similar characters. For example, in a CHOP you can get the number of the CHOP Network:
-
opname("..")=ch1(a string) -
opdigits("..")=1(a set of digits)
- "." is name of the OP that the expression is in.
- ".." is the parent OP. If it occurs in a CHOP, ".." means the CHOP network it is in.
-
float opdigits(string name)
- This function will return the numeric value of the concatenation of all the digits in a node's name. It is used when building several similar networks. For example:
-
opdigits("/obj/geo7")= 7 -
opdigits("..")= 7 (at the SOP level of geo1)
To make a channel name that is for export to an object, and you want to name the channels to match the CHOP network to the object name, create a name that look like this:
-
geo`opdigits("..")`:tx
- If this is in a CHOPnet called ch3, the channel name will be geo3:tx .
-
modblend()- Themodblend()function blends between two numbers using a weighting factor.
