Page 1 of 1

Absolute > Relative CCs?

Posted: Wed Oct 12, 2011 4:20 pm
by muckleby
I have an NI Kore 2 controller, with endless encoders that transmit absolute CCs.
And what I'd like to do is use MT to trigger a Left keypress every time an encoder is turned to the left and trigger a Right keypress every time the encoder is turned to the right.
So essentially the encoder will be acting as though it was in relative mode and triggering keypresses.
Is this possible?

Re: Absolute > Relative CCs?

Posted: Sat Oct 22, 2011 4:22 pm
by florian
yes, that is no problem. By comparing the last value, you can derive if it was turned left or right:

Code: Select all

Translator 0: turn left
Options: stop=false
Incoming: MIDI B0 0E pp 
Rules: 
  gd=pp-ga
  ga=pp
  if gd>=0 then exit rules, skip Outgoing Action
Outgoing: Keystroke: 0 

Translator 1: turn right
Options: stop=false
Incoming: MIDI B0 0E pp 
Rules: 
  if gd<=0 then exit rules, skip Outgoing Action
Outgoing: Keystroke: 1 
Upon turning the knob (here: controller 0E hex), the variable pp receives the current controller value. In ga, I store the last value of the controller. By taking the difference (and set gd to it), I know that: if gd < 0, I turned left (counter clockwise), and if gd > 0, I turned right. I also update ga with the current value.

Now whenever you turn right, gd will be positive. The IF statement in "Translator 0" will evaluate to TRUE, and therefore that translator's outgoing action is not executed. However, the second Translator's IF statement is false, and so that outgoing action is executed: keystroke 1. It works the other way round for turning left.

Thanks,
Florian

PS: one problem with this approach is that turning fast will likely skip controller values and therefore you'll miss keystrokes. This can be solved with MT, too. The example project for Frontier Design's Tranzport (shipping with MT) shows such an approach with timers in the Winamp preset.

Re: Absolute > Relative CCs?

Posted: Fri Nov 11, 2011 1:03 am
by muckleby
niceone florian, thanks for such a helpful reply.

nice little bit of code that :)

the skipping values is not so bad, a bigger issue is the fact that once the min/max CC is reached, the rule no longer works and the the action isn't triggered. i can't think of a way around it either.

so the result isn't quite an endless encoder, but might be close enough for my use anyway.

so thanks again, i'll have a play with the demo some more and see how it works out....

Re: Absolute > Relative CCs?

Posted: Thu Nov 17, 2011 12:13 pm
by florian
when you're at max CC value and keep on turning, does it still send repeated MIDI messages with the max value? Then we can tweak the translators to keep on sending keystrokes.
Florian

Re: Absolute > Relative CCs?

Posted: Thu Dec 01, 2011 2:54 am
by Big_T
florian wrote:when you're at max CC value and keep on turning, does it still send repeated MIDI messages with the max value? Then we can tweak the translators to keep on sending keystrokes.
Florian
Thank you for the useful code!

This is the case for me (still keeps sending the max or min values: MIDI B0 11 00, oo=0x00 or MIDI B0 11 7F, oo=0x7F ). I have continuous rotary knobs but the keystrokes stop once maxed or mined out.

You mentioned tweaking the translators to keep on sending keystrokes. Can you elaborate on how to do that? How can we keep the good times rolling?

Many thanks!

T

Re: Absolute > Relative CCs?

Posted: Thu Dec 01, 2011 1:51 pm
by florian
i guess it's as simple as adding one more IF statement:

Code: Select all

   Translator 0: turn left
   Options: stop=false
   Incoming: MIDI B0 0E pp
    Rules:
      gd=pp-ga
      ga=pp
      if pp==0 then exit rules, execute Outgoing Action
      if gd>=0 then exit rules, skip Outgoing Action
    Outgoing: Keystroke: 0

    Translator 1: turn right
    Options: stop=false
    Incoming: MIDI B0 0E pp
    Rules:
      if pp==127 then exit rules, execute Outgoing Action
      if gd<=0 then exit rules, skip Outgoing Action
    Outgoing: Keystroke: 1
[updated Dec.6, 2011]

Re: Absolute > Relative CCs?

Posted: Sun Dec 04, 2011 9:33 pm
by Big_T
Hi Florian,

Thanks for your help. I tried the new line but nothing different happened? I can still only output 127 1's or 0's in a given sweep. It stalls at the max or min cc message but in the monitor it is still trying to send out.

I'm not very good a coding but form your additional code : "if pp=0 then exit rules, execute Outgoing Action" I think I see what you mean where you are saying to keep going but in practice it doesn't seem to work?

From the log:

on the left side it says pp=0x00
on the right side it says pp=0x7f



T

Re: Absolute > Relative CCs?

Posted: Sun Dec 04, 2011 10:59 pm
by florian
hmm, don't know what's hapening. Can you post your full translator here (use copy in Midi Translator, and paste here in the forum)? Also copy/paste some lines from the log.
Thanks,
Florian

Re: Absolute > Relative CCs?

Posted: Mon Dec 05, 2011 4:52 am
by Big_T
Hmm I can't seem to copy and paste the code? I used copy form MT and past in here.



I see an error code: Error: executing Preset|Copy: (ExceptionInInitializerError)

When I copy the translators it copied and pastes like this:

translator 0:

[Ljava.lang.String;@fc9e7e


translator 1:

[Ljava.lang.String;@15fc606


I'm using a mac.


I did manage to save it as a text file though:

--------------- Preset try keystroke


[x] Translator 0: New Translator
Incoming: CC ch.1: Data Entry -1 (#97), pp
Rules:
gd=pp-ga
ga=pp
if gd>=0 then exit rules, skip Outgoing Action
Outgoing: Keystroke: 0

[x] Translator 1: New Translator
Incoming: CC ch.1: Data Entry -1 (#97), pp, on ports BCR2000 : Port 1 (BEHRINGER), BCR2000 : Port 2 (BEHRINGER)
Rules:
if gd<=0 then exit rules, skip Outgoing Action
pp=0
pp=0
Outgoing: Keystroke: 1





Here is some log window lines:

4081: IN 4.1 MIDI B0 61 7C, pp=0x7C
4082: OUT 4.1 1 : keystroke suppressed (main window active)
4083: IN 4.0 MIDI B0 61 7D, pp=0x7D
4084: IN 4.1 MIDI B0 61 7D, pp=0x7D
4085: OUT 4.1 1 : keystroke suppressed (main window active)
4086: IN 4.0 MIDI B0 61 7E, pp=0x7E
4087: IN 4.1 MIDI B0 61 7E, pp=0x7E
4088: OUT 4.1 1 : keystroke suppressed (main window active)
4089: IN 4.0 MIDI B0 61 7F, pp=0x7F
4090: IN 4.1 MIDI B0 61 7F, pp=0x7F
4091: OUT 4.1 1 : keystroke suppressed (main window active)
4092: IN 4.0 MIDI B0 61 7F, pp=0x7F
4093: IN 4.1 MIDI B0 61 7F, pp=0x7F
4094: IN 4.0 MIDI B0 61 7F, pp=0x7F
4095: IN 4.1 MIDI B0 61 7F, pp=0x7F
4096: IN 4.0 MIDI B0 61 7F, pp=0x7F
4097: IN 4.1 MIDI B0 61 7F, pp=0x7F
4098: IN 4.0 MIDI B0 61 7F, pp=0x7F
4099: IN 4.1 MIDI B0 61 7F, pp=0x7F
4100: IN 4.0 MIDI B0 61 7F, pp=0x7F
4101: IN 4.1 MIDI B0 61 7F, pp=0x7F
4102: IN 4.0 MIDI B0 61 7F, pp=0x7F
4103: IN 4.1 MIDI B0 61 7F, pp=0x7F
4104: IN 4.0 MIDI B0 61 7E, pp=0x7E
4105: IN 4.1 MIDI B0 61 7E, pp=0x7E
4106: OUT 4.0 0 : keystroke suppressed (main window active)

Re: Absolute > Relative CCs?

Posted: Mon Dec 05, 2011 9:00 am
by florian
Hi,

thanks, the copy/paste thing is a bug! will be fixed in the next version.

In your preset, I don't see the additional "IF" lines in the rules!

Regards,
Florian

Re: Absolute > Relative CCs?

Posted: Mon Dec 05, 2011 11:36 pm
by jaynyc
i am trying this also... i add that 2nd rule (the new one), but ultimately it seems that only 1 rule stays.
if pp=127... it says "Erronous rule: condition expected"

so i have translator 0 with 4 rules, and translator 1 with 1 rule.

Re: Absolute > Relative CCs?

Posted: Tue Dec 06, 2011 2:51 am
by Big_T
Hi Florian,

It seems I'm in the same situation as Jay above. When I add the code to the rules the second "if" statement does not seem to stick.
I have tried adding it as a whole copy and paste from your code, and also adding it after by hand. After I click away then back on the translator the code I just added seems to have disappeared and I get: pp=0 in it's place

I get the following statement in the rules section:


Translator (0)

gd=pp-ga
ga=pp
if gd>=0 then exit rules, skip Outgoing Action
pp=0


Translator (1)

if gd<=0 then exit rules, skip Outgoing Action
pp=0


Also when I add the additional "if" statement it says "line 4 parse error: condition expected" in red



T

Re: Absolute > Relative CCs?

Posted: Tue Dec 06, 2011 11:27 am
by florian
sorry guys, I should've tried it myself! I used a single = for comparison, but it should be a double == for comparison:

Code: Select all

if pp==0 then exit rules, execute Outgoing Action
I've fixed it in the preset above, you should now be able to copy paste the rules.

Best,
Florian

Re: Absolute > Relative CCs?

Posted: Wed Dec 07, 2011 8:54 am
by Big_T
Thanks Florian! It works perfectly now :)

I would have never figured that out by myself.


T

Re: Absolute > Relative CCs?

Posted: Thu Dec 22, 2011 6:21 pm
by muckleby
Glad this helped someone!
My controller stops sending at max value :(
However it does have a strange Mackie emulation mode where left turns send values from 41 to 4F and right turns send 01 to 0F.
Could I use a rule to send keystroked based on these value ranges?

Re: Absolute > Relative CCs?

Posted: Mon Jan 30, 2012 5:42 am
by florian
Hi muckleby,

I've created an own topic for this:
http://www.bome.com/forums/viewtopic.php?f=3&t=3755

Regards,
Florian

Re: Absolute > Relative CCs?

Posted: Sun Mar 13, 2016 10:07 pm
by NiDBiLD
I know this is an old topic. But I just figured out a way to do this with only one translator and no global variables:

Code: Select all

[x] Translator 2.12: Knob 1 to relative
Options: swallow
Incoming: Control Change on channel 2 with CC#:30 (0x1E) set 'pp' to value
Rules:
  if pp>=65 then Goto "Right"
  if pp<=63 then Goto "Left"
  
  Label "Left"
  oo=29
  Goto "Exit"
  
  
  Label "Right"
  oo=30
  Goto "Exit"
  
  Label "Exit"
  pp=64
Outgoing: MIDI B2 oo 7f B1 1E pp
oo is the cc number (or note) you want the output when turning left or right. pp is the knob value. Only drawback is you have to send the knob message as outgoing as well, to reset the calculation for every message.

Might be of use to someone.

Re: Absolute > Relative CCs?

Posted: Tue May 03, 2016 9:43 pm
by florian
NiDBiLD, thanks for posting!