[gen] latch function-- any ideas?

Floating Point's icon

Just wondering....
well I've been at a loss how to do this, seem to be going around in circles, maybe someone can help.

Consider this: A single sample impulse (say from click) is used to make an output stream raise from zero to 1. Subsequent clicks are ignored until the stream is reset to zero after a certain amount of time. Seems simple, and I'm sure it is but I can't figure it out.
thanks......in.......advance......

MuShoo's icon

I've been battling the same issue (though slightly different terms) - perhaps my attempts will be helpful. Not triggered from click, though, mine was meant to function as a phasor~ replacement, and will automatically start a new ramp once the 'certain amount of time' has passed.

Max Patch
Copy patch and select New From Clipboard in Max.

Still, I don't like my approach - it feels VERY clunky and has some of it's own issues (phase resetting is merely a delay, not an actual phase amount, and so it cannot be adjusted in 'real time').

Also I barely remember how it actually works - but I'm using two internal accumulators - one to output the actual ramp, and another that counts until it matches the 'stall' time needed after a ramp. If you hook up a number box or some form of changing number to a ($1 reset) message box and feed that in, you can restart all the accumulators.

Floating Point's icon

Thanks MuShoo, I managed to work it out after looking at the way you used the accum and history operators.

Max Patch
Copy patch and select New From Clipboard in Max.

I've made it so you can cascade the gen latch subpatches to control polyphony as illustrated in this patch (might be useful to someone):

btw maybe the c74 people could code up a gen latch operator (and an msp external version as well). It's a pretty fundamental function really-- surprised there hasn't been one made yet...

Graham Wakefield's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Not sure if this is what you wanted, but it's a basic latch:

Floating Point's icon

Thanks Graham-- it's much simpler than my version.
T