Roland sysex checksum calculation

rtm1101

2016-05-10 11:41:08

Hi all-

I have found a few posts here that got me started, but nothing to get me all the way. Here is my situation.

I am able to calculate and send successful sysex messages to my roland device individually by hand. For example, if I pick and incoming trigger like midi note or key stroke, and set my outgoing to "raw midi" and enter:

f0 41 10 00 00 00 20 12 70 01 0b 7f 05 f7

in the message field, it sets the address 70 01 0b with data 7f successfully. the checksum of 05 is calculated using standard roland formula of adding the address and data bits, dividing by 128, and subtracting the remainder from 128. If this value is 128, we use 00 as the checksum.

just to be sure i'm getting this right, here is a break down of the above sys ex.


f0 - command to start sys ex
41 - roland family product id
10 - individual device id
00 00 00 20 - product id
12 - command for data set operation
70 01 0b - address of parameter at device we want to change
7f - value to write at above address
05 - check sum
f7 - command to end sys ex

As I said this works great. However, I would very much like to use a control change message from a different device also attached to my computer, a livid DS1, to set this value. The range of the parameter I am trying to alter is also 128 steps like CC, so I have selected the correct CC # in the incoming window, and set the value to "any value" with the set variable option ticked and set to oo. Referring back to my original sys ex statement, "f0 41 10 00 00 00 20 12 70 01 0b 7f 05 f7", i understand to replace the 7f value with the "oo" variable: "f0 41 10 00 00 00 20 12 70 01 0b oo 05 f7".

Is this all correct so far?


at this point the checksum will be invalid. I am hoping there is a rule I can write to look at the incoming cc value on #50 and use that value to calculate the check sum.

Can this be done?


Thank you for your help!

DvlsAdvct

2016-05-10 15:35:14

Hi rtm1101

If it works the way you explained, it should work correctly. Out of curiosity, can you check what the message should be if the value isn't 7F? you mentioned there's a formula involved to calculate the checksum. If the value is NOT 7F, is the Checksum still 05?

Jared

rtm1101

2016-05-10 18:59:23

As the oo variable changes with the CC value, the calaclution mentioned above will have various results. This calculation is: add the value of the address bits and the data bits (the data bit is the variable CC value), divide by 128, and subtract the remainder from 128. This yields a number from 1 to 128, not 0 to 127 as we need, so if the solution is 128 Roland changes it into a 0.

I just need to know how to use the rules section to reliabley make this calulation without a MOD function, and write it to a second variable.

Cheers and thank you.

florian

2016-05-10 19:32:36

you can use the % operator as a MOD function. For calculating the checksum in pp:

// add the address bytes
pp=0x70
pp=pp+0x01
pp=pp+0x0b
// add the data byte
pp=pp+oo
// calculate the remainder of pp/128
pp=pp % 128
// subtract the remainder from 128
pp=128 - pp
if pp==128 then pp=0

Let us know if that works!
Florian

rtm1101

2016-05-12 19:02:22

Bingo!

You made the sale!!!

Thanks for your help and great software Florian!