Hold Key conflict

  • Forum
  • [RESOLVED] Hold Key conflict
0
0

Hi All.

 

I am using a script(at the bottom ) to be able to single tap a controller for an action , double tap it for a differnet action , and hold it for a 3rd action

 

the same script is duplicated for several controllers i am using

 

i have found a problem . when i hold a key , lets say key A , which should trigger action 1  , and simultaneously  single tap  another key that is configured with the same script but with different triggers /action , the hold action on the second key is triggered

so i have button A, that does the foollowing

single tap     =  action 1

double tap  = action 2

hold  = action 3

 

and i have button b , that does

single tap = action 4

double tap = action 5

hold = action 6

 

if i hold button A  and simultaneously single tap button B  , i end up with action 3 ,action 4  and action 6 triggered

 

so the hold action for the key i single tapped gets triggered for some reason

 

if any of this makes sense to you , is there a way to avoid this from happening

 

 

[x] Translator 0: Button Press (Hold Detection)
Incoming: MIDI 90 00 7F
Rules:
  ga=1
  gb=1
Outgoing: One-shot timer "Hold Detection": 2000 ms delay

[x] Translator 1: Button Press (Double Tap Detection)
Incoming: MIDI 90 00 7F
Rules:
  gc=gc+1
  if gc>=2 then gc=2
Outgoing: One-shot timer "Double Tap Detection": 300 ms delay

[x] Translator 2: Button Release
Incoming: MIDI 90 00 00
Rules: ga=0
Outgoing: (none)

[x] Translator 3: Single Tap Output
Incoming: On timer "Double Tap Detection"
Rules:
  if ga==1 then exit rules, skip Outgoing Action
  if gc!=1 then exit rules, skip Outgoing Action
Outgoing: MIDI 90 00 7F

[x] Translator 4: 2 Second Hold Output
Incoming: On timer "Hold Detection"
Rules:
  gb=0
  if ga!=1 then exit rules, skip Outgoing Action
Outgoing: MIDI 90 01 7F

[x] Translator 5: Double Tap Output
Incoming: On timer "Double Tap Detection"
Rules:
  if gc==2 then skip next 2 rules
  gc=0
  exit rules, skip Outgoing Action
  gc=0
  exit rules, execute Outgoing Action
Outgoing: MIDI 90 02 7F

 

RESOLVED
Marked as spam
Posted by (Forum: 1, Answers: 1)
September 15, 2020 1:55 am
33 views
0
Private answer

Hi,

I've had a lot of experience and headaches with gestures so instead of troubleshooting your logic,  let me offer up my example.  In my example I use global variable and counts to manage gestures.  In the below example the note numbers are controlled by the variables g0, g1 and g2 in Set Globals translator under Init.

We basically count button presses on a given incoming note (or CC) and then call a timer "Gesture Manager". There are several rules for each button and each one outputs a different MIDI message.

To add notes, you would need to

1) Add g3 (for the forth note)

2) Copy a the last section of translators and in the rules, change g2 to g3. Then set the desired outgoing actions.

 

Right now we are looking for any channel but if you want to target only a given channel there is a rule in each translator you can uncomment and change.  Basically only one of the "Gesture Dispatcher" rule will fire based on the note, and tap count.

 

If you want to modify my file with your outgoing actions, just take the checked gesture and replace the current outgoing action with your own.  All global variables used in the project are documented in the "Set Globals" translator.

 

Steve Caldwell
Bome Customer Care


Also available for paid consulting services: bome@sniz.biz

 

Marked as spam
Posted by (Forum: 50, Answers: 5298)
September 15, 2020 3:40 am
0
Private answer

If you are using this as duplicate for many buttons, you will need to use different global variables for each button. So for the first button you would use ga gb and gc as shown.

For the second button you would need something like gd, ge and gf in their place as these variables are global and the updates from the second button would interfere with the first button.

It looks like it should work correctly for 1 button though, right?

Although my solution looks a lot more complicated, it is way more flexible and allows for as many buttons as you want with only a single global variable added for each.

Steve Caldwell
Bome Customer Care


Also available for paid consulting services: bome@sniz.biz

 

P.S. In the design you showed, you would also need different timer names for each button.

 

Marked as spam
Posted by (Forum: 50, Answers: 5298)
September 15, 2020 8:45 am
Thanks a lot Steve, I was indeed not aware how to set up global variables properly, to be honest i just snatched the script from another post and tweaked it to the best of my abilities (which are very limited). changing the global variables for one button in the current the script i am using solves my problems, for now, because in my current project, there is only one button that i need to press simultaneously while holding another button, , and so separating it from the rest with a different set of variables removes the overlap. However, I take your point I do now understand that it is not the most practical script, as. I have over 100 translators running (5 per button), and so if i want to further sperate the buttons for any other project, I will eventually run out of variables if i keep doing this :) I think the next step for me is to have a deeper look at your translator and try to better understand it, to be prepared when I need it. But for now, I am all sorted, so again thanks a lot for the help!
( at September 16, 2020 12:25 am)
Glad I could help!
( at September 16, 2020 1:41 am)