Forums > MaxMSP

Auto Increment To Specific Integer Then Return To 0

July 22, 2008 | 3:38 pm

Hi there,

I’m trying to increment a value to 255 then once it hits this value, returns to 0 and stays at 0.

I’ve tried it with tempo, then using split to find out when it’s at 255 then needed to decrement it but I don’t think this is the easiest way.

Any ideas?

Thanks,
Neak.


July 22, 2008 | 3:59 pm

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 186 195 47 196617 gate 1 1;
#P newex 159 353 27 196617 != 0;
#P number 186 329 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 186 295 40 196617 % 256;
#P newex 186 237 27 196617 i;
#P newex 186 268 27 196617 + 1;
#P button 223 159 15 0;
#P connect 6 0 2 0;
#P fasten 5 0 6 0 164 381 135 381 135 167 191 167;
#P connect 0 0 6 1;
#P connect 4 0 5 0;
#P fasten 4 0 2 1 191 363 269 363 269 222 208 222;
#P connect 3 0 4 0;
#P connect 1 0 3 0;
#P connect 2 0 1 0;
#P window clipboard copycount 7;


July 22, 2008 | 4:24 pm

Quote: LoneMonad aka don malone wrote on Tue, 22 July 2008 09:59
—————————————————-
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P newex 186 195 47 196617 gate 1 1;
> #P newex 159 353 27 196617 != 0;
> #P number 186 329 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 186 295 40 196617 % 256;
> #P newex 186 237 27 196617 i;
> #P newex 186 268 27 196617 + 1;
> #P button 223 159 15 0;
> #P connect 6 0 2 0;
> #P fasten 5 0 6 0 164 381 135 381 135 167 191 167;
> #P connect 0 0 6 1;
> #P connect 4 0 5 0;
> #P fasten 4 0 2 1 191 363 269 363 269 222 208 222;
> #P connect 3 0 4 0;
> #P connect 1 0 3 0;
> #P connect 2 0 1 0;
> #P window clipboard copycount 7;
>
>
—————————————————-

Thanks for the patch but that only resets to 0 rather than decrementing back down to 0.


July 22, 2008 | 4:38 pm

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P message 218 237 19 196617 -1;
#P newex 186 362 44 196617 sel 255;
#P button 223 169 15 0;
#P newex 139 365 27 196617 t i i;
#P newex 156 420 47 196617 gate 1 1;
#P newex 156 396 31 196617 == 0;
#P newex 186 195 47 196617 gate 1 1;
#P newex 193 396 27 196617 != 0;
#P number 186 329 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 186 237 27 196617 i 0;
#P newex 186 268 42 196617 + 1;
#P connect 7 0 3 0;
#P connect 8 0 4 1;
#P connect 4 0 1 0;
#P connect 10 0 0 1;
#P fasten 9 0 10 0 191 388 307 388 307 230 223 230;
#P connect 2 0 7 0;
#P connect 2 0 9 0;
#P fasten 2 0 1 1 191 356 269 356 269 222 208 222;
#P connect 0 0 2 0;
#P fasten 6 0 4 0 161 443 130 443 130 187 191 187;
#P connect 7 1 5 0;
#P connect 1 0 0 0;
#P connect 3 0 6 1;
#P connect 5 0 6 0;
#P window clipboard copycount 11;


July 22, 2008 | 4:40 pm

Quote: LoneMonad aka don malone wrote on Tue, 22 July 2008 10:38
—————————————————-
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P message 218 237 19 196617 -1;
> #P newex 186 362 44 196617 sel 255;
> #P button 223 169 15 0;
> #P newex 139 365 27 196617 t i i;
> #P newex 156 420 47 196617 gate 1 1;
> #P newex 156 396 31 196617 == 0;
> #P newex 186 195 47 196617 gate 1 1;
> #P newex 193 396 27 196617 != 0;
> #P number 186 329 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 186 237 27 196617 i 0;
> #P newex 186 268 42 196617 + 1;
> #P connect 7 0 3 0;
> #P connect 8 0 4 1;
> #P connect 4 0 1 0;
> #P connect 10 0 0 1;
> #P fasten 9 0 10 0 191 388 307 388 307 230 223 230;
> #P connect 2 0 7 0;
> #P connect 2 0 9 0;
> #P fasten 2 0 1 1 191 356 269 356 269 222 208 222;
> #P connect 0 0 2 0;
> #P fasten 6 0 4 0 161 443 130 443 130 187 191 187;
> #P connect 7 1 5 0;
> #P connect 1 0 0 0;
> #P connect 3 0 6 1;
> #P connect 5 0 6 0;
> #P window clipboard copycount 11;
>
>
—————————————————-

Ah perfect thankyou :)


July 22, 2008 | 4:49 pm

On Jul 22, 2008, at 8:38 AM, Neak wrote:

> I’m trying to increment a value to 255 then once it hits this value,
> returns to 0 and stays at 0.

It was unclear to me whether you wanted the number to decrement back
down to 0 or to jump to 0, so this is a little more complicated than
it needs to be, because it can do both:

– Pasted Max Patch, click to expand. –

-C

Chris Muir
cbm@well.com

http://www.xfade.com



jln
July 22, 2008 | 4:58 pm


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