Ok, I have come back and re-read this a few times now. It is very helpful, hut there are still some things I don’t fully understand (yet).
For example:
Determining midi channel by “masking lower four bits (0x0f)” – what is going on here? I mean, I understand the result, but I don’t understand where the 0x0f comes from, and what it means. Is the “x” in this string a multiplication? Clearly there is no “x” in the hexadecimal system. I also don’t *really* understand what a bit is, in relation to the message we are dealing with, and therefore what the “lower four bits” really means. Also, I don’t exactly understand how or why “tt=oo&15” achieves this masking and lets tt=incoming channel number.
SJC> OK if you look at a binary value of a 8 bit MIDI Bite it looks like this
1111 1111
I separated the values by “nibble” which is 4 bits. The right most bit of each
nibble represents 1, the next one 2, the next one 4 and the left most bit is 8
So to represent different numbers
000=1
0001=1
0010=2
0011=3
0100=4
0101=5
0110=6
0111=7
1000=8
1001=9
1010= 10 decimal (A Hex which is represented as 0xa)
1011= 11 decimal ( 0xb)
1100=12 decimal (0xc)
1101=13 decimal (0xd)
1110-14 decimal (0xe)
1111-15 decimal (0x0e)
so 1111 1111 represents 0xff (first nibble 0xf0, second nibble 0x0f)
the MIDI command for note on is 0x9n where n is the channel number starting with zero. So 0x90 is note on MIDI channel 1. 0x91 would be note on MIDI channel 2
and so on.
What we do here is OR the bits together. The operator for or is “|”
1 OR 1 = 1
1 OR 0 = 1
0 OR 1 = 1
0 OR 0 = 0
So if we take the first nibble 0xB0 and OR with the channel number we get the
full note on and channel message
1011 0000 (0xb0)
OR
0000 0000 (0x0)
=========
1011 0000 (0xb0)
If we OR it with channel 1 we get
1011 0000 (0xb0)
OR
0000 0001 (0x1)
=========
1011 0000 (0xb1)
So essentially we are building the note on message with the channel number in
the rules
<SJC
Moving on:
“Get the command (upper value)”… We are getting the message type here (i.e. Bx for program change, 9x for note-on [where x is the channel in hexadecimal])? Is that correct?
SJC > Yes
<SJC
Next:
“// 0xF0 = 240 decimai” I think this is a typo-error for decimal, but I’m not sure why “uu=oo&0xF0” achieves the result we want, which I guess is to “let uu equal message type” [unless I was wrong about what was meant by “Get the command” earlier]. (Is this using more masking, perhaps?)
SJC> Not a typo. For an 8 bit number the lowest bit on the higher nibble is 16
So 0xf0 converted to decimal is 240
1 times 16
plus
1 times 32
plus
1 times 64
plus
1 times 128
128+64+32+16 =240
<SJC
(Aside:
I managed to negotiate the line “of uu!=0xb0 then exit rules, skip outgoing action” but only after pulling up a pdf of the manual and using the search function to find instances of “!” – my lack of experience with scripting, programming, etc, meant that I did not realise “!=” was a simple “does-not-equal”. I think it was on page 60-something of the manual. I have included this so you have some idea of the ignorance with which I am approaching this. I have, on a few occasions, read through the manual, and the forum, and seen a lot of your videos, but it is exceptionally difficult to take it all in, and I always find I don’t understand or remember the information I need when I need to use it!)
SJC> Thats OK, we all started here at one time or another. Part of the learning experience.
Further:
In the “if uu!=0xb0 then…” line, I don’t understand this now familiar type of string, here represented by 0xb0. I mean, I assume it just means “B (change command)” but I am hazarding guesses at a lot of this.
SJC> If uu is note equal to hex b0 (decimal 176) then ..
0xb0 is the command (upper nibble) for a control (CC) message on channel 1
For instance if you want to change controller number 1 on MIDI channel 2 it would be
0xb1 0xnn 0xvv
where nn is the controller number and vv is the value
<SJC
Final section:
How does ORing the command and the channel together work? My internal logic doesn’t like “let z=a or b” leading to “z=ab”, or “z=a_then_b” although I’m sure this is my stupidity. I am assuming from “// vv is now 0xB4” that vv is now what I would have thought of as B4 (cc change on channel 5).
SJC>
Hopefully this is explained above already)
OxB4 is Control change on MIDI channel 5)
<SJC
If you have time:
– I noticed yoy did not include an outgoing message, would this set of rules be used in conjunction with the other rule/translators to achieve the “velocity-to-cc41-and-sent-BEFORE-note-on” result, or did you envisage a single self-contained rule to do the whole process?
Is one way obviously better than the other?
SJC> Including all rules in one translator vs multiple translator is usually a matter
of choice. For me, if I already have a translator that handles a given function, I try and leverage it rather than duplicate it in multiple translators. That way, if I later need to change it, I can change it in one place rather than many).
<SJC
-Would replacing the last action in the rule with “vv=uu|tt” mean that vv became a control change message (B) on whatever the input channel was, or am I way off the mark?
SJC> You are right on
<SJC
And just for clarification:
Some of the four character strings which begin 0x (such as “0xF0” and “0x0f”), have got lower/upper case letters (aside from the lower-case “x”). Is this intentional? Are they case-sensitive strings? Do f and F mean different things there?
SJC> Case is insensitve in MT Pro 0xf0 is the same as 0XF0.
<SJC
Thanks so much for the help you’ve already provided me with this.
SJC> Your quite welcome!
<SJC