Checking multiple global variables

KenC

2012-07-03 11:26:46

I'm trying to come up with a preset so that I can press 3 keys on my MIDI keyboard that will then activate a typing keyboard mode, so those 3 keys held down acts as a switch that turns on my typing mode.

This is so I can still use my MIDI keyboard to play these keys separately, but when they are all held down they act as a switch.

I've set up 3 triggers for C0,C#0 and D0 (octave 0), each one sets one of global variables ga,gb and gc to 1 when that key is held down.

Now I'm stuck at how to check if these 3 are all 1 in another trigger rules, and only then execute the outgoing action to finally send the key when another key on my MIDI keyboard is pressed.

I've tried lots of things in the rules section, but I keep getting errors.

What I'd need is something like:

I press the C1 key, the rules then check:

If (ga==1 AND gb==1 and gc== 1) then exit rules, execute Outgoing Action

Has anyone tried doing something like this and perhaps know how to do this?

DvlsAdvct

2012-07-03 17:37:11

Hi KenC

What you want to do is definitely doable, you just need to implement timers into your setup.

The problem you are going to run into is that you want those keys to send regular MIDI when the three are not being pressed at the same time. You could either: have them send MIDI as normal UNTIL all three are pressed, or have them lock out their MIDI messages once more than one key is pressed, but that prevents you from selecting all three MIDI messages at once if you wanted.

The basic idea requires using delays and timers. So it would look something like this

Code: Select all

Translator 1: c0
Incoming Message: 90 0C pp
Rules: if pp>0 then ga=1
if pp=0 then ga=0
if g1!=0 then exit rules, skip outgoing action
Outgoing Action: 90 0C pp 4ms delay

[code]Translator 2: d0
Incoming Message: 90 0D pp
Rules: if pp>0 then gb=1
if pp=0 then gb=0
if g1!=0 then exit rules, skip outgoing action
Outgoing Action: 90 0C pp 4ms delay


[code]Translator 3: d0
Incoming Message: 90 0E pp
Rules: if pp>0 then gc=1
if pp=0 then gc=0
if g1!=0 then exit rules, skip outgoing action
Outgoing Action: 90 0C pp 4ms delay

Translator 4: Timer
Incoming Message: 90 xx pp
Rules: if pp==0 then exit rules, skip outgoing action
if xx>14 then exit rules, skip outgoing action
if xx<12 then exit rules, skip outgoing action
if ga!=1 then exit rules, skip outgoing action
if gb!=1 then exit rules, skip outgoing action
if gc!=1 then exit rules, skip outgoing action
Outgoing Action: Timer: Key Control On 0ms delay

Translator 5: Timer Off
Incoming Message: 90 xx 00
if xx>14 then exit rules, skip outgoing action
if xx<12 then exit rules, skip outgoing action
Outgoing Action: Timer: Key Control Off 0ms delay

Translator 6: Activate Key
Incoming Message: Key Control On
Rules: g1=1

Translator 7: Deactivate Key Control
Incoming Message: Key Control Off
Rules: g1=0
Then what you'd do is have your key command translators put together with the rule being

Code: Select all

 if g1!=1 then exit rules, skip outgoing action
The other option is to set up presets for this, which is cleaner. But if you get this working it should give you an idea of how to do that.

Thoughts?
J

KenC

2012-07-04 10:07:32

I'll try and implement your solution, still new to coding for MT so it's a learning experience :?

I didn't even know about switching presets yet, but now that I've played around with them that's going to be much less messy.

You've sparked another idea now that I know about being able to switch to another preset.

I could simply hit the transpose down button on my keyboard and then pick an activation key from that range of keys that switched to my "typing/shortcut" mode, those keys would be so low that I'd never use them when playing, so I wouldn't need anything than simply switching to another preset.

Thanks for your help, appreciate it :D