using fader for increase-decrease keystrokes

stoecklem

2006-11-30 07:32:21

Hello

I was wondering if I could get a push in the right direction if this is possible with the current version of MIDI translator.

I would like to set it up so that my fader is controlling parameter sliders in a 3-D program.

there are two keyboard shortcuts for increase and decrease the parameter.

Is it possible to somehow link this to a slider..... so that when I push the MIDI fader up it triggers one keystroke and when I move it down it triggers another keystoke.

It would need to lift the key off and then re press it at each fader decrease. Keying down does not work in the program

thanks

(also you can middle click and drag right or left to increase and decrease paramters) so when mouse events are added it will work a lot smoother using that if possible)

florian

2006-11-30 09:46:57

Hi, this is possible with MT Pro: use a global variable gv to remember the last position of the fader. When you move the fader, you'll know the direction by taking the difference of the new value and the old value (difference stored in gd). Then, depending on direction, you can send the one keystroke, or the other keystroke.

Here is a way to do it. I assume the following:
MIDI fader: CC 01, moves from 0 to 127 (hex 00 to 7F)

Code: Select all

Translator 1: calculate difference in gd, remember last value
GENERAL: Stop Processing: unchecked
INCOMING: MIDI B0 01 pp
RULES:
  gd = pp - gv
  gv = pp
OUTGOING: <none>

Translator 2: Send key up if gd > 0
GENERAL: Stop Processing: unchecked
INCOMING: MIDI B0 01 pp
RULES:
  IF gd <= 0 THEN exit rules, skip outgoing action
OUTGOING: Keystroke <Key Up>

Translator 3: Send key down if gd < 0
INCOMING: MIDI B0 01 pp
RULES:
  IF gd >= 0 THEN exit rules, skip outgoing action
OUTGOING: Keystroke <Key Down>
Note that I use the opposite IF condition to exit the translator. You could also use the direct condition, but then you'd need an explicit exit (default is to execute the translator), e.g. for Translator 3:

Code: Select all

Translator 3: Send key down if gd < 0 (intuitive IF statement)
INCOMING: MIDI B0 01 pp
RULES:
  IF gd < 0 THEN exit rules, execute outgoing action
  exit rules, skip outgoing action
OUTGOING: Keystroke <Key Down>
Let us know how it works!
Florian

PS: mouse output is available as a preview for registered users of MT pro - just request it at http://www.bome.com/contact.php .

stoecklem

2006-11-30 21:54:42

thanks

doing this helped me become more familiar with rules. (the second and third incoming messages have to use gv as the variable though)


it works really well when moving the fader slowly. when moving at fast speeds it jumps around and is hard to judge ,which is a fault more on XSI's end. another drawback is that because it is using a different amount of keypresses every time I move the fader there is no set range for the fader.

If the mouse movements are going to be powerful enough then it would be much smoother as I mentioned. ( If I can tie a middle click drag right to increase fader and middle click mouse drag left to decrease fader)

Also if it ever allows an event that can use and store the mouse position on screen(Ithink I read that on here somewhere) that could really be amazing.

I love MT for musical applications , but I also like using it to get my MIDI controllers to control other software. Its really one of my favorite things and I am glad to see that its future is bright. (I will be ordering very soon.)

admin

2006-12-01 08:39:34

Hi,

thanks for the nice words! Indeed, this translator set will cause irregular keystrokes if the fader skips values (very common though). One solution would be a "repeat outgoing action gd times" (a feature already requested).

Retrieving the current mouse position could be done by way of special variables, e.g. mx and my or so. This would be a leaner way than using mouse movement as Incoming Action.

One question: was there a problem when keeping "pp" in Translator 2 and 3? I can see why it will work the same if replacing pp with gv (gv should already have that same value, because of the Rule in Translator 1 "gv = pp"), but I don't see why it would be necessary? Maybe a bug in MT?

Regards,
Florian

stoecklem

2006-12-01 22:01:27

oops your right. It works just find with pp in parameter 2 and 3. Just been experiementing and probably wasn't working because of something else I did. thanks

stoecklem

2006-12-01 23:52:59

I am having trouble with the same matter. bringing another keystroke into the equation.

In order for the increase decrease keystrokes to work the tool needs to be activated by pressing the F4 button.

How would I have any move of the fader, trigger the F4 button(just one key press and release) and then leave it alone allowing the movement of the fader to trigger the increase decrease keystrokes.

and then ideally trigger F4 again when I am done moving the fader.

I thought this would be simple at first but I'm not having any luck

thanks for your help

florian

2006-12-02 15:17:12

Hi,

this is indeed tricky, mostly because there is no dedicated event when you stop moving the fader. One way is to use the timer feature: when ever you move the slider, start a timer with, say, 500milliseconds expiration time. If you continue moving the slider, the timer keeps on getting restarted with 500millis. Only if you don't move the fader during those 500millis will the timer expire and fire the timer incoming action. In that action, the second F4 keystroke is triggered. We use a variable gm to keep track if you're moving the fader (gm=1) or not (gm=0).

Here is how to do it:

Code: Select all

In translator 3 above, uncheck the "stop processing" flag.

Translator 4: Send F4 if you start fading
GENERAL: Stop Processing: unchecked
INCOMING: MIDI B0 01 pp
RULES:
  IF gm > 0 THEN exit rules, skip outgoing action
OUTGOING: Keystroke F4

Translator 5: Start Timer upon start fading, set gm to 1
INCOMING: MIDI B0 01 pp
RULES:
  IF gm > 0 THEN exit rules, skip outgoing action
  gm = 1
OUTGOING: Start one-shot timer "Stop Fading", delay=500millis

Translator 5: Send F4 if you stop fading, reset gm
INCOMING: Timer "Stop Fading"
RULES:
  IF gm = 0 THEN exit rules, skip outgoing action
  gm = 0
OUTGOING: Keystroke F4
How does that work? You may need to increase the 500 milliseconds if it's reacting too fast.

Florian

stoecklem

2006-12-08 06:15:25

Thanks. that works well

RichardT

2006-12-14 23:17:01

Hi Florian and Midi Translator Pro users

I've followed these steps and got it working OK. But I found that it wasn't quite right for what I needed - which was to use a rotary encoder on my Novation keyboard to select a track in Live when in the session view.

By default, every single message that got sent by the encoder moved the focus to the right or left, which meant that when I moved the encoder only a small amount the selected track moved from being the left hand most one to the right hand most one (or vice versa, depending on which way I turned the knob).

The only way around this I could find was to put an extra translator in for the message that allowed through only messages that had values 5,10,15....125. This worked ok but when I turned the knob very fast it didn't (as Florian pointed out) send all the values but only every third or fourth value. So I changed the filter to allow any value through provided is was 4 or more different from the previous one.

It's still not quite right, but it's not too bad.

I thought I'd share this as it might interest people and there also might be a better way that you can think of, Florian.

Here's what the filter step looks like schematically (any way you can add ctrl-c functionality from the rules window Florian?)

if gd >= 4 jump to valid
if gd <= -4 jump to valid
if midi value = 5 jump to valid
if midi value = 10 jump to valid
...
if midi value = 125 jump to valid
ge = 0
valid:
ge = 1

Then in each of the rules that execute the keystroke I put in an extra check that ge = 1 before sending the keystroke

This is a great product! The only risk is that I spend all my time programming it and no time making music!


:D

florian

2006-12-15 11:29:14

Hi Rich,

this is pretty much how I'd do it. Oh, except: you will need a "exit rules" rule after "ge=0" so that it won't continue to the next rule! Maybe you just forgot to list here? The Ctrl-C of the Translators is coming.

Though, I'm not sure what you need the single "IF midi value=5 THEN jump to valid" rules for. As you pointed out, this bears the risk that the knob will skip exactly that value, making it somewhat less predictable. And, btw, the following rules are an easier way to check if pp is a multiple of 5:

tt = pp / 5
tt = tt * 5
IF tt = pp THEN jump to valid

Regards,
Florian

RichardT

2006-12-15 11:43:47

Thanks for that Florian. What you suggested will really simplify what I have - I was hoping you'd come up with something like that as it's clumsy at the moment.

The reason I put the multiple of 5 check in is that if I move the knob slowly (or even reasonably fast) it doesn't skip midi values, and so I was finding that a small turn of the knob had a very big effect, so I wanted to reduce the effect. But maybe I'm missing something here ? Are you thinking I can just get away with just checking a change in gd?

Rich

florian

2006-12-15 14:31:40

RichardT wrote:Are you thinking I can just get away with just checking a change in gd?Rich
It should suffice: each time you turn by more than 4 (or whatever number you put in), it will be valid. You can increase the amount you need to turn by using a larger number than 4.

For checking this out without loosing your current rules, you can just duplicate the entire Translator in the main window (i.e. copy/paste), deactive the original (uncheck in the main window) and edit the duplicate.

Regards,
Florian

RichardT

2006-12-20 23:46:13

florian wrote:
RichardT wrote:Are you thinking I can just get away with just checking a change in gd?Rich
It should suffice: each time you turn by more than 4 (or whatever number you put in), it will be valid. You can increase the amount you need to turn by using a larger number than 4.
Hi Florian, I've made some changes to my script along the lines you suggest. It's working but there is a strange feature which may or may not be a bug, I'm not sure.

The script now has four translators and looks like this

Code: Select all

[Project]
Version=1
[Preset.0]
Name=Novation SL 1
Active=1
Name0=Track Select: Identify wanted messages
Incoming0=MID1B008pp
Outgoing0=None
Options0=Actv01Stop00OutO00StMa00000005gv=0if(gl==0)gl=ppgd=pp-glif(gd>=12)gv=1if(gd<=-12)gv=1
Name1=Track Select: Send keystroke right if turned to the right
Incoming1=MID1B008pp
Outgoing1=KAM10100KSQ1000E012126326212012126326212012126326212127327
Options1=Actv01Stop00OutO00StMa00000002if(gd<=0)noexecuteif(gv==0)noexecute
Name2=Track Select: Send keystroke left if turned to the left
Incoming2=MID1B008pp
Outgoing2=KAM10100KSQ1000E012126326212012126326212012126326212125325
Options2=Actv01Stop00OutO00StMa00000002if(gd>=0)noexecuteif(gv==0)noexecute
Name3=Track Select: Store Last Value
Incoming3=MID1B008pp
Outgoing3=None
Options3=Actv01Stop01OutO00StMa00000001if(gv==1)gl=pp
Basically, this script works as follows

- the first translator sets the variable gv to 1 if the control midi value has moved 12 or more in either direction, otherwise to 0. In addition it initialises the last value to the current value if required.

- the second picks up positive moves when gv = 1. It then issues a series of keystrokes to move focus to the session list in Live and move one track to the right
- the third picks up negative moves when gv = 1 and does the same as above, but going left
- the fourth sets the last value to current value if gv = 1.

The problem I'm having is that when I start with the control at 0, and turn it right, the first time it sets gv = 1 it doesn't execute the second translator. By which I mean the log shows the incoming event of the translator but there is nothing else shown for it. At least, that's what I think is happening. The next time it sets gv = 1, it does execute the second step.

This might be a programming error of course (quite likely!), but it doesn't look right to me and I'm stuck. If you have time to look at this, please let me know what you think.

This doesn't stop the script doing the job it's supposed to, but it does mean that the control feels sluggish when at the left hand end of the dial.

Here's an extract from the log for all the processing when the difference value first reaches 12. The line that puzzles me is in bold
  • IN : MIDI B0 08 15, pp=0x15
    assignment: (gv=0) = 0
    assignment: (gd=pp-gl) = 12
    condition satisfied: if gd>=12 then gv=1
    assignment: (if gd>=12 then gv=1) = 1
    IN : MIDI B0 08 15, pp=0x15
    IN : MIDI B0 08 15, pp=0x15
    condition satisfied: if gd>=0 then exit rules, skip Outgoing Action
    IN : MIDI B0 08 15, pp=0x15
    condition satisfied: if gv==1 then gl=pp
    assignment: (if gv==1 then gl=pp) = 21
I've got some suggestions that would really help debug...
  • - a facility to put comments either as rule steps or as notes against each rule step
    - could the log show the translator name and step number?
    - could you add a facility to translate the script into meaningful English, in the way that you do when you include a script in a post
I've also noticed that when I start the program minimized, it doesn't pass messages on. Is that supposed to happen?

thanks very much.

Rich

florian

2007-01-02 16:44:06

RichardT wrote:Here's an extract from the log for all the processing when the difference value first reaches 12. The line that puzzles me is in bold
  • IN : MIDI B0 08 15, pp=0x15
    assignment: (gv=0) = 0
    assignment: (gd=pp-gl) = 12
    condition satisfied: if gd>=12 then gv=1
    assignment: (if gd>=12 then gv=1) = 1
    IN : MIDI B0 08 15, pp=0x15
    IN : MIDI B0 08 15, pp=0x15
    condition satisfied: if gd>=0 then exit rules, skip Outgoing Action
    IN : MIDI B0 08 15, pp=0x15
    condition satisfied: if gv==1 then gl=pp
    assignment: (if gv==1 then gl=pp) = 21
The single MIDI IN line means that the conditions are not satisfied and the outgoing action is triggered. MIDI IN and Keystrokes are processed in separate threads, therefore it is likely that the outgoing keystroke is sent after all translators for that MIDI IN event are processed. But it should follow immediately in the log after the processing above.
RichardT wrote:I've got some suggestions that would really help debug...
  • a facility to put comments either as rule steps or as notes against each rule step
  • could the log show the translator name and step number?
  • could you add a facility to translate the script into meaningful English, in the way that you do when you include a script in a post
These are good suggestions. The last one is already implemented for the next version of MT.
RichardT wrote:I've also noticed that when I start the program minimized, it doesn't pass messages on. Is that supposed to happen?
No, what do you mean with "does not pass messages on"? you mean, the keystrokes are not executed? This may be a bug in the option "suppress outgoing keystroke when active". I'll fix this.

Thanks and a good start into 2007!
Florian