Forums > MaxMSP

if object help

January 17, 2007 | 5:40 pm

i dont know if anyone can help…. i have been looking at the if object and cant seem to be able to make it do what i want.
i need an statement that says if float in inlet 1 is equal to or greater than 150 then send a bang else if the float in inlet 1 is less than or equal to than 150 send another bang. sounds simple but cant seem to get it.
if anyone can help would be appreciated
cheers james


January 17, 2007 | 6:10 pm

Sure theres a way to do it all within the if object itself. But this way will work anyways.
T

max v2;
#N vpatcher 137 44 737 444;
#P window setfont Arial 12.;
#P flonum 349 120 35 12 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 349 151 138 131137548 if $f1>149 then 1 else 0;
#P button 187 278 15 0;
#P newex 187 241 138 131137548 select 1;
#P flonum 187 121 35 12 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 187 211 35 12 0 0 0 2001 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 187 152 138 131137548 if $f1>149 then 1 else 0;
#P connect 2 0 0 0;
#P connect 0 0 1 0;
#P connect 1 0 3 0;
#P connect 3 0 4 0;
#P connect 6 0 5 0;
#P pop;


January 17, 2007 | 6:15 pm

sorry mate but what is that??


January 17, 2007 | 6:27 pm

Chain two if objects.
On 17-Jan-2007, at 18:41, james wrote:

> i need an statement that says if float in inlet 1 is equal to or
> greater than 150 then send a bang else if the float in inlet 1 is
> less than or equal to than 150 send another bang. sounds simple but
> cant seem to get it.

————– http://www.bek.no/~pcastine/Litter/ ————-
Peter Castine +–> Litter Power & Litter Bundle for Jitter
Universal Binaries on the way
iCE: Sequencing, Recording &
Interface Building for |home | chez nous|
Max/MSP Extremely cool |bei uns | i nostri|
http://www.dspaudio.com/ http://www.castine.de


January 17, 2007 | 6:27 pm

James,

What you’ve said there is, effectively, that you should get a bang for
any value of $f1, which I’m sure isn’t what you meant. What’s wrong with
the split object in this context?


Owen

james wrote:
> i dont know if anyone can help…. i have been looking at the if
> object and cant seem to be able to make it do what i want. i need an
> statement that says if float in inlet 1 is equal to or greater than
> 150 then send a bang else if the float in inlet 1 is less than or
> equal to than 150 send another bang. sounds simple but cant seem to
> get it. if anyone can help would be appreciated cheers james
>
>


January 17, 2007 | 10:05 pm

Do you really mean >= 150 and < =150? Do you need 150.0 to make both conditions true? If so, then you may need to chain two if statements. But if not, try this:

[if $f1 < = 150.0 then out1 bang else out2 bang]

But, as has been pointed out already, [split 150.0] does the same job nicely.

#P button 411 144 15 0;
#P button 361 144 15 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 361 121 60 196617 split 150.;
#P button 265 143 15 0;
#P button 83 143 15 0;
#P flonum 259 69 41 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 83 121 192 196617 if $f1 < = 150. then out1 else out2 bang;
#P fasten 1 0 0 0 264 102 88 102;
#P fasten 1 0 4 0 264 102 366 102;
#P connect 4 0 5 0;
#P connect 4 1 6 0;
#P connect 0 0 2 0;
#P connect 0 1 3 0;
#P window clipboard copycount 7;

Tim


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