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.
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...
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
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.
thanks, Roger, I will check out your patch!
Here's an abstraction that I call CounterSeeSaw:
I did it with [split] and like four other objects - this is about as small as I can get it, I think.
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. :
Wetterberg,
Never mind what I said about breaking it - also, I don't think the modulo is needed, see this patch...
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
yeah, the modulo is left over from the patch it's copied from - it normally hooks into [transport]
Chris,
Your design is the most user friendly, no doubt. :)
@Nicolas — génial !!
yes, very interesting bit of math there, Nicolas. :)