Quick explanation of how pd objects work, in regards to 'hot' and 'cold' inlets.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
firstly, as a general rule, only the inlet on the furthest to the LEFT is a 'hot' inlet.
any other inlets are 'cold'
if you send a value to a cold inlet, it will be stored inside the object, but no will be carried out until the hot inlet receives a value, or a bang, or something like that.
here's an example:
[7 ( [3 ( [5 (
| | |
[pack f f f]
|
[expr $f1 + $f2 + $f3]
|
[print result]
this has 3 message boxes, each with a number in it.
now, if you go out of edit mode, you can click on these message boxes to send the values into the [pack f f f] object.
if you click on the [7 ( before clicking on either the [3 ( or the [5 (, then the answer will be printed to the console as 7 + 0 + 0 = 7
(because [pack] initializes values to 0 when it is created)
ok, now,,,if you click on the [5 ( message, the number 5 will be sent into the pack object and stored there. However, because the right inlets are 'cold', nothing will be sent out FROM the pack object.
if you click on the [7 ( message again, the sum will be computed this time as:
7 + 0 + 5 = 12
likewise, once you click on the [3 ( message, nothing will happen, but then when you click [7 ( again, the sum comes out as 7 + 3 + 5 = 15
now, while this probably makes sense, you're probably still wondering..."why bother with cold inlets? why not just make them all hot?"
and the answer to that is there is a very significant issue when using pure data called 'order of execution', or 'evaluation order'.
look at the example again. there is a 7, a 3, and a 5. If you just click the 'hot' [7 ( BEFORE clicking the cold [3 ( and [5 ( , then the answer is output as '7'. However, if you want to add these numbers together, then you don't want to know that 7 + 0 + 0 = 7. All you want to know is what 7 + 3 + 5 is. SO, you need to store the 3 and 5 inside the object without triggering a computation. This is achieved by having cold inlets.
this all ties in with another VERY important object: the trigger [t ] object.
what [t ] does, is FORCE the order from RIGHT to LEFT.
so, if you make a [t b b b] the trigger object will send 3 'bang' messages. First from the right hand outlet, then from the middle, and finally from the left. This ties in perfectly with our hot/cold inlets in the next object, which expect to get messages from the right hand side first and then finally from the hot inlet on the left.
so, we can automate our process by doing this:
[bang(
|
[t b b b]
| | |
[7 ( [3 ( [5 (
| | |
[pack f f f]
|
[expr $f1 + $f2 + $f3]
|
[print result]
now, all you have to do is go out of edit mode again, and hit the [bang( message at the top. This single bang goes into the [t b b b] and gets output as 3 separate bangs, first on the right, then in the middle, and finally on the left.
look in your console, and you will see that the answer has been printed correctly as 15.
there are a couple of exceptions, notably the [timer] family of objects, but in general most pd objects follow this convention.