Threshold Bang

Sam Bilbow's icon

Hi all,

I've screenshotted part of my patch below. The number box is a constant stream of numbers (idle around 0, but peaks at around 0.9). I'm using the togedge object to bang whenever the number goes above 0.8 (like a threshold). However due to the nature of the stream of numbers, sometimes the number will hit 0.9, 0.0, then 0.9 again in quick succession (within milliseconds). Is there some sort of "hold" or release timer that I can implement so that I only get one bang in that scenario?

Thanks

Floating Point's icon

you could try using onebang and a variable delay to reset it, to filter out spurious threshold breaches (sort of a time-hysteresis):

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

Christopher Dobrian's icon

As @floatingpoint said, you need to wait a certain amount of time before permitting another event. The speedlim object imposes a minimum time between events, but that's a bit different from what I think you want, which is for no event to be permitted until such time as there has been no previous event for a certain amount of time. That's what his example does. Here's the same idea in the form of a reusable abstraction.

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

Sam Bilbow's icon

Thanks for your help guys, I used @floatingpoint's method and it worked so I've stuck with that.

Cheers