Forums > MaxMSP

detect when in range

April 16, 2006 | 10:19 pm

i need to see wether a number is within a certain range, is there a way of attaching an AND to the ‘if’ object?

for example

if $1 < 1 AND > 1 …


April 16, 2006 | 10:32 pm

Have a look at the logic ops like || and &&. These are common
programming operations. || means logical or and && means logical and.
Most expression objects will support these operations as well.

wes


April 16, 2006 | 10:36 pm

thanks for that.


April 16, 2006 | 11:14 pm

cool, i have worked out the syntax vaguely, how can i get a if object to output a bang?


April 16, 2006 | 11:19 pm

here is the patch

max v2;
#N vpatcher 30 89 630 489;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 60 83 39 196617 set $1;
#P flonum 179 163 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P button 151 166 15 0;
#P newex 164 111 134 196617 if $i1* $i1 < 9 then set $i1;
#P flonum 174 60 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 8;
#P comment 334 68 100 196617 trying to assess if the input is between _3 and 3 , which the equation should do , and then output a bang , but i cant get it to output anything!!!;
#P connect 1 0 5 0;
#P connect 2 0 3 0;
#P connect 5 0 2 0;
#P connect 2 0 4 0;
#P pop;


April 16, 2006 | 11:23 pm

sel 1 will output a bang if the input is 1

trigger b will always output a bang

depends on what you want.

wes


April 16, 2006 | 11:31 pm

Here’s the patch below. Some friendly advice which is probably too
late for you now…read the manual and do the tutorials. Your patch
showed some serious misunderstandings of max.

#P button 211 226 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 224 171 124 196617 if $f1* $f1 < 9 then bang;
#P flonum 234 120 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 8;
#P comment 394 128 100 196617 trying to assess if the input is between
_3 and 3 , which the equation should do , and then output a bang ,
but i cant get it to output anything!!!;
#P connect 2 0 3 0;
#P connect 1 0 2 0;
#P window clipboard copycount 4;


April 16, 2006 | 11:31 pm

could you look at the patcher,as it is not outputting anything at all

cheers


April 16, 2006 | 11:49 pm

cant get that patcher to load, it just comes back up as text. isnt a patcher as text supposed to end with a ‘pop’ message?

"read the manual and do the tutorials. Your patch
showed some serious misunderstandings of max." —i know. basically, i started with max about a year ago, then got quite heavily into flash.

unfortunatly, my memory isnt as good as i had hoped, but i am on a tight deadline for my degree (music technology) and my project must be in max (well, or PD, but we wont go there!!)

so i am relying on you peoples kind hearts and my own intensive ‘on the job’ research’ to get through

for the record, when you say serious misunderstandings, what do you mean?

again, thank you very much for your patience. for the record i am very much enjoying my learning, and when i can i will return the goodwill by participating on this forum in a helping capacity

cheers


April 16, 2006 | 11:53 pm

I sent you a version that does what you want. See my last email.

wes


April 16, 2006 | 11:59 pm

Ok,
you can just copy the text using command+C (apple + c on mac) and past
using command+v into a patcher. All of the objects should appear and
work.

> for the record, when you say serious misunderstandings, what do you mean?
>

You were using the set message to do things that you can’t use the set
message to do. Also, the fact that bang is a message and can just be
written as text for output from the if object.

wes


April 17, 2006 | 12:00 am

emailed me direct? or PM the forum? i havent recieved any emails from you!

psc.recordings@gmail.com


April 17, 2006 | 12:13 am

thanks for all you help!!

got it now

i’d like to say thats the last simple question i will have, but it wont be, so i wont!!

again

cheers

John


April 17, 2006 | 12:19 am

Remember the one that you couldn’t get to load?? Try that one using
the instructions for copying and pasting. If you want to see it in
the forum, go here:
http://www.cycling74.com/forums/index.php?t=msg&th=19379&sta rt=0&rid=0&S=9dfa076a35fe24529ead0ab137c5878f


April 17, 2006 | 12:26 am

yeah, got it

i never realised you could copy text direct into a patcher

for the record, is there a way to extract text from a patcher also?

my current method is to re-open the patcher as text and then copy and paste it


April 17, 2006 | 12:36 am

also

in the help file for ‘if’ they use the syntax $i1, whereas in your solution you have used $f1, could you explain?


April 17, 2006 | 12:39 am

same way highlight your objects and command+c.


April 17, 2006 | 12:51 am

one is for floats one is for ints


April 17, 2006 | 11:26 am

I think the split object may be what you’re looking for,
Cheers
Roger


April 17, 2006 | 2:52 pm

Quote: 88mph wrote on Sun, 16 April 2006 16:19
—————————————————-
> i need to see wether a number is within a certain range, is there a way of attaching an AND to the ‘if’ object?
>
> for example
>
> if $1 < 1 AND > 1 …
—————————————————-

[if and if then else ... ] will not work, you
would have to use two [if]s in series.

what you want (topic) could be done by [split 22 33].


April 17, 2006 | 3:06 pm

[if ($f1 >= 1) && ($f1 < = 2) then $f1 else out2 $f1]

is equivalent to

[split 1 2]

/*j

#P window setfont "Sans Serif" 9.;
#P flonum 418 187 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 456 187 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 418 159 48 196617 split 1 2;
#P flonum 286 81 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 128 187 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 358 188 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 128 159 240 196617 if ($f1 >= 1) && ($f1 < = 2) then $f1 else
out2 $f1;
#P connect 4 1 5 0;
#P connect 4 0 6 0;
#P connect 3 0 0 0;
#P connect 3 0 4 0;
#P connect 0 0 2 0;
#P connect 0 1 1 0;
#P window clipboard copycount 7;


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