Forums > MaxMSP

filter to choose between 2 values


Dec 06 2013 | 8:03 am

hello,

i’m stuck at a point where i’m not sure what combination of if / route / gate / select objects i should use.

i have 2 variables: theta1, theta2
and 4 other variables: a, b, c, d

i want some kind of ‘filter’ that says:

if either ‘a’ or ‘b’ are equal to zero, then pass on "theta1"

if neither ‘a’ or ‘b’ are equal to zero, then compare ‘c’ and ‘d’.
if c>d then pass on "theta1".
if c<=d then pass on "theta2".

ideas?
thanks.

Dec 06 2013 | 9:17 am

let me see…

a, b, c, d, theta1, theta2

[expr ((($f1==0)||($f2==0))*$f5)+(($f1!=0)&&($f2!=0))*((($f3>$f4)*$f5)+(($f3<=$f4)*$f6))]

(untested)

you might need to add some [t b f] triggers before the theta inputs.

-110

Dec 06 2013 | 9:34 am

oh, and you have to add a [prepend set] before the first inlet, to make it _not trigger an output when you _dont want it.

Dec 06 2013 | 11:01 am

thanks for the reply roman.

for some reason whenever i trigger an output i get the answer $f5 (theta1) no matter what the case is.

Dec 06 2013 | 11:54 am

i just got this suggestion from a friend and it works

<code>
-- Pasted Max Patch, click to expand. --

</code>

Dec 06 2013 | 12:26 pm

You’re able to state your conditions logically, which is 50% of the job, so all you have to do is implement them in the given language. Here’s one way. (The pak object is just for easy input, to let you try different values for the variables; the evaluative code is in the if object.)

<code>
-- Pasted Max Patch, click to expand. --

</code>

Dec 07 2013 | 5:41 pm

thanks a lot for the input christopher

Viewing 7 posts - 1 through 7 (of 7 total)

Forums > MaxMSP