back and forth counter with repeating values?

Feb 20, 2013 at 6:00pm

back and forth counter with repeating values?

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.

#66631
Feb 20, 2013 at 6:15pm

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…

#239815
Feb 20, 2013 at 6:56pm

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. –
#239816
Feb 20, 2013 at 7:23pm

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.

#239817
Feb 20, 2013 at 7:26pm

thanks, Roger, I will check out your patch!

#239818
Feb 20, 2013 at 7:43pm

Here’s an abstraction that I call CounterSeeSaw:

– Pasted Max Patch, click to expand. –
#239819
Feb 20, 2013 at 8:47pm

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. –
#239820
Feb 20, 2013 at 9:20pm

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. :

#239821
Feb 20, 2013 at 9:51pm

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. –
#239822
Feb 20, 2013 at 10:45pm

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. –
#239823
Feb 20, 2013 at 11:41pm

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

#239824
Feb 21, 2013 at 8:35am

Chris,

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

#239825
Feb 21, 2013 at 12:21pm

Hi,

Why not with a polynomial regression ?

– Pasted Max Patch, click to expand. –
#239826
Feb 22, 2013 at 2:29pm

@Nicolas — génial !!

#239827
Feb 22, 2013 at 3:22pm

Hi,

@Peter : pretty odd use of math ! Thanks to http://www.xuru.org/rt/LR.asp from Euskal Herria.

#239828
Feb 22, 2013 at 7:57pm

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

#239829

You must be logged in to reply to this topic.