Most efficient way to only trigger once

I was making a sample-and-hold module with a slight twist, and i was using SchmittTrigger’s process function to try to receive a trigger and call another function only once every time the gate switches to high. However, this didn’t behave as expected for me because it seemed to return true it every cycle that the gate was high, instead of just returning true when the gate changed from low to high. I was going to approach this by having a boolean flag that’s set to true when the gate goes high, and set back to false when it’s low, but I’m sure there’s a cleaner way of doing that.

EDIT: I had this problem was because i was reusing the same SchmittTrigger for two different inputs.

yeah, that’s what they are supposed to do, I think. I’ve been using this dumb code for many years to do both: SquinkyVCV/GateTrigger.h at main · squinkylabs/SquinkyVCV · GitHub

I wouldn’t worry much about efficiency here… (alhough if you module is polyphonic it would be convenient to have something that works with float_4).