Tag Archives: sample

Nov 12 2014

Switch CHOP tutorial.

The Switch CHOP. TouchDesigner 088. 2014.
The Switch CHOP is a fundamental multi-input Channel Operator.

1
00:00:00,267 –> 00:00:03,533
Let’s take a look at the switch
CHOP.

2
00:00:03,533 –> 00:00:07,400
The switch CHOP is a commonly
used operator.

3
00:00:07,400 –> 00:00:11,767
It allows for the switching of
any different type of CHOP.

4
00:00:11,767 –> 00:00:15,567
It has a minimal set of
parameters.

5
00:00:15,567 –> 00:00:20,633
Its inputs are indexed starting
with 0.

6
00:00:20,633 –> 00:00:27,133
Index entries that are higher
than the number of inputs are
ignored.

7
00:00:27,133 –> 00:00:33,667
Fractional entries are rounded
down to the closest integer.

8
00:00:33,667 –> 00:00:39,000
Here I use the index .5, which
rounds down to 0.

9
00:00:39,000 –> 00:00:45,967
I’ve built this network to
further illustrate the concept
of channels and samples.

10
00:00:45,967 –> 00:00:57,767
We have a circle TOP whose R, G,
and B parameters are set to
evaluate the 20th sample of the
switch CHOP.

11
00:00:57,767 –> 00:01:07,767
CHOPs can hold any arbitrary
number of channels, and each
channel can hold any arbitrary
number of samples.

12
00:01:07,767 –> 00:01:15,267
Therefore, the switch CHOP will
hold the exact number of
incoming channels and samples.

13
00:01:15,267 –> 00:01:22,800
I’ll change the Python
expression to evaluate only the
1st sample of the switch CHOP.

14
00:01:22,800 –> 00:01:27,700
When the index set to 0, we
select the 1st input.

15
00:01:27,700 –> 00:01:30,533
It only has 1 sample.

16
00:01:30,533 –> 00:01:35,200
Index 1 will select the 2nd
input.

17
00:01:35,200 –> 00:01:42,533
We can middle mouse click on the
CHOP to determine how many
samples it holds.

18
00:01:42,533 –> 00:01:51,900
It has 600 samples, and we are
evaluating only the 1st, in this
case a value of 0.

19
00:01:51,900 –> 00:01:58,500
The 3rd CHOP has sixty samples,
also starting with a value of 0.

20
00:01:58,500 –> 00:02:05,233
I’ll set the Python expression
to evaluate the 500th sample.

21
00:02:05,233 –> 00:02:12,733
Since only the 2nd input to the
switch CHOP has at least 500
samples,

22
00:02:12,733 –> 00:02:20,667
the Python expression will give
us the last available sample
from the other inputs.

23
00:02:20,667 –> 00:02:29,767
Input 1 has only 1 sample,
therefore the Python expression
evaluates to the value .5.

24
00:02:29,767 –> 00:02:34,567
But what about the 3rd input,
index 2?

25
00:02:34,567 –> 00:02:41,600
Shouldn’t it evaluate to a value
of 0, which is the value of the
last sample?

26
00:02:41,600 –> 00:02:45,567
We should have a black circle,
but it’s grey.

27
00:02:45,567 –> 00:02:54,200
Touch Designer gives us the
ability to change the way
out-of-range samples are
evaluated.

28
00:02:54,200 –> 00:03:01,067
I’ll change the “Extend Left”
and “Extend Right” parameters to
“Hold”.

29
00:03:01,067 –> 00:03:08,400
Imagine now a straight line
instead of a repeating cycle of
sample values.

30
00:03:08,400 –> 00:03:10,400
Now the 500th sample evaluates
to 0, which is the last actual
sample value in the 3rd input.

Nov 12 2014

Wave CHOP tutorial.

The Wave CHOP. TouchDesigner 088. 2014.
The Wave CHOP can generate static or dynamic waveforms.

1
00:00:00,600 –> 00:00:04,033
Let’s examine the wave CHOP.

2
00:00:04,033 –> 00:00:05,833

3
00:00:05,833 –> 00:00:13,867
Here we have an example with
three wave CHOP operators.

4
00:00:13,867 –> 00:00:21,867
Remember we can hit the H key to
home our screen, which will
center all of operators.

5
00:00:21,867 –> 00:00:30,333
And we can hit the P key to
display the parameters for the
selected operator.

6
00:00:30,333 –> 00:00:31,567

7
00:00:31,567 –> 00:00:38,867
In the first example we will
examine the concept of time in
Touch Designer.

8
00:00:38,867 –> 00:00:40,633

9
00:00:40,633 –> 00:00:44,033
These are examples of Python
expressions,

10
00:00:44,033 –> 00:00:49,300
that reference the amount of
time a node has been cooking.

11
00:00:49,300 –> 00:00:56,967
We can use this constantly
updating value to create an
animation engine.

12
00:00:56,967 –> 00:00:59,867

13
00:00:59,867 –> 00:01:06,567
We are animating the phase
parameter of the wave CHOP,

14
00:01:06,567 –> 00:01:16,633
then using the generated value
to animate the alpha channel of
a constant TOP.

15
00:01:16,633 –> 00:01:22,333

16
00:01:22,333 –> 00:01:27,400
We can generate different types
of waves.

17
00:01:27,400 –> 00:01:31,567

18
00:01:31,567 –> 00:01:34,567
The different types of waves
will affect the different

19
00:01:34,567 –> 00:01:42,167
values generated along the
waveform, and in turn affect

20
00:01:42,167 –> 00:01:49,967
the animation of any node that
references the resulting wave-
form data.

21
00:01:49,967 –> 00:01:52,633

22
00:01:52,633 –> 00:01:58,000
Let’s adjust the speed of our
animation by reducing the value

23
00:01:58,000 –> 00:02:02,167
referenced by our Python
expression.

24
00:02:02,167 –> 00:02:08,967
We’ve created of pulse waveform
type with a range of 0 to 1.

25
00:02:08,967 –> 00:02:15,533
If I keep the same wave CHOP
parameters and switch the type
to square,

26
00:02:15,533 –> 00:02:21,467
you’ll see our waveform
amplitude now ranges from -1 to
1.

27
00:02:21,467 –> 00:02:27,700
In order to create the desired
output range of 0 to 1,

28
00:02:27,700 –> 00:02:32,600
we must adjust the waveform’s
amplitude and offset

29
00:02:32,600 –> 00:02:37,167
depending on the desired type of
waveform.

30
00:02:37,167 –> 00:02:45,000

31
00:02:45,000 –> 00:02:50,267
Now let’s examine the concept of
samples in Touch Designer.

32
00:02:50,267 –> 00:02:58,767
Wave CHOP 1 has channel settings
of a start of 0 seconds and end
of 10 seconds,

33
00:02:58,767 –> 00:03:04,867
and a sample rate of 60, giving
us a grand total of 600 samples.

34
00:03:04,867 –> 00:03:10,867
For every frame processed by
Touch Designer, at 60 frames per
second,

35
00:03:10,867 –> 00:03:15,867
this operator will generate 600
samples of data.

36
00:03:15,867 –> 00:03:20,100
Wave CHOP number 2 has channel
settings of

37
00:03:20,100 –> 00:03:27,000
a start of 0 seconds, an end of
1 second, and a sample rate of
1.

38
00:03:27,000 –> 00:03:35,667
This means this operator will
generate 1 sample of data for
every frame Touch Designer
processes.

39
00:03:35,667 –> 00:03:36,733

40
00:03:36,733 –> 00:03:41,533
We can use a Python expression
to access CHOP data.

41
00:03:41,533 –> 00:03:47,500
We can access the CHOP name, the
names and numbers of channels
within the CHOP,

42
00:03:47,500 –> 00:03:51,800
and the data generated by each
channel at each sample.

43
00:03:51,800 –> 00:03:56,533
The Python expression works by
referencing the operator name,

44
00:03:56,533 –> 00:04:00,367
the channel name, and the
desired sample.

45
00:04:00,367 –> 00:04:01,700

46
00:04:01,700 –> 00:04:10,800
Here we reference the operator
“wave1”, the channel named
“chan1”, and sample 0.

47
00:04:10,800 –> 00:04:20,833
Here we reference the operator
named “wave2”, the channel named
“green”, and sample 0.

48
00:04:20,833 –> 00:04:21,767

49
00:04:21,767 –> 00:04:27,167
Let’s examine these Python
expressions in greater detail.

50
00:04:27,167 –> 00:04:33,300
Again we are referencing the
operator, the channel, and the
sample.

51
00:04:33,300 –> 00:04:37,133
In this case the channel we’re
referencing by name.

52
00:04:37,133 –> 00:04:41,767
The wave CHOP must name the
channel it creates.

53
00:04:41,767 –> 00:04:50,433
If I change the channel name,
our Python expression will
break.

54
00:04:50,433 –> 00:04:55,100
This is because we are
referencing the channel by name.

55
00:04:55,100 –> 00:05:01,900
In order for our Python
expression to work, it must know
where to look for data.

56
00:05:01,900 –> 00:05:04,000

57
00:05:04,000 –> 00:05:09,033
We can also reference channels
by number.

58
00:05:09,033 –> 00:05:12,233
The wave CHOP creates a single
channel.

59
00:05:12,233 –> 00:05:20,867
Remember to think in base 0 for
most of your numbering systems
in Touch Designer.

60
00:05:20,867 –> 00:05:26,067
Channel 0 is the first channel,
not channel 1.

61
00:05:26,067 –> 00:05:33,733
Now that we are referencing our
channel by number, we can name
our channel anything we like.

62
00:05:33,733 –> 00:05:39,833

63
00:05:39,833 –> 00:05:44,800
We have many options when we
deal with time In Touch
Designer.

64
00:05:44,800 –> 00:05:54,933
A simple but powerful method is
by using a Python expression to
reference the amount of time a
node has been cooking.

65
00:05:54,933 –> 00:06:00,300
But, as Einstein showed us, time
is relative.

66
00:06:00,300 –> 00:06:13,700
When we use the Python
expression “me.time.seconds”, we
are referencing the amount of
time this node has been cooking
in reference to the Touch
Designer timeline.

67
00:06:13,700 –> 00:06:26,533
As we watch the playhead on the
timeline, we’ll see that after
10 seconds the value of our
“me.time.seconds” expression
will reset.

68
00:06:26,533 –> 00:06:27,333

69
00:06:27,333 –> 00:06:33,967
Wave CHOP number 2 uses absolute
time as it’s time reference.

70
00:06:33,967 –> 00:06:44,800
This value is independent of the
Touch Designer timeline, and
references the amount of time
that has elapsed since Touch
Designer was launched.

71
00:06:44,800 –> 00:06:48,200

72
00:06:48,200 –> 00:06:58,833
Let’s investigate in more detail
the concept of a sample range
contained in an operator’s
channel.

73
00:06:58,833 –> 00:07:07,000
Wave CHOP number 3 is not
animating, and it contains a
range of sixty samples.

74
00:07:07,000 –> 00:07:08,667

75
00:07:08,667 –> 00:07:18,333
We will use the range of samples
created by the wave CHOP to
offset the center of a circle
TOP.

76
00:07:18,333 –> 00:07:20,467

77
00:07:20,467 –> 00:07:33,100
We’ll use the 60 discrete values
created by the wave CHOP to
offset the Y, the up and down
position of the circle TOP.

78
00:07:33,100 –> 00:07:34,900

79
00:07:34,900 –> 00:07:40,533
We have a horizontal slider that
generates an initial range of 0
to 1.

80
00:07:40,533 –> 00:07:48,933
We then use a simple CHOP
network to re-range the slider
data to fit our needs.

81
00:07:48,933 –> 00:07:57,700
The offset position of the
circle TOP corresponds exactly
to the shape of the generated
waveform.

82
00:07:57,700 –> 00:08:01,600

83
00:08:01,600 –> 00:08:13,400
As you can see, the wave CHOP is
a simple but extremely powerful
method for generating animation
paths.

84
00:08:13,400 –> 00:08:19,900

85
00:08:19,900 –> 00:08:29,833
We treat the initial 0 to 1
value range created by the
slider using a series of CHOPs.

86
00:08:29,833 –> 00:08:39,033
First we rename the incoming
channel to “x” and “y”.

87
00:08:39,033 –> 00:08:49,033
We re-range the 0 to 1 incoming
values to -.5 to positive .5.

88
00:08:49,033 –> 00:08:54,400
these values equate to “X”
position of the circle TOP.

89
00:08:54,400 –> 00:09:04,800
.5 represents the extent of
screen right, and negative .5
represents the extent of screen
left.

90
00:09:04,800 –> 00:09:06,833

91
00:09:06,833 –> 00:09:16,133
Next we re-range the incoming
“y” value of 0 to 1, to a range
of 0 to 60.

92
00:09:16,133 –> 00:09:25,133
This is our sample range. The
wave CHOP creates a range of 60
discrete samples.

93
00:09:25,133 –> 00:09:36,767
As we move the slider from left
to right, we change the value of
the waveform shape we are
sampling from.

94
00:09:36,767 –> 00:09:48,533
Here the slider has generated a
value of 17, and we are sampling
the 17th value of the sample
range of the waveform shape.

95
00:09:48,533 –> 00:09:49,667

96
00:09:49,667 –> 00:09:57,267
.5 represent screen top, -.5
represents screen bottom.

97
00:09:57,267 –> 00:10:03,000

98
00:10:03,000 –> 00:10:07,667
Let’s take a closer look at our
Python expressions.

99
00:10:07,667 –> 00:10:09,100

100
00:10:09,100 –> 00:10:24,700
In order to generate our “x”
value, we reference first the
“math1” operator, then channel
“x” from the “math1” operator,
and finally evaluate the sample.

101
00:10:24,700 –> 00:10:37,433
In this case, the “math1”
operator creates only one
sample, therefore we don’t need
to reference it specifically by
number when we evaluate it.

102
00:10:37,433 –> 00:10:39,933

103
00:10:39,933 –> 00:10:47,167
To generate our “y” value, we
use a slightly more complicated
Python expression.

104
00:10:47,167 –> 00:10:53,267
I’ll demonstrate how we nest one
Python expression within
another.

105
00:10:53,267 –> 00:11:03,933
We use the familiar sequence-
operator, channel, then sample-
when we create our expression
string.

106
00:11:03,933 –> 00:11:05,267

107
00:11:05,267 –> 00:11:12,667
We need to reference the
operator named “wave3” and its’
first channel.

108
00:11:12,667 –> 00:11:16,900
BUT which sample do we wish to
evaluate?

109
00:11:16,900 –> 00:11:21,967
We can choose any sample from a
range of 60.

110
00:11:21,967 –> 00:11:24,667

111
00:11:24,667 –> 00:11:35,300
In order to dynamically change
the sample we wish to evaluate,
we need another Python
expression.

112
00:11:35,300 –> 00:11:48,933
The value created by the slider,
and re-ranged by the “math2”
operator, is the number of the
sample we wish to evaluate.

113
00:11:48,933 –> 00:11:51,100

114
00:11:51,100 –> 00:11:59,300
To access this value, we use our
familiar Python string-
operator, channel, sample.

115
00:11:59,300 –> 00:12:09,733
The operator is “math2”, the
channel is 0, and we evaluate
the first sample.

116
00:12:09,733 –> 00:12:15,100
We can also access the channel
by name, in this case “y”.

117
00:12:15,100 –> 00:12:17,800

118
00:12:17,800 –> 00:12:30,933
Now I will cut that entire
Python expression string, and
use it as the “.eval” argument
in my first Python string.

119
00:12:30,933 –> 00:12:31,900

120
00:12:31,900 –> 00:12:42,500
Now the value of the “math2”
operator is the value we use to
sample the waveform shape of the
“wave3” CHOP.

121
00:12:42,500 –> 00:12:43,533

122
00:12:43,533 –> 00:12:53,233
By nesting one Python expression
in another, we are able to
access two operators
simultaneously-

123
00:12:53,233 –> 00:12:55,233
and apply selected values from
them to another operator- in
this case the circle TOP.