How do I convert absolute cc’s to relative cc’s?

  • Q&A Forum
  • How do I convert absolute cc's to relative cc's?
2
0

Ultimately I seek to be sending out physical keys G or H with relative/incremental behavior from an absolute knob. I have the option to change the knob to relative in it’s respective editor software, BUT I have already mapped the knob in 6 other presets of my project as an absolute knob!

In this case it just makes more sense for me to change this one usage of the knob to relative, instead of changing all the other uses from relative to absolute! Ideally, the solution would live in one preset and only use 1 global variable! Is that possible?

Thanks in advance

Marked as spam
Posted by (Q&A Forum: 5, Answers: 18)
January 14, 2017 6:43 pm
203 views
2
Private answer

Yes, a local variable “lives” within the incoming event. So even if two translators have different incoming action, they will use the same local variables if once event triggers both.
Example:
Translator 1 Incoming: Note On any channel, Note 60, any velocity, set pp to velocity
Translator 2 Incoming: Note On Channel 1, Any Note, any velocity

Now if Note On, Channel 1, Note 60, Velocity 100 is received on a MIDI IN port, first Translator 1 is triggered and sets pp to 100. In the rules, it sets qq to 27.
Then Translator 2 is triggered, and you can count on pp being 100 and qq 27.
Beware: in Translator 1, the values of pp and qq are not defined and can be anything. They’re not specified to be 0 by default.

Also, of course, a translator can only pass on local variables to following translators.

This behavior is also very useful to circumvent concurrency issues: the MIDI engine in MT Pro is heavily multi-threaded (i.e. can process incoming MIDI data simultaneously using all processor cores), so when using local variables, you can be sure that no other simultaneous incoming MIDI event can change the local variable of another incoming event (even if the same translator!). Don’t worry if that sounds abstract 🙂 These are difficult concepts in general.

Marked as spam
Posted by (Q&A Forum: 6, Answers: 351)
January 16, 2017 9:50 pm
0
Private answer

Are you saying that if you have multiple translators sharing a single event, the local variable is common across all of those translators? Wow, good to know if true. I thought the local variables were tied to only a given translator.

Marked as spam
Posted by (Q&A Forum: 39, Answers: 3273)
January 16, 2017 9:20 pm
0
Private answer

Thanks Florian,
I wasn’t able to get this working for some reason the second translator was working but the first one was sending both keystrokes at the same time.

I read through the forum link and have been working with one of your examples using 2 global variables but I am hitting a different issue now that the knob stops sending keystrokes after it reaches it’s max/min (0/7F). I could not find the solution in the attached thread. I am confused how this could ever be possible for an absolute knob to continue sending keystrokes after it has reached it’s max/min— or is there another trick?

Thanks again

Marked as spam
Posted by (Q&A Forum: 5, Answers: 18)
January 15, 2017 5:26 am
1
Private answer

Hi, yes, that’s definitely possible. It depends a bit on which relative style you want it to convert to. Here is an example for CC#20:

[x] Translator 0.0: turn left
Options: swallow
Incoming: Control Change on ch. 1 with CC#:20 (0x14) set 'pp' to value
Rules:
  qq=ga-pp
  ga=pp
  if qq>=0 then exit rules, skip Outgoing Action
  pp=63-qq
Outgoing: Control Change on ch. 1 with CC#:14 (0x0E) and value:pp

[x] Translator 0.1: turn right
Options: swallow
Incoming: Control Change on ch. 1 with CC#:20 (0x14) and any value
Rules:
  if qq<=0 then exit rules, skip Outgoing Action
  qq=qq-1
Outgoing: Control Change on ch. 1 with CC#:14 (0x0E) and value:qq

It sends value 64 for turning right (or up). When you turn left, it sends value 0. If you turn faster, you might skip values, so then it’s sending e.g. 65 or 1 (whatever the difference is).

I use a trick here to get by with one global variable: local variables are bound to an incoming event, so because the second translator reacts to the same incoming event, we can safely pass on variable qq from the first to the second translator.

Marked as spam
Posted by (Q&A Forum: 6, Answers: 351)
January 15, 2017 4:14 am
( at January 15, 2017 4:17 am)

ha, I haven’t seen that you do want to send out keystrokes! so just replace the outgoing action with keystrokes!

( at January 15, 2017 4:18 am)

very cool trick with passing the local variable! I will remember that one!
I mistakenly responded to this by clicking the ”answer” button :0

( at January 15, 2017 5:29 am)