Forums > MaxMSP

How to make a double tap(click) button for monome

March 2, 2012 | 9:27 pm

I’m building a monome style controller with my launchpad, and wondering how to make a button, that when pushed quickly twice, will perform a different function, than if pushed once.

Apologies if this has been discussed on the forum before, but I couldn’t find anything when searching "double click" or "double tap".


March 2, 2012 | 10:26 pm

This is a good spot for thresh:

– Pasted Max Patch, click to expand. –

March 3, 2012 | 1:13 am

a "triple click" too…awesome.

Can I also make a "hold button" with thresh, that will perform a different function when the button is being held?


March 3, 2012 | 2:23 am

So you’re looking for a ‘tap, doubletap, or press/hold’ type thing? I had something like that setup for arduino stuff. I would imagine it’s not much different from the code above. I think the problem with using thresh is that you add a constant latency (ie the normal ‘tap’ won’t 300ms in the example above, which is quite slow/unresponsive. If you bring that number right down (to 50ms or so) it’s nearly impossible to get it to register a ‘double tap’.

You can have stuff be triggered by the button release as most of the time you release after pressing. That way you can use timer that checks how long between button press and release and if it’s over something short, then it’s a press and hold (or double tap etc..)


March 4, 2012 | 11:12 pm

Thanks again to Ben for the patch.

And thanks to Rodrigo for the great info. Now I can at least use the right terminology. Thanks for the tip about latency, I’ll make sure it controls something that is not dependent on low latency.

BTW, the Party Van looks like amazing. Should it work with a Launchpad too?


March 4, 2012 | 11:30 pm

I plan on putting something like this together as I need it for some Softstep programming, so when I do I’ll post it on this thread too.

Thanks. It should work as long as it’s compatible for serialosc (not sure how the emulation stuff works). You can map just about everything to MIDI control though, so there’s always that.


August 29, 2013 | 1:14 pm

I love that use of [thresh] to detect between single/double/triple taps! I had been using a [timer] into a series of [split]s, but this is much more graceful this way.

Here is an expanded patch, incorporating that use of [thresh], but also adding detection of long/held button presses.

This patcher takes MIDI velocity in, so any non-zero number is treated as a "button down" message, and any zero is treated as "button up".

It has 5 outlets that it will bang, respectively, for: single tap, double tap, triple tap, long hold (trigger ASAP), long hold (trigger on release).

The long hold (ASAP) outlet bangs as soon as the "long hold" interval is reached (500ms by default). The long hold (on release) outlet bangs only once the button is released.

Depending on what function the long hold is mapped to, you would want to use one type of trigger or the other. If you want to time an event to something musical, you’d want to use the long hold (on release) outlet, so you can lift the button right at the precise moment you want to trigger an event. But for something more "admin", like resetting a parameter, or jumping to the top of a list, you just want it to fire as soon as it knows you are doing a long hold.

(For non-English speakers, "ASAP" is short for "as soon as possible".)

– Pasted Max Patch, click to expand. –

cheers,
Leigh


August 29, 2013 | 1:30 pm

That’s quite elegant!


August 29, 2013 | 1:51 pm

Thank you! I wrote that tap-detector patch to interface Max4Live to a Logidy UMI3 foot controller. Here’s how I incorporated it into that environment:

Attachments:
  1. Screen-shot-2013-08-29-at-1.40.55-PM

August 30, 2013 | 3:21 pm

Here’s an expanded version of my patch above. As Rodrigo points out, the drawback to a patch that detects double taps is the latency (in this case, 300ms) that it adds to registering single taps.

In this patch, I’m passing single-tap triggers out through two different outlets. One sends an output bang immediately when it receives an input (button down), and the other sends an output bang only once the 300ms window has closed with only one bang (which I call single tap confirmed).

If, however, the patch detects that a user is actually making a double-tap or a "long hold", it sends a "cancel single tap" message out. So, the immediate version has no latency, but its truth is tenuous.

Therefore, choose wisely whether to use the single tap (immediate) or single tap (confirmed) outlet. The basic rule is, if you can’t undo whatever action you would start with a single tap, only use the confirmed version of the single tap.

cheers,
Leigh

– Pasted Max Patch, click to expand. –

Viewing 10 posts - 1 through 10 (of 10 total)