sending out "note on/off" on a different channel

Magnuzoid

2014-12-16 18:27:21

Hi,
I'd like to send my keyboard's keys out on a different channel than the default: 1.
I've made one rule for the keys (IN):
90 bb qq

I want then to output:
92 bb qq

but when using Midi Monitor, it tells me that my translated values are still on channel 1,
and the weirdest thing is that when I press a key, the value transmitted is the key I previously pressed.
For example pressing first an A3 and then C3 will give me two times A3, but if I press C3 again it will output C3.
I'm guessing it's something to do with the values of the variables being stored, but I can't seem to look through what's going on, so I'm hoping someone here can help me. :)

Best regards,

Magnus

Magnuzoid

2014-12-16 20:09:22

I think I've solved it by using individual variables for the messages I'm sending. :)

florian

2014-12-16 20:53:16

Hi, just to clarify whoever else is reading this thread: "bb" is not a variable, it's a hexadecimal number BB, which is start of a control change MIDI message on channel 12 :)

For changing channel from 1 to 3, use a translator like this:

Code: Select all

Incoming: MIDI 90 pp qq
  [x]swallow original message
Outgoing: MIDI 92 pp qq
To also capture Note Off messages, add another translator like this:

Code: Select all

Incoming: MIDI 80 pp qq
  [x]swallow original message
Outgoing: MIDI 82 pp qq
Regards,
Florian

Magnuzoid

2014-12-16 20:58:13

Hi Florian, it's great that you add that to it. I had to quickly refresh my knowledge regarding the translator since I'm trying to setup my old Oxygen keyboard to work with Bitwig and some Native Instruments plugs. Had some CC's that affected some hard-coded parameters.. but yeah it's worth mentioning that the manual says that the local variables range from "oo" to "zz".. I had been using "pp" on all the rules (8 knobs + 1 for keys).
I just want to make sure. If I use - let's say "pp" - for two rules in the same preset, do they then affect each other? I wouldn't expect that since they are locale variables, but maybe locale is with each preset in the translator?

Best regards

florian

2014-12-16 21:16:32

Hi,

indeed, the local and global variable scope is not very clearly documented.

Global variables are easy: they keep their value across translators, presets and apply to all incoming and outgoing actions, and rules, of course. If you use a global variable in an incoming MIDI message, the global variable will be set to the corresponding value. Usually it's OK to do that, though you can use a timer or other Incoming actions to also set the global variable which might be executed at the same time. Because of this slight possibility of a "race condition", we usually use local variables if they are only used inside one translator.

The scope of local variables, however, is defined to an incoming event. So when setting a local variable in an incoming MIDI event, it cannot be changed by another incoming event that comes at the same time. That's why it's always safe to use local variables in a translator that you do not need outside of the translator.

Hope I confused you less than clarify :)
Florian

Magnuzoid

2014-12-16 21:22:33

Thank you for that, but in the case where I have 8 knobs. Would I be able to use the same locale variable for each rule without it affecting each other?
I've attached my end result, but there I switched to individual variable, since i got the impression that was part of my problem.
I'd just like to have this clarified regarding the locals, so I have that straight for the next time I need to do some quick translating. :)
Attachments
Screen Shot 2014-12-16 at 21.21.32.png
Screen Shot 2014-12-16 at 21.21.32.png (43.39 KiB) Viewed 3189 times

florian

2014-12-16 22:36:59

You can use the same local variable in every translator. Here's a step-by-step what happens for example:
Say, you turn knob 3 by one notch, say this arrives as this MIDI message: B0 0C 08 (CC#12 on Channel 1, value 8).
So the incoming event carries this MIDI message.
Now MT examines the first translator if it matches to this incoming event: but it does not, because the first translator triggers on CC#73. Variable oo is not touched and stays "uninitialized" as all other local variables.
Then it examines the second translator. Same here.
Then it examines the third translator: this one matches, and it sets qq to 8 (the value of the incoming message). Now qq is stored along with the incoming event. If the third translator has rules, they are executed, where qq has the value 8. Last, but not least, the outgoing action is executed, using the value of qq stored in the incoming event.
Unless the translator has the "stop processing" flag checked, this event will continue "traveling" to all next translators, but won't match any of them. If any other translator matched, they could use the value of qq, because it's tied to this incoming event.

Now if simultaneously you turn knob 2, it will have its own incoming event, and it will set qq in this event (not in the other event from knob 3).

So in your preset, you can safely use the same variable for all translators.

It's a bit abstract to explain...
Florian

PS: the last outgoing MIDI message seems to be wrong, unless you initialize ga (a global variable) somewhere.

Magnuzoid

2014-12-16 22:58:02

hehe I like how the cool smiley came in (to other readers, this is meant as "8 )".
But I think you made it clear - I have some programming background and I'm used to local and global variables and just had to make sure it made the same sense as I initially thought. being each translater being a function with a local variable inside of it, but you clarified it well - thanks and thank you for a nice piece of software together with perfectly fast support!

Regarding the ga variable - I had to define it in the rule to force the channel to channel 2.

All works well, thank you :)