|
|
@ -103,7 +103,8 @@ bool get_sysex_voice(char* dir, File sysex, uint8_t voice_number, uint8_t* data) |
|
|
|
{ |
|
|
|
{ |
|
|
|
File file; |
|
|
|
File file; |
|
|
|
uint16_t n; |
|
|
|
uint16_t n; |
|
|
|
uint32_t calc_checksum = 0; |
|
|
|
int32_t bulk_checksum_calc = 0; |
|
|
|
|
|
|
|
int8_t bulk_checksum; |
|
|
|
char sysex_file[20]; |
|
|
|
char sysex_file[20]; |
|
|
|
|
|
|
|
|
|
|
|
strcpy(sysex_file, dir); |
|
|
|
strcpy(sysex_file, dir); |
|
|
@ -149,35 +150,44 @@ bool get_sysex_voice(char* dir, File sysex, uint8_t voice_number, uint8_t* data) |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
return (false); |
|
|
|
return (false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
file.seek(4102); // Bulk checksum
|
|
|
|
|
|
|
|
bulk_checksum = file.read(); |
|
|
|
|
|
|
|
|
|
|
|
file.seek(6 + voice_number * 128); // start of 32*128 (=4096) bytes data
|
|
|
|
file.seek(6); // start of bulk data
|
|
|
|
for (n = 0; n < 128; n++) |
|
|
|
for (n = 0; n < 4096; n++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
uint8_t d = file.read(); |
|
|
|
uint8_t d = file.read(); |
|
|
|
calc_checksum += (d & 0x7F); // calculate checksum
|
|
|
|
if (n >= voice_number * 128 && n < (voice_number + 1) * 128) |
|
|
|
data[n] = d; |
|
|
|
{ |
|
|
|
|
|
|
|
data[n - (voice_number * 128)] = d; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
bulk_checksum_calc -= d; |
|
|
|
} |
|
|
|
} |
|
|
|
calc_checksum = uint8_t(~calc_checksum + 1); |
|
|
|
bulk_checksum_calc &= 0x7f; |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.print(F("Checksum: 0x")); |
|
|
|
Serial.print(F(" Bulk checksum: 0x")); |
|
|
|
Serial.println(calc_checksum, HEX); |
|
|
|
Serial.println(bulk_checksum, HEX); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
uint8_t c = uint8_t(file.read()); |
|
|
|
if (bulk_checksum_calc != bulk_checksum) |
|
|
|
if (calc_checksum != c) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.print(F("E: checksum mismatch: 0x")); |
|
|
|
Serial.print(F("E: Bulk checksum mismatch: 0x")); |
|
|
|
Serial.print(calc_checksum,HEX); |
|
|
|
Serial.print(bulk_checksum_calc, HEX); |
|
|
|
Serial.print(F(" != 0x")); |
|
|
|
Serial.print(F(" != 0x")); |
|
|
|
Serial.println(c,HEX); |
|
|
|
Serial.println(bulk_checksum, HEX); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
//return (false);
|
|
|
|
return (false); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
Serial.print(F("Cannot open ")); |
|
|
|
Serial.print(F("Cannot open ")); |
|
|
|
Serial.println(sysex.name()); |
|
|
|
Serial.println(sysex.name()); |
|
|
|
|
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
return (true); |
|
|
|
return (true); |
|
|
|
} |
|
|
|
} |
|
|
|