From f946ac7a813bac0680cdf5c5fcef5e8a6c0d9192 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Mon, 30 Sep 2019 11:08:17 +0200 Subject: [PATCH] SYSEX loading of voices. Not ready yet. --- MicroDexed.ino | 43 +++++++++++++++++++++++++++++++++++++++++++ config.h | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 59c0d01..8f8ae99 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -657,11 +657,22 @@ void handleSystemExclusive(byte * sysex, uint len) } else if (len == 163) { + int32_t bulk_checksum_calc = 0; + int8_t bulk_checksum = sysex[161]; + // 1 Voice bulk upload #ifdef DEBUG Serial.println(F("1 Voice bulk upload")); #endif + if (sysex[162] != 0xf7) + { +#ifdef DEBUG + Serial.println(F("E: Found no SysEx end marker.")); +#endif + return; + } + if ((sysex[3] & 0x7f) != 0) { #ifdef DEBUG @@ -678,7 +689,39 @@ void handleSystemExclusive(byte * sysex, uint len) return; } + // checksum calculation + for (uint8_t i = 0; i < 155 ; i++) + { + bulk_checksum_calc -= sysex[i + 6]; + } + bulk_checksum_calc &= 0x7f; + if (bulk_checksum_calc != bulk_checksum) + { +#ifdef DEBUG + Serial.print(F("E: Checksum error for one voice [0x")); + Serial.print(bulk_checksum, HEX); + Serial.print(F("/0x")); + Serial.print(bulk_checksum_calc, HEX); + Serial.println(F("]")); +#endif + return; + } + + // load sysex-data into voice memory + uint8_t tmp_data[155]; + memset(tmp_data, 0, 155 * sizeof(uint8_t)); + + for (uint8_t i = 0; i < 155 ; i++) + { + tmp_data[i] = sysex[i + 6]; + } + strncpy(voice_name, (char *)&tmp_data[145], sizeof(voice_name) - 1); + Serial.print(F("Voice [")); + Serial.print(voice_name); + Serial.print(F("] loaded.")); + + dexed->loadSysexVoice(tmp_data); } #ifdef DEBUG else diff --git a/config.h b/config.h index 87a82ed..aa811d7 100644 --- a/config.h +++ b/config.h @@ -52,7 +52,7 @@ // AUDIO // If nothing is defined PT8211 is used as audio output device! -#define TEENSY_AUDIO_BOARD 1 +//#define TEENSY_AUDIO_BOARD 1 //#define TGA_AUDIO_BOARD //*************************************************************************************************