Need Help – Selecting a range between 2 number outputs

Dec 9, 2009 at 3:38pm

Need Help – Selecting a range between 2 number outputs

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.

#47122
Dec 9, 2009 at 3:53pm

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

– Pasted Max Patch, click to expand. –
#169408
Dec 9, 2009 at 4:02pm

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?

#169409
Dec 9, 2009 at 4:56pm

Is this what you mean?

– Pasted Max Patch, click to expand. –
#169410
Dec 9, 2009 at 5:11pm

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

#169411
Dec 9, 2009 at 5:16pm

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

#169412
Dec 9, 2009 at 5:18pm



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

#169413
Dec 9, 2009 at 5:18pm

ahhhhh!

#169414
Dec 9, 2009 at 5:40pm

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

#169415

You must be logged in to reply to this topic.