Hi, yes, that's a great example of the kind of "gestures" that you can easily add support for using Midi Translator Pro.
The basic idea is this:
1) whenever you press the MIDI button (first), you start a timer that expires in, say, 500 milliseconds (half a second).
2) when the timer expires, you know that any following button press cannot be part of a double click, because the last click has been at least 100ms ago
3) if you press the button before the timer expired, you know it's a fast repetition.
Code: Select all
Translator 0: First press of button 1: start timer
Options: stop=false
Incoming: MIDI 90 5D 7F
Rules:
gc=gc+1
Outgoing: One-shot timer "Double Click Expiry 1": 300 ms delay
Translator 1: Second press of button 1: double click
Options: stop=false
Incoming: MIDI 90 5D 7F
Rules:
if gc!=2 then exit rules, skip Outgoing Action
gc=0
Outgoing: MIDI C0 01
Translator 2: Doubleclick Timer 1 Expired
Options: stop=false
Incoming: On timer "Double Click Expiry 1"
Rules:
gc=0
Outgoing: (none)
The example assume that your button sends a Note On message on channel 1 (=90), on note 93 (=5D hex) with maximum velocity 127 (=7F hex). To use a different message, use the MIDI capture function in MT. Replace the Incoming MIDI message in Translator 0 and in Translator 1.
In Translator 0, we use a (arbitrary) global variable "gc" to store the click count. By default it's 0, and everytime you press the button, it is increased by one. Also everytime you press the button, the timer is (re)started (in the outgoing action).
In Translator 1, which is also triggered when you press the button, we check if the click count is 2. If it is NOT 2, ignore this translator's outgoing action. If it is 2, we reset the click count to 0 and execute the outgoing action. In this example, I output a MIDI Program Change message, but you can send any MIDI message, or emulate a keystroke, or whatever is possible with MT.
Translator 2 is triggered when the timer expires, i.e. 500ms after the last button press. It just resets the click count to 0.
You can define a double click behavior for as many buttons as you like using this scheme, but note that you will need to use a different global variable for each button, and a different timer name, too.
In order to define an action for a single click, you can define an action in Translator 2, but add a rule to exit the translator if gc was not 1. I.e. the single click only occured if the click count is 1 when the timer expired.
And, of course you can also define a triple click this way... and so on...
Let us know how it works!
Thanks,
FLorian