Charles,
There is some confusion sometimes with the use of the term 'nybble' and 'byte' in Sysex manuals - because all the message data has to be below 127,I suppose you may know that some manufacturers split the BYTE up into Hi and Lo nybbles - both below 16 in value.
Since the actual message BYTE contains these 4 bits then the item that is actually a NYBBLE is represented in a BYTE.
That is - if the data was 20 then the hi nybble has to represent 16 and the lower one 4 which means
0001 0100 (20dec) becomes 0000 0001 = 1 in the hi 'byte' and 0000 0100 = 4 in the lo 'byte'
Of course referring to them as 'bytes' is kind of confusing - Yamaha refer to the 2s complement of all data BYTES in the PSS manual - what is actually means is to sum the numbers in the hi and lo 'bytes' which are actually nybbles in the sense that they never get beyond 4 bits.
I have not tried to do a Casio checksum yet,presumably I will be back referring to Jose when [if?] I get there!
LEE
________________________________
From: charlie midi gfa <charles.copp@...>
To: CZsynth@yahoogroups.com
Sent: Thursday, 30 January 2014, 20:43
Subject: Re: [CZsynth] VZ SysEx Format
nybbles are bytes
?
charlie
----- Original Message -----
From: "Lee Borrell" <templarser@...>
To: <CZsynth@yahoogroups.com>
Sent: Thursday, January 30, 2014 1:59 PM
Subject: Re: [CZsynth] VZ SysEx Format
That's interesting thanks - I have worked on Yamaha checksums which
calculate on the nybbles - not the bytes - I will bear what you have said in
mind when I come to CZ.
________________________________
From: José Ángel Morente <msxjam@...>
To: CZsynth@yahoogroups.com
Sent: Wednesday, 29 January 2014, 22:30
Subject: Re: [CZsynth] VZ SysEx Format
That's right.
The checksum is in fact a 'checksub' :)
It works similar to a two's complement, but I remember (it was some years
ago) that the traditional complement caused the checksum to fail in one or
two cases (when the sum was 00 or 7F, can't remember for sure).
After a while I realized that substracting the accumulated value (instead of
summing) the thing worked perfectly.
Then you must reset the more significant bit. I used for that a AND 7F
operation (checksum = checksum & 0x7f)
However, the tricky part is that the VZ sends the data bytes splitted into 2
nibbles, but the checksum is calculated with the whole byte.
In other words, you have to do these steps:
1) Read one byte from sysex
2) Read one byte from sysex, shift 4 bits to left
3) Get the actual data, byte = 1) OR 2)
4) CHECKSUM = CHECKSUM - BYTE
5) goto 1) and repeat 64 times * patch length
6) Take the 7 less significant bits: CHECKSUM = CHECKSUM & 0x7F
7) Store the checksum byte, the sysex closing sequence, 0xF7, etc.
On 29 Jan 2014 17:27, "Lee Borrell" <templarser@yahoo.co.uk> wrote:
>
>Jose,
>
>Can you explain the -= in C, is that subtraction?
>
>It seems your routine is very similar to mine save for the 'twos
>complement' section - but if you are subtracting rather than adding,perhaps
>that accounts for it.
>I do not know what the VZ checksum should be anyhow - only yamahas.
>
>Is the VZ summing all nybbles and then anding with 7f,or is there something
>more?
>
>
>
>
>
>
>________________________________
> From: José Ángel Morente <msxjam@...>
>To: CZsynth@yahoogroups.com
>Sent: Wednesday, 29 January 2014, 16:18
>Subject: Re: [CZsynth] VZ SysEx Format
>
>
>
>
>Some time ago I posted a C program used to convert from VZ1 to standard SYX
>files. You may take a look at the checksum routine, maybe it can be
>helpful:
>
>
>#include <stdio.h>
>#include <stdlib.h>
>#include <string.h>
>
>#define TONES_NO 64;
>
>typedef unsigned char byte;
>
>int main (int argc,char *argv[])
>{
> char *inputfilestream;
> char *outputfilestream;
> FILE *inputfile;
> FILE *outputfile;
>
> byte tonebuf[336];
> byte operbuf[100];
>
> byte syxopen[8]={
> 0xf0, 0x44, 0x03, 0x00, 0x70, 0x70, 0x02, 0xf7
> };
> byte syxdata[6]={
> 0xf0, 0x44, 0x03, 0x00, 0x70, 0x74
> };
> byte syxclose[7]={
> 0xf0, 0x44, 0x03, 0x00, 0x70, 0x71, 0xf7
> };
>
> int i,j,checksum=0;
>
> byte buffer[10];
>
> if (argc >= 2) {
>
> inputfilestream = argv[1];
> if (argc > 2) {
> outputfilestream = argv[2];
> } else {
> outputfilestream = malloc(255);
> strcpy(outputfilestream,inputfilestream);
> outputfilestream = strcat(outputfilestream,".syx");
> }
>
> inputfile = fopen(inputfilestream,"rb");
> outputfile = fopen(outputfilestream, "wb");
>
> //write OPEN and DATA sysx messages
> fwrite(syxopen,sizeof(syxopen),1,outputfile);
> fwrite(syxdata,sizeof(syxdata),1,outputfile);
>
> //process the patches
> for (i=0;i<64;i++) {
> fread(tonebuf,sizeof(tonebuf),1,inputfile);
> checksum = 0;
> for (j=0;j<sizeof(tonebuf);j++) {
> //update the checksum
> checksum -= tonebuf[j];
>
> buffer[1] = tonebuf[j] & 0x0f;
> buffer[0] = tonebuf[j] >> 4;
> fwrite(buffer,2,1,outputfile);
> }
> //ignores the bit 7
> checksum &= 0x7f;
> fwrite(&checksum,1,1,outputfile);
>
> }
> //process the operations
> for (i=0;i<64;i++) {
> fread(operbuf,sizeof(operbuf),1,inputfile);
> checksum = 0;
> for (j=0;j<sizeof(operbuf);j++) {
> //update the checksum
> checksum -= operbuf[j];
>
> buffer[1] = operbuf[j] & 0x0f;
> buffer[0] = operbuf[j] >> 4;
> fwrite(buffer,2,1,outputfile);
> }
> //ignores the bit 7
> checksum &= 0x7f;
> fwrite(&checksum,1,1,outputfile);
>
> }
>
> buffer[0] = 0xf7;
> fwrite(buffer,1,1,outputfile);
> fwrite(syxclose,sizeof(syxclose),1,outputfile);
>
>
> fclose(inputfile);
> fclose(outputfile);
> }
> return 0;
>}
>
>
>
>
>
>--
>
>
>
>
>On Sun, Jan 5, 2014 at 10:23 PM, <facebook@...> wrote:
>
>
>>
>>Happy new year to all,
>>
>>
>>I spent some time during the holidays setting up an smal HTML5 based
>>framework which is intented to act as a librarian for the VZ sound
>>patches.
>>
>>
>>Going through the specs I came over the checksum, which isn't described in
>>detail in the CasioVZ-HohnerHS Sysex Format.pdf.
>>
>>
>>Can anyone help me out on the details here?
>>
>>
>>My idea:
>>Create a little helper to rearrange existing sysex files, which will (in
>>the first step) be consolidated in a new sysex file to be uploaded.
>>
>>
>>
>>My progress:
>>So far I can drag and drop sysex files into the GUI and extract the tone
>>and op names of the banks, also a re-arrangement is possible (from gui
>>side).
>>
>>
>>My need:
>>Any help on the internal sysex format - especially on the check sum.
>>
>>
>>Technology:
>>HTML5 so anyone could use it. Upload to the VZ would still need an
>>external tool but maybe HTML5 will support that, too in the future.
>>
>>
>>Me:
>>I have a VZ10m, HS-2, CZ-3000 and an HT-3000 in my set-up (besides D-110,
>>X3R, AN1x, Phm and sonic|core Scope 5)
>>
>>
>>Any help is appreciated,
>>
>>
>>cheers,
>>
>>
>>Pete
>>
>>
>>(I was in the forum before but lot my ID after a computer crash ;) )
>>
>>
>
>
>Message
Re: [CZsynth] VZ SysEx Format
2014-02-06 by Lee Borrell
Attachments
- No local attachments were found for this message.