Forums > MaxMSP

if sentence

November 29, 2010 | 8:08 am

Hi forum,

I am new to max, so a simple question:

How do I make an if sentence that can set a toggle to 1 when the value is between 0 and 10?

I have tried to do it here – see the code below. I can’t get it to work …

– Pasted Max Patch, click to expand. –

Thanks for your help!


November 29, 2010 | 8:32 am

using the [if] expression, I would say

if $1 <10 then out 2 1

and connect outlet 2 to your toggle;
look at the helpfile for [if] under ‘multiple conditions’ to get the syntax correct;

this will continuously give a 1 when input is <10, if you want it to happen only once look at [onebang]


November 29, 2010 | 11:26 am

Two other approaches, using [split] and [expr].

_
johan

– Pasted Max Patch, click to expand. –

November 29, 2010 | 1:41 pm

[expr $i1>=0 && $i1< =10]


November 29, 2010 | 6:45 pm

At the risk of being known as the "benchmark guy" I’m happy to report that expr wins this race:

– Pasted Max Patch, click to expand. –

November 29, 2010 | 8:17 pm

being the benchmark guy is important, it’s good to see how things compare under the hood.


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