Forums > MaxMSP

Need Help – Selecting a range between 2 number outputs

December 9, 2009 | 3:38 pm

I am working on a tangible interface where I can track the X & Y values of a symbol but I don’t know how to set a range so that when the symbol goes within that range it triggers a bang.

e.g. trigger a bang if the symbol goes lower than a value of 60 for the X axis and higher than 440 on the Y axis.

Help would really be appreciated. Thanks.


December 9, 2009 | 3:53 pm

If I understand you correctly something like this should do it:

– Pasted Max Patch, click to expand. –

December 9, 2009 | 4:02 pm

Thats great thanks. How would I do it so that it will only output a bang if they are both in the correct area instead of a bang for each?


December 9, 2009 | 4:56 pm

Is this what you mean?

– Pasted Max Patch, click to expand. –

December 9, 2009 | 5:11 pm

That is exactly what I was looking for, thanks mate!


December 9, 2009 | 5:16 pm

i cant look at max5 code and i dont understand the given case, but something like
[code]
[strong]
[if ($f1>200)&&($f1<400)&&($f2>300)&&($f2<700) then bang]
[/strong]
[/code]

should do the job.

under circumstances you will prefer to do the opposite, and bang only when
the mouse leaves the wanted area.

good use of the [change] object should also be on your to do list for such
interface things.

-110


December 9, 2009 | 5:18 pm



[if ($f1>200)&&($f1<400)&&($f2>300)&&($f2<700) then bang]


December 9, 2009 | 5:18 pm

ahhhhh!


December 9, 2009 | 5:40 pm

btw, (now that i found out about the markup code) you can also
combine the if_then logic with [clip]ing your X and Y values.

let me try this without looking at max – i am hopefully getting it
right offhand:

for X:

expr ( ($i1>$i3) && ($i1< $i4) && ($i2>$i5) && ($i2< $i6) ) * ( min(max($i1,$i3),$i4) )

for Y:

expr ( ($i1>$i3) && ($i1< $i4) && ($i2>$i5) && ($i2< $i6) ) * ( min(max($i2,$i5),$i6) )

inputs:

X mouse = $i1
X low limit = $i3
X high limit = $i4

X mouse = $i2
X low limit = $i5
X high limit = $i6

the two expression will output 0 when the condition is not met.

this means that you will have to add a [route 0] behind, and it also means
you cant use negative values (and also not 0 !)

-110


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