Binding

From Derivative
Jump to: navigation, search

Parameter Binding[edit]

Bound parameters keep their values in sync and will respond to changes from either parameter. For each parameter that is a bind master, it will have one or more bind reference parameters.

The bind master holds the current value. It can have exports and expressions and generally works like any other parameter, but its value can be also changed indirectly by the bind references.

A bind reference holds the location of the bind master. A bind reference is in a fourth "Bind" Parameter Mode, and will show up as purple text in parameter dialogs. It can only be changed via its its bind master, its UI, and its val property.

Setting Up Binding[edit]

To set up, in the bind reference parameter, set its Parameter Mode to Bind, then put an expression that points to the bind master parameter, like op('lfo1').par.phase. Thereafter, if there is change the bind master (in this case, lfo1's Phase parameter) in any way, the bind reference will have the same value as the bind master.

If a bind reference parameter is changed using its parameter UI, it sets the bind master to that value as well. If you try to change the bind reference with python (like OP.par.Parname.val = 2), it also sets the bind master to that value. In both cases the value then propagates from the bind master back to all its bind references.

A bind reference does not use its expression or export parameter modes.

The Period parameter is a bind target.

You can have one or more bind references bound to one bind master, and you can also set up a chain where parameter C is the bind reference of parameter B, which is the bind reference of parameter A, and so on. That is, a bind reference can also be a bind master, but will have all the limitations of a bind reference such a not being able to use expression or export modes.

Setting Up by Dragging[edit]

You can set up binding by dragging parameters or by typing a bind expression.

Binding Parameters Using Mouse Drag[edit]

To bind parameters using the mouse, you will want to drag the bind master to the bind reference. Drag the parameter name from the bind master's parameter dialog into the parameter name or text entry field of the bind reference parameter. In the case of multi-value parameters, drag the name of the bind master onto the name of the bind reference.

Once you have done this, select Bind Parameter from the popup menu that appears.

Binding Parameters Using Bind Expressions[edit]

The mouse method above will write a bind expression automatically, but you can also write your own. Writing a bind expression is much like writing a normal parameter expression, but must resolve to a parameter object, like parent().par.Speed.

The bind expression is accessed by expanding the bind reference's parameter and then selecting the purple box next to a parameter to put it in bind mode. The bind expression can then be entered into the parameter field entry.

You can also set the bind reference up through python: Par.bindExpr = string

Any of the procedural data operators. OPs do all the work in TouchDesigner. They "cook" and output data to other OPs, which ultimately result in new images, data and audio being generated. See Node.

Parameters in TouchDesigner are an operator's settings (numbers, menus, flags, strings, paths) which the user can alter. Parameters for any operator can be opened by right-clicking on the operator and selecting "Parameters..." A currently selected operator's parameters can be viewed in a Network Editor by pressing the keyboard shortcut 'p'.