Forums > MaxMSP

back and forth counter with repeating values?


Feb 20 2013 | 6:00 pm

hey folks,

What’s the simplest way to make the counter object go back and forth like this:

0 1 2 3
3 2 1 0
0 1 2 3
3 2 1 0
etc.

Feb 20 2013 | 6:15 pm

set the range to 1 greater in each direction, so [counter -1 4 2] for your example.

add a [sel -1 4] object to the output. The rightmost outlet of [sel] lets the values out that you want. Both of the other two should bang the counter so there’s no appreciable delay as it hits the extreme values, then it’ll go back into the range of values you want. You could use [split] in the same way.

Try it out, I can’t try it here so maybe there’s stuttering, but I think it should be OK…

Feb 20 2013 | 6:56 pm

I asked the same question years ago, and someone kindly provided me with this (you are excused for not finding it via a search, because it would have been on the old McGill mailing list ;-)
Inlets are count min and max,
Cheer
Roger


-- Pasted Max Patch, click to expand. --

Feb 20 2013 | 7:23 pm

seejayjames,

thanks but that gives me this output:

0 1 2 3 3
3 2 1 0 0
0 1 2 3 3
3 2 1 0 0
etc.

Feb 20 2013 | 7:26 pm

thanks, Roger, I will check out your patch!

Feb 20 2013 | 7:43 pm

Here’s an abstraction that I call CounterSeeSaw:


-- Pasted Max Patch, click to expand. --

Feb 20 2013 | 8:47 pm

I did it with [split] and like four other objects – this is about as small as I can get it, I think.


-- Pasted Max Patch, click to expand. --

Feb 20 2013 | 9:20 pm

Thanks, Chris. That works!

Wetterberg: Thank you. Yours is definitely the simplest solution that works. Although, when I tried to modify it to work with different number ranges, I quickly broke it. :

Feb 20 2013 | 9:51 pm

Wetterberg,

Never mind what I said about breaking it – also, I don’t think the modulo is needed, see this patch…


-- Pasted Max Patch, click to expand. --

Feb 20 2013 | 10:45 pm

Well, if object count is paramount, here’s my CounterSeeSaw with the two routes replaced by one sel. :-) I’m still up a couple of message boxes, though.

It’s worth noting that CounterSeeSaw can count between arbitrary ranges, e.g. 1-4, 10-20


-- Pasted Max Patch, click to expand. --

Feb 20 2013 | 11:41 pm

yeah, the modulo is left over from the patch it’s copied from – it normally hooks into [transport]

Feb 21 2013 | 8:35 am

Chris,

Your design is the most user friendly, no doubt. :)

Feb 22 2013 | 2:29 pm

@Nicolas — génial !!

Feb 22 2013 | 7:57 pm

yes, very interesting bit of math there, Nicolas. :)

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

Forums > MaxMSP