Eliminating double triggering

wisemonkey's icon

Hi - I'm new to Max MSP and am trying to find the best way to do the following: I have a midi device that is sending midi into the computer, and occasionally it double-triggers. Is there a way to set up hysteresis or use some other method so that there is a short time threshold that applies to stop repeated notes from triggering - in other words, I'd like the system to play the first midi note it receives, and then ignore the same note for say, 50 milliseconds for example. I suspect this might have something to do with the speedlim command or something - otherwise is there a plug in or a pre-existing max app that I can use that will stop this doubletriggering? Thanks very much for your help!

pid's icon

thresh

quickthresh

etc

wisemonkey's icon

Thanks pid - can you be more specific? I've also just noticed the sensor-tamer. Is this a better way to go?

pid's icon

just load thresh and quickthresh into a patcher and look at the help and ref files - it is all very simple and they explain better than i could. sensor tamer is an abstraction that would interesting look inside of, sure. but what you need to do is very achievable with the aforementioned objects.

AlexHarker's icon

I tend to use this (there may be a better way) - I believe this is quicker than thresh, because the bang you want goes straight through with no delay.

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

If you want to use messages other than bangs in, put a [t b] in front of the delay to transform any message into a bang..

Alex

AlexHarker's icon

Or - if you look at the sensor tamer abstraction - you only need the debouncer subpatch. This does the same thing with one less object, but would be slightly harder to adapt to other messages. In fact - it's possible you could do it in just two objects (the onebang and the del(ay)...

Alex

Emmanuel Jourdan's icon
Max Patch
Copy patch and select New From Clipboard in Max.

A simpler solution using onebang:

Bas van der Graaff's icon

Wouldn't it be an idea to use [speedlim] here, in order to make sure you always have the correct last value sent through, even when the midi signal 'bursts'?

genfu's icon

in the triggering i have in my patch, i have a delay you can set before another trigger is possible. it is just done with a gate, where triggers can only pass through the gate to be received when the gate is open. when the first trigger is sent, it passes through the gate and immediately closes it. you then have a delay which you can adjust the time of, after that time has elapsed a bang is sent to open the gate again, at which point a second trigger can pass through. this may not be the most straightforward way to do it, but it works fine if all you want to do is say prevent 2 triggers within 50ms (or any other value).

Andrew St Hilaire's icon

I'm using an Akai MPK Mini II with the sustain pedal to trigger my scene launches in Ableton Live 10. Sometimes I'll get a double trigger which is a problem since it will relaunch the scene from the top and ruins a live performance. Is there anything I can use with Max 7 or Max 8 that will prevent these double triggers like something that will let the first MIDI CC64 through but block any subsequent messages for 10 seconds which should solve my problem? I know this is an old thread but I couldn't find anything else.

Jean-Francois Charles's icon

I'm not sure about the exact way you get your CC64, but if you want to filter out the 0 value, you can use [sel]:

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

Jean-Francois Charles's icon

If you're looking for a debounce function, there are several ways. You would certainly use a [gate] and maybe something like [del]:

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

kLSDiz's icon

A classic "switch-scenes-with-sustain-pedal" solution (very similar to JFC patch, but reduced to bare minimum).

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

Andrew St Hilaire's icon

Jean-Francois Charles, can you possibly help me out? It sounds like the debounce is what I need, but I don't know where to paste the patch or how to set this up. I'm getting the CC64 by pressing the sustain pedal on my controller which is mapped to the Play button. I'm also using a Max plugin by Isotoniks Studio called Follow which allows for follow actions after each scene so with that, my next scene is cued up and ready for me to launch with the press of the sustain pedal again and this continues through my entire performance. I only need to use the sustain pedal to trigger everything I need until something goes wrong with the double trigger I experience only 1% of the time. Sometimes it's flawless but when it happens, it's unpredictable and not good. Where do I put the code you shared for debounce and how to do I then set it up? Hopefully it will allow me to set a timer of maybe 0.5 seconds or something to block subsequent CC64 until the timer elapses and then it's ready for my next trigger press. I'd really appreciate a little more guidance on what to do since I don't use Max much and I can't figure out where to paste the code.