/* EES2SYX.c - A program to convert sysex dumps from the EES Midi */ /* into Chroma Cult sysex format. */ /* */ /* Version 0.1 - written 16-DEC-03 by David Clarke */ /* (ac151@freenet.carleton.ca) */ /* */ /* Please feel free to compile, change or do whatever you want with this */ /* utility; however, if you make any significant improvements I'd */ /* appreciate you e-mailing me a copy. Thanks! */ /* */ /* Syntax: */ /* EES2SYX FILENAME.EES */ /* */ /* The program will output 1 file called FILENAME.SYX */ /* For a properly formatted EES file, the resulting sysex file will be */ /* 5958 bytes. */ /* */ /* Comments: */ /* The EES file format is generally as follows: */ /* F0 {Sysex header} */ /* 63 43 {EES header/manu. ID} */ /* payload of 50 x 69 bytes, where the first byte is the */ /* patch/program number. */ /* F7 {Sysex footer} */ /* */ /* The sysex payload (by definition) can only consist of 7-bit */ /* bytes. For the EES sysex implementation, the 8-bit Chroma */ /* program data is packed in the payload where the 'missing' */ /* eighth bit for groups of 7 'byte's are encoded in the 8th */ /* byte, as below: */ /* */ /* Byte 0 0 {program number} */ /* */ /* Byte 1 0 a7 a6 a5 a4 a3 a2 a1 */ /* Byte 2 0 b7 b6 b5 b4 b3 b2 b1 */ /* Byte 3 0 c7 c6 c5 c4 c3 c2 c1 */ /* Byte 4 0 d7 d6 d5 d4 d3 d2 d1 */ /* Byte 5 0 e7 e6 e5 e4 e3 e2 e1 */ /* Byte 6 0 f7 f6 f5 f4 f3 f2 f1 */ /* Byte 7 0 g7 g6 g5 g4 g3 g2 g1 */ /* Byte 8 0 a0 b0 c0 d0 e0 f0 g0 */ /* */ /* Byte 9 0 h7 h6 h5 h4 h3 h2 h1 */ /* ... */ /* Byte 65 0 x7 x6 x5 x4 x3 x2 x1 */ /* Byte 66 0 y7 y6 y5 y4 y3 y2 y1 */ /* Byte 67 0 z7 z6 z5 z4 z3 z2 z1 */ /* Byte 68 0 x0 y0 z0 ? ? ? ? */ /* */ /* To convert to Chroma Cult format, simply take the 7-bit */ /* data and add on the corresponding 'overflow' bit. */ /* */ /**************************************************************************/ #include #include #include #include static char out[] = ".syx"; /* output file suffix */ char *f1name; /* full input file name */ char f2name[50]; /* full output file name */ FILE *f1, *f2; int main(int argc , char *argv[]) { int aa,x, ProgCount, z; unsigned char outbyte, byte[8]; ProgCount = 0; /* Current Program Number */ if (argc == 1) { printf("Syntax: EES2SYX {filename.ees} where filename is a 50 program EES file\n"); return(-1); } f1name = argv[1]; strncpy(f2name, f1name, strlen(f1name)-4); strcat(f2name, out); if ((f1 = fopen(f1name, "rb")) == NULL) { printf("can't open %s\n", f1name); return(-1); } if ((f2 = fopen(f2name, "wb")) == NULL) { printf("can't open %s\n", f2name); return(-1); } for (x = 1; x <= 3; x++) /* Strip of Sysex header info from file */ { outbyte = fgetc(f1); } /* Output Sysex Header Info */ fputc(0xF0, f2); /* Start of Sysex */ fputc(0x08, f2); /* Fender Manuf. ID */ fputc(0x00, f2); fputc(0x4B, f2); fputc(0x59, f2); /* Chroma Cult ID */ fputc(0x7F, f2); /* Indicate that this is a data dump, not a request */ fputc(0x33, f2); /* Indicate that this is a 50-program file */ while (!feof(f1) && (ProgCount < 50)) /* Convert all 50 programs */ { /* Strip of EES Patch Number */ outbyte = fgetc(f1); ProgCount++; /* Increment current Patch Number */ fputc(ProgCount, f2); /* Output Patch Number */ z = 1; /* keep track of which partial byte we're at */ for (x = 1; x <= 68; x++) /* Do for all 68 bytes of EES data payload*/ { byte[z++] = fgetc(f1); /* If we've read qty. 8, 7-bit bytes, combine into qty. 7, 8 bit */ /* bytes, and output as nibbles. */ if (x % 8 == 0) { for (aa = 1; aa<=7; aa++) { outbyte = (byte[aa] << 1) + ((byte[8] >> (7-aa)) & 0x1); fputc((outbyte & 0xF0) >> 4, f2); /* Output Top Nibble */ fputc(outbyte & 0x0F, f2); /* Output Lower Nibble */ } z = 1; } /* If x = 68, we're at the end of the data - and need convert qty. 4*/ /* 7-bit bytes into qty. 3, 8 bitbytes, and output as nibbles. */ if (x == 68) { for (aa = 1; aa<=3; aa++) { outbyte = (byte[aa] << 1) + ((byte[4] >> (7-aa)) & 0x1); fputc((outbyte & 0xF0) >> 4, f2); /* Output Top Nibble */ fputc(outbyte & 0x0F, f2); /* Output Lower Nibble */ } } } } fputc(0xF7, f2); /* Output an End of Sysex */ fclose(f1); /* Close Input File */ fclose(f2); /* Close Output File */ return(0); }