Forums > MaxMSP

if/then/else sentence

Jan 27 2008 | 3:26 pm

hi,

( first at all, my English is not good. )

I’m trying to do the following:

if \$i1 >= 13 then out=\$i1-12 else \$i1

" out=\$i1-12 "
how can I do that?

I just want numbers over 12 to be subtracted by 12.

is it clear?

the solution I find is using the i\$2 with one more object with the \$i1-12 expr, so…

if \$i1 >= 13 then \$i2 else \$i1
where \$i2 is "\$i1-12"

but… i’m sure there is a way to do this with one single "if sentence", isn’t it?

thnks,
damian.

Jan 27 2008 | 3:55 pm

why not just do something like this – it seems easier to me:

I’ll have to admit that, with if statements, I probably use the
"out2" bit more often than not.

[ddg]
Darwin Grosse

Jan 27 2008 | 4:16 pm

Depending on what you’re doing (there was no info on the context of
what this is for) you might just be looking for %12 (modulo 12) –
this just gives you the remainder after dividing by 12.

#P window setfont "Sans Serif" 9.;
#P number 83 180 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 83 125 34 196617 % 12;
#P number 83 87 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P connect 1 0 2 0;
#P connect 0 0 1 0;
#P window clipboard copycount 3;

—-
Steven M. Miller
Professor, Contemporary Music Program
College of Santa Fe

Jan 27 2008 | 4:19 pm

>I just want numbers over 12 to be subtracted by 12.

I would do it like this:

#P window setfont "Sans Serif" 9.;
#P number 314 173 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 349 142 30 196617 – 12;
#P number 314 90 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 314 116 45 196617 split 12;
#P connect 1 0 0 0;
#P connect 0 1 2 0;
#P connect 0 0 3 0;
#P fasten 2 0 3 0 354 166 319 166;
#P window clipboard copycount 4;

/J

jr.abstractions for MaxMSP – new version (2008-01-15)
http://www.sonicescape.net/maxmsp/

Jan 27 2008 | 4:38 pm

thnks a lot.

"Modulo operator" seems to be perfect.

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

Forums > MaxMSP