Gen~: Instantaneous reset trigger for counters?

noddy-oer's icon

Hello! I'm working on a gen~ patch that relies on using two separate counters to drive two peek objects. At certain points the counters become unsync'd and I'm looking for a way to send an instantaneous trigger into their middle inlets when a parameter changes value (it's a param that only goes from 0->1 or vice versa).

I tried just setting that param into the middle inlets but as expected that just sends a steady stream of samples with whatever value the param has, and so would re-trigger the counter once per-sample which is not what I want.

Any suggestions greatly appreciated, thanks!


dequalsrxt's icon

Send the parameter output to a trigger object, bang from the trigger object to click~, then click~ into the gen counter reset input.

noddy-oer's icon

That worked, thank you!

dequalsrxt's icon

Sure thing! (and some more words to satisfy the minimum comment length of 15 characters)

Graham Wakefield's icon

It's better to keep it all inside gen if you can, for tighter timing.

Send the param to a change op, send that to a > 0 op, and send that to the counter middle inlet.

Counter's middle inlet will hold the count at zero as long as the signal at the middle inlet is any nonzero value.

Change outputs 0 if the input is not changing, or 1 or -1 if the input is rising or falling. Since you only want the rising edge, use a > 0 to detect only that.

So any rising param will reset the counter, everything else is ignored and lets the counter continue.

dequalsrxt's icon

Ah, hadn't considered that. So would using a trigger object on the top level max patch add an extra vector of latency? I have a similar two counter gen patch, but in my case the timing doesn't matter so long as both counters stay synced.