UpDown Counter needs to count first and last number twice...?

coffeencigs's icon

greetings.

iam using a counter to drive a step sequencer.

i want to add "palindrome" (play forward,play backward and so on) playback to it.

the problem is to keep it in sync.

i made a (counter 1 16) and set it to mode3 (count up then down)
the problem is.. it counts ... 14 15 16 15...
but to stay in sync i need it to count ... 14 15 16 16 15 14...
so the first and the last number have to be counted twice.

is this possible with just one counter?

Chris Muir's icon
Max Patch
Copy patch and select New From Clipboard in Max.

It's not pretty:

Roman Thilenius's icon

oh yeah, when i made my first counter with both a palindrome and
backwards/fprward mode i almost kicked the computer out of the window.

that was somewhen between the fifth and sixth attempt.

making it just run somehow is easy, but to make the "reset" work, change
the direction by user input, or changing the mode it is quite complicated
with only one counter object.

coffeencigs's icon

hey guys.

i thank you very much.
i got really mad while i was trying to figure it out myself.

Christopher Dobrian's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Two more goofy solutions:

Charlie Williams's icon

Hey all, brilliant. I can't believe how much time I spent trying to make counter do what it seems like it should just DO out of the box. Thanks!

Look, I didn't even have to post a question.

Gregory Taylor's icon

Wow. Here's my new teaching example for the adage "There's more than one way to do anything in Max."

While palindromes for your drum machine are things that you would definitely want, this is a *counter* object, and you don't duplicate upper or lower numbers when increment or decrement counters as the more general case, I think.

As long as you're at it, why not add inlets and outlets as required and save the one of these you really love in your patches folder with a nice name (palindrum?)? That way you can just type "palindrum" into an object box and never worry about it again!

Charlie Williams's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Agreed, GT, I'm amazed at how many ways there are to do this. Here's a non-drum-machine application for this functionality. I'm using counter to fade two panels' alpha channels, for a game-based patch. (The lit-up panel shows whose turn it is). With counter, the panels would fade in one direction (let's say it's fading out) and then "snap" back on at the end. So the final state always ended up being opposite of what I wanted. Perhaps there's an easier way around this, but:

Charlie Williams's icon

P.S. Vanille's way is awesome though. I aspire to that level of elegance. (As you can see, I have a lot of perspiring to do)

roger.carruthers's icon
Max Patch
Copy patch and select New From Clipboard in Max.

And here's another - not mine, I hastened to add, but I've been using it for so long, I've forgotten where it came from. Essential for arpeggiators too...

Anangel Argonaut's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Hello! I found this thread while looking for a way to code a palindrome mode for my step sequencer. Here is my solution, I hope someone finds it useful.