Hi Thomas,
thanks for posting and for requesting! Indeed, variables for keystrokes is on our feature request database, but so are hundreds (or thousands?) of other useful features... Priorities get raised if requested more often, and in fact, this feature is not asked for much, so we took the liberty to first work on other features.
One reason is certainly that there is a work-around. As you say, creating 100 translators is not practical, but it's definitely possible. There's a lot of copy/paste (or better: Duplicate Ctrl+D), but it shouldn't take more than 15 minutes to create all 100 translators and then you're done.
However, 3 notes for that approach:
- MIDI controllers usually go from 0 to 127, while Photoshop (I believe) usually has values from 0 to 99.
- MIDI controllers can send at a very fast rate, while keystrokes are relatively slow. They would pile up and cause sluggish behavior for fast knob movements
- With MT Pro's scripting, it is no problem to separate a number into the individual digits and then send digit by digit. So instead of 100 translators, only 10 are needed (plus the coordination rules)
I found your problem quite interesting, so I renamed your topic, and created a test project for the fun of it.
For 1), use a Rule to scale from 0..127 to 0..99. The basic Math is (using pp as incoming controller variable):
For 2), we use a timer "Delayed Number" with 20ms delay. Only after 20ms, the actual keystrokes are executed. When a new MIDI controller message comes in during the 20ms, the new value is remembered, but the timer is restarted. That way, we throttle keystrokes to a rate of max. one per 20ms. The 20ms are somewhat arbitrary, but work fine.
For 3) we trigger the keystrokes in response to the "Delayed Number" timer. There, we have 3 translators:
Translator 0: calculate 10s digit, issue timer "send 10s digit"
Translator 1: calculate 1s digit, issue timer "send 1s digit"
Translator 2: issue timer "send ENTER" -- to terminate this value
In the example project, the main translator "Knob Movement" receives Controller #1 on MIDI Channel 1, scales this value to a value from 0..99, and stores this value in a global variable
g0. As outgoing action, this translator starts (or restarts) the timer "Delayed Number".
Then, the translator "Send 10s digit" is executed when the timer expires (after 30ms). The rules calculate the 10s digit by dividing g0 by 10 and remember that value in the global variable g1. If that value is 0, we don't need to output a key and bail out. Otherwise, a 0-ms timer is started to actually send that 10s digit. 0-ms timers are a special feature which cause all translators which react to that timer to be executed with very little overhead.
The translator "send 1s digit" is executed directly afterwards (also in response to the "Delayed Number" timer. It calculates the 1s digit by calculating the remainder of the division by 10, i.e. the MOD function, using the % operator in the Rules in the translator.
The last translator in that preset issues a 0-ms timer to send ENTER (aka Return), also in response to the
Delayed Number timer. We could generate the keystroke directly as an outgoing action here, but MT Pro only guarantees the correct order of outgoing actions if they're triggered in the same way. So to prevent that the ENTER is sent before, e.g., the 1s digit, we also queue it up using the 0ms timer.
For sending the actual digits, there are 2 presets with 10 translators each. For the 10s digits, the variable g1 is evaluated in the Rules and the corresponding digit is sent. For the 1s digits, the same, but for variable g2. It took me 2 minutes to create all these translators (using the duplicate function).
Of course, this is quite a lot to digest for a newbie... but it achieves a lot, and it should be easy to adapt to your needs. Whenever stuck, you know where to ask
![Smile :)](../../../images/smilies/icon_smile.gif)
The project is attached for direct download (see below), and here in text form:
Code: Select all
[x] Preset 0: Knob Input
Default MIDI IN ports: From Controller
[x] Translator 0.0: Knob Movement
Options: swallow
Incoming: Control Change on ch. 1 with CC#:1 (0x01) set 'pp' to value
Rules:
pp=pp*99
g0=pp/127
Outgoing: One-shot timer "Delayed Number": 20 ms delay
[x] Translator 0.1: Send 10s digit
Incoming: On timer "Delayed Number"
Rules:
g1=g0/10
if g1==0 then exit rules, skip Outgoing Action
Outgoing: One-shot timer "Send 10s Digit": 0 ms delay
[x] Translator 0.2: Send 1s digit
Incoming: On timer "Delayed Number"
Rules: g2=g0%10
Outgoing: One-shot timer "Send 1s Digit": 0 ms delay
[x] Translator 0.3: Send ENTER
Incoming: On timer "Delayed Number"
Rules:
Outgoing: One-shot timer "Send ENTER": 0 ms delay
[x] Preset 1: Send 10s digits (g1)
[x] Translator 1.0: Digit 0
Incoming: On timer "Send 10s Digit"
Rules: if g1!=0 then exit rules, skip Outgoing Action
Outgoing: Text: 0
[x] Translator 1.1: Digit 1
Incoming: On timer "Send 10s Digit"
Rules: if g1!=1 then exit rules, skip Outgoing Action
Outgoing: Text: 1
[x] Translator 1.2: Digit 2
Incoming: On timer "Send 10s Digit"
Rules: if g1!=2 then exit rules, skip Outgoing Action
Outgoing: Text: 2
[x] Translator 1.3: Digit 3
Incoming: On timer "Send 10s Digit"
Rules: if g1!=3 then exit rules, skip Outgoing Action
Outgoing: Text: 3
[x] Translator 1.4: Digit 4
Incoming: On timer "Send 10s Digit"
Rules: if g1!=4 then exit rules, skip Outgoing Action
Outgoing: Text: 4
[x] Translator 1.5: Digit 5
Incoming: On timer "Send 10s Digit"
Rules: if g1!=5 then exit rules, skip Outgoing Action
Outgoing: Text: 5
[x] Translator 1.6: Digit 6
Incoming: On timer "Send 10s Digit"
Rules: if g1!=6 then exit rules, skip Outgoing Action
Outgoing: Text: 6
[x] Translator 1.7: Digit 7
Incoming: On timer "Send 10s Digit"
Rules: if g1!=7 then exit rules, skip Outgoing Action
Outgoing: Text: 7
[x] Translator 1.8: Digit 8
Incoming: On timer "Send 10s Digit"
Rules: if g1!=8 then exit rules, skip Outgoing Action
Outgoing: Text: 8
[x] Translator 1.9: Digit 9
Incoming: On timer "Send 10s Digit"
Rules: if g1!=9 then exit rules, skip Outgoing Action
Outgoing: Text: 9
[x] Preset 2: Send 1s digits (g2)
[x] Translator 2.0: Digit 0
Incoming: On timer "Send 1s Digit"
Rules: if g2!=0 then exit rules, skip Outgoing Action
Outgoing: Text: 0
[x] Translator 2.1: Digit 1
Incoming: On timer "Send 1s Digit"
Rules: if g2!=1 then exit rules, skip Outgoing Action
Outgoing: Text: 1
[x] Translator 2.2: Digit 2
Incoming: On timer "Send 1s Digit"
Rules: if g2!=2 then exit rules, skip Outgoing Action
Outgoing: Text: 2
[x] Translator 2.3: Digit 3
Incoming: On timer "Send 1s Digit"
Rules: if g2!=3 then exit rules, skip Outgoing Action
Outgoing: Text: 3
[x] Translator 2.4: Digit 4
Incoming: On timer "Send 1s Digit"
Rules: if g2!=4 then exit rules, skip Outgoing Action
Outgoing: Text: 4
[x] Translator 2.5: Digit 5
Incoming: On timer "Send 1s Digit"
Rules: if g2!=5 then exit rules, skip Outgoing Action
Outgoing: Text: 5
[x] Translator 2.6: Digit 6
Incoming: On timer "Send 1s Digit"
Rules: if g2!=6 then exit rules, skip Outgoing Action
Outgoing: Text: 6
[x] Translator 2.7: Digit 7
Incoming: On timer "Send 1s Digit"
Rules: if g2!=7 then exit rules, skip Outgoing Action
Outgoing: Text: 7
[x] Translator 2.8: Digit 8
Incoming: On timer "Send 1s Digit"
Rules: if g2!=8 then exit rules, skip Outgoing Action
Outgoing: Text: 8
[x] Translator 2.9: Digit 9
Incoming: On timer "Send 1s Digit"
Rules: if g2!=9 then exit rules, skip Outgoing Action
Outgoing: Text: 9
[x] Preset 3: Send Other keys
[x] Translator 3.0: Send ENTER
Incoming: On timer "Send ENTER"
Outgoing: Text: Return