## Counter reset to new number and start "0 1 2 3 4" count

Jun 16, 2011 at 7:21pm

# Counter reset to new number and start "0 1 2 3 4" count

Hi everyone,

I’ve tried and tried, search the help, tutes and forums, but I’m really boiling up on the counter-object these hours…
I need a behaviour like this: the counter gets bangs and counts from 0 and upwards. When it reaches max, its resets and gets a new max. E.g.:

0 1 2 (MAX! New max: 8)
0 1 2 3 4 5 6 7 (MAX! New max: 3)
0 1 2 (MAX! New max: 8)

I’ve tried lots of things – see my suggestions below. Actually I don’t quite understand the counter behaviour in them – so if anyone could explain the double 0 and the -1 in them, I would be more than extremely thankful!

A quick solution to my problem would even extend my thankfulness :)

– Pasted Max Patch, click to expand. –
#57645
Jun 16, 2011 at 8:09pm

something like this?

– Pasted Max Patch, click to expand. –
#206558
Jun 16, 2011 at 8:28pm

You could simply change the max value if the counter is at 0, like this

– Pasted Max Patch, click to expand. –
#206559
Jun 16, 2011 at 9:19pm

Thanks a lot – great feedback! :)

@Gregory Taylor: My patch is showing three ways I tried to solve the problem. Bangs are to be generated from the big button in the top. The message boxes in the bottom show how each of the solutions fail in different ways. Of course I should have made this more clear.

I like your thoughts on the counter – but I think I need a few days to digest them. But you’re right that it’s something in the high counter value / maximum I need to get my head around.

@kochhw: Nice solution! Works! Thanks man! :D

@broc: Yeah, that’s how it should work (in my head too!). I tried out something like this. The problem is, when the max value is 3 and goes to 8, the counter doesn’t get reset. So it always goes: 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 and so on.

Until I get in depth with the details of the counter object’s “high counter value” / “maximum” and how it resets – which I still hope can do this relatively simple task, without to much workaround! – I just came up with a rather simple solution, where the resetting takes place completely outside the object:

– Pasted Max Patch, click to expand. –

I’m very open to more discussion and thoughts – I would really like a decent friendship with this object… :)

#206561
Jun 16, 2011 at 10:19pm

note that your version has a flaw: if you paste it into an empty patcher, the first two numbers will be 0.
this is due to missing initialization of the select object. i changed something in your version to mend this (and replaced the 2nd counter with cycle, which does the same simpler)

– Pasted Max Patch, click to expand. –
#206562
Jun 16, 2011 at 11:41pm

I think the problem was that you were pulling the rug out from counter by setting a new max before it reset from the previous max.

– Pasted Max Patch, click to expand. –
#206563
Jun 17, 2011 at 8:49am

@kochhw: Thanks a lot – you’re perfectly right :)
@Chris Muir: Yeah that makes sense… ahh I think the problem was, that I thought setting a new max meant resetting… things are clearing up :) Thanks for your solution, I like it!

#206564
Jun 17, 2011 at 4:24pm

You can easily extend my approach for more endpoints by adding more numbers to the [sel] and increasing the modulo [%] number.

#206565
Jun 19, 2011 at 6:55pm

Yep. :) But I actually combined your solution with the cycle object of kochhw’s approach instead of the sel+modulo thing – even more simple!

Just out of pure curiosity: Does the [t b b] object in your solution have anything to say?

Thanx again guys – you’re truly great – I’ve learned a lot!

#206566

You must be logged in to reply to this topic.