Jump to content

Checksum


Per
 Share

Recommended Posts

Hi Per,

the checksum is calculated over the data part only (256 bytes)

Calculation (pseudo code):


// data block is located in data[] array
// create sysex string:

Array<uint8> sysEx;

sysEx.add(0xf0);
sysEx.add(0x00);
sysEx.add(0x00);
sysEx.add(0x7e);
sysEx.add(0x49);
sysEx.add(deviceNumber);
sysEx.add(0x02);
sysEx.add(type);
sysEx.add(bank);
sysEx.add(patch);

uint8 checksum = 0x00;
for(int i=0; i<256; ++i) {
uint8 b = data[i];
sysEx.add(b);
checksum += b;
}

sysEx.add(-(int)checksum & 0x7f); // 7bit !!!
sysEx.add(0xf7);
[/code]

Best Regards, Thorsten.

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...