diff --git a/MicroDexed.ino b/MicroDexed.ino index df6163b..b24d67a 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -144,7 +144,7 @@ void setup() #endif // load default SYSEX data - //load_sysex(bank, EEPROM.read(EEPROM_VOICE_ADDR)); + load_sysex(bank, EEPROM.read(EEPROM_VOICE_ADDR)); #ifdef DEBUG show_patch(); diff --git a/config.h b/config.h index 9f9b158..ee8d9f0 100644 --- a/config.h +++ b/config.h @@ -27,7 +27,7 @@ // Initial values #define MIDI_DEVICE Serial1 #define USE_ONBOARD_USB_HOST 1 -#define VOLUME 0.5 +#define VOLUME 0.2 #define SAMPLE_RATE 44100 #define DEFAULT_MIDI_CHANNEL MIDI_CHANNEL_OMNI #define DEFAULT_SYSEXBANK 0 @@ -42,7 +42,7 @@ #endif // Master key handling (comment for disabling) -//#define MASTER_KEY_MIDI MIDI_C6 +#define MASTER_KEY_MIDI MIDI_C6 #define MASTER_NUM1 MIDI_C1 // Debug output diff --git a/dexed_sysex.cpp b/dexed_sysex.cpp index 73ab8aa..e42bd4c 100644 --- a/dexed_sysex.cpp +++ b/dexed_sysex.cpp @@ -103,7 +103,8 @@ bool get_sysex_voice(char* dir, File sysex, uint8_t voice_number, uint8_t* data) { File file; uint16_t n; - uint32_t calc_checksum = 0; + int32_t bulk_checksum_calc = 0; + int8_t bulk_checksum; char sysex_file[20]; strcpy(sysex_file, dir); @@ -149,35 +150,44 @@ bool get_sysex_voice(char* dir, File sysex, uint8_t voice_number, uint8_t* data) #endif return (false); } - - file.seek(6 + voice_number * 128); // start of 32*128 (=4096) bytes data - for (n = 0; n < 128; n++) + file.seek(4102); // Bulk checksum + bulk_checksum = file.read(); + + file.seek(6); // start of bulk data + for (n = 0; n < 4096; n++) { uint8_t d = file.read(); - calc_checksum += (d & 0x7F); // calculate checksum - data[n] = d; + if (n >= voice_number * 128 && n < (voice_number + 1) * 128) + { + data[n - (voice_number * 128)] = d; + } + bulk_checksum_calc -= d; } - calc_checksum = uint8_t(~calc_checksum + 1); + bulk_checksum_calc &= 0x7f; + #ifdef DEBUG - Serial.print(F("Checksum: 0x")); - Serial.println(calc_checksum, HEX); + Serial.print(F(" Bulk checksum: 0x")); + Serial.println(bulk_checksum, HEX); #endif - uint8_t c = uint8_t(file.read()); - if (calc_checksum != c) + if (bulk_checksum_calc != bulk_checksum) { #ifdef DEBUG - Serial.print(F("E: checksum mismatch: 0x")); - Serial.print(calc_checksum,HEX); + Serial.print(F("E: Bulk checksum mismatch: 0x")); + Serial.print(bulk_checksum_calc, HEX); Serial.print(F(" != 0x")); - Serial.println(c,HEX); + Serial.println(bulk_checksum, HEX); #endif - //return (false); + return (false); } } #ifdef DEBUG - Serial.print(F("Cannot open ")); - Serial.println(sysex.name()); + else + { + Serial.print(F("Cannot open ")); + Serial.println(sysex.name()); + } #endif + return (true); }