This is what I want to do (using pd-extended_0.43.4-1, Ubuntu 11.04): when the variable varA
changes, I want to explicitly set the variable varB
to 1; when either varA
or varB
changes, I want to compute the result of 2*varA+varB
, and print all three (varA
, varB
and the result) values.
I came up with this PD patch (code below):
The problem is - when I click to set the value of varA
, there are four printouts, all different; when I click to set the value of varB
, there are two printouts (which is why there is the metro
/onebang
thing - so I add a delimiter after such a quick sequence has finished, so I can see how many printouts were there per click). So after patch load - if I first click [2(
of varB
, and after I click the [2(
of varA
, I get the printout:
A/B/res: 0 0 2
A/B/res: 0 2 2
---------: bang
A/B/res: 0 2 1
A/B/res: 0 1 1
A/B/res: 0 1 5
A/B/res: 2 1 5
---------: bang
If I remove the bang
connections from the [t b f]
to the [pack]
, after patch load, and the same click sequence, then there is no printout for the first click (on [2(
of varB
), and for the subsequent click of varA
I get:
A/B/res: 2 1 5
... which actually turns out to be correct (as 2*2+1 is 5, given that varA
also sets varB
to 1); and it's printed in a single line, which is what I want. However, I'd like the same effect when values for varB
are changed - which is why I added those [t b f]
there in the first place (however, those cause multiple messages to be output/printed).
What is the recommended way to do this (e.g. output a list - but only once - from an object, and only after other calculations have completed)?
(I simply don't trust removing the bang connections from the [pack]
, as it's pretty clear that [expr]
should finish later than when varA
comes into the hot inlet of [pack]
, if it is varA
being set. The [onebang]
thing could be modified to "gate" quick sequential messages if the timing isn't relevant - but what if I need the reaction/printout ASAP after the result has been computed?)
Thanks in advance for any answers,
Cheers!
Patch as attachment: test.pd