Keystroke combinations to MIDI

florian

2009-11-13 22:46:03

A user wants to convert keystroke combinations to MIDI,
e.g.
Ctrl+A -> Note On, Channel 1, key 64

florian

2009-11-13 22:58:02

A simple solution, but not fully optimized, yet easy to understand, is the following:

The trick is that you need to manually "remember" if currently SHIFT, CTRL and/or ALT is pressed. The usual way is to use a global variable for that. Global variables are 2-letter combinations that start with g, h, ...n and have letter or number as second letter. In the following example, I use gs for remembering SHIFT state, gc for remembering CTRL and ga for remembering ALT.

Create these six translators in a separate Preset "Modifier Keys":

Code: Select all

Translator 1: Shift down: gs=1
Incoming: Key down: Shift
Rules: 
  gs=1
Outgoing: (none)

Translator 2: Shift up: gs=0
Incoming: Key up: Shift
Rules: 
  gs=0
Outgoing: (none)

Translator 3: Ctrl down: gc=1
Incoming: Key down: Ctrl
Rules: 
  gc=1
Outgoing: (none)

Translator 4: Ctrl up: gc=0
Incoming: Key up: Ctrl
Rules: 
  gc=0
Outgoing: (none)

Translator 5: Alt down: ga=1
Incoming: Key down: Alt
Rules: 
  ga=1
Outgoing: (none)

Translator 6: Alt up: ga=0
Incoming: Key up: Alt
Rules: 
  ga=0
Outgoing: (none)
When you check out the log window, it should show the activity when pressing SHIFT, CTRL and ALT (when MT PRO is not focused).

Now create a second preset where you create individual translators for the Key-to-MIDI mappings. Here are a few examples:

Code: Select all

Translator 1: Ctrl+A down -> Note On, Channel 1, key 64, velocity 127
Options: stop=false
Incoming: Key down: A
Rules: 
  if gs==1 then exit rules, skip Outgoing Action
  if gc==0 then exit rules, skip Outgoing Action
  if gs==1 then exit rules, skip Outgoing Action
Outgoing: MIDI 90 40 7F 

Translator 2: Ctrl+A up -> Note Off, Channel 1, key 64
Options: stop=false
Incoming: Key up: A
Rules: 
  if gs==1 then exit rules, skip Outgoing Action
  if gc==0 then exit rules, skip Outgoing Action
  if gs==1 then exit rules, skip Outgoing Action
Outgoing: MIDI 90 40 00 

Translator 3: Shift+W down -> Note On + Note Off key 60
Options: stop=false
Incoming: Key down: W
Rules: 
  if gs==0 then exit rules, skip Outgoing Action
  if gc==1 then exit rules, skip Outgoing Action
  if gs==1 then exit rules, skip Outgoing Action
Outgoing: MIDI 90 3C 7F 90 3C 00 

Translator 4: Shift+Alt+B down -> CC#1 value 5
Options: stop=false
Incoming: Key down: B
Rules: 
  if gs==0 then exit rules, skip Outgoing Action
  if gc==1 then exit rules, skip Outgoing Action
  if gs==0 then exit rules, skip Outgoing Action
Outgoing: MIDI C0 01 05 
I think the principle gets obvious. Please join the discussion!
Florian

Dilla4Ever

2010-04-05 06:12:00

Hey Florian,

I'm just getting the hang of understanding MIDI data and using your translator to compile. I was wondering if you could give a basic example of what the rules would look like if you were simply outputting MIDI data from one 25 keyboard and importing it into another?

RobG

2010-06-05 16:42:17

Florian,

THANK YOU!

This is one of the most useful functions I've learned about MT and deserves to be a sticky!
You've not only saved me a whole heap of cursing at the application this afternoon, you've
also helped me get Serato hot cues and looping running off my laptop keyboard whilst having
USB MIDI controllers attached.

Nice one! :D

RobG