|
|
|
@ -51,7 +51,9 @@ bool load_sd_voice(uint8_t b, uint8_t v, uint8_t instance_id) |
|
|
|
|
get_bank_name(b, bank_name, sizeof(bank_name)); |
|
|
|
|
sprintf(filename, "/%d/%s.syx", b, bank_name); |
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
sysex = SD.open(filename); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
if (!sysex) |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
@ -81,8 +83,9 @@ bool load_sd_voice(uint8_t b, uint8_t v, uint8_t instance_id) |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
configuration.dexed[instance_id].transpose = MicroDexed[instance_id]->getTranspose(); |
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
sysex.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
uint8_t data_copy[155]; |
|
|
|
|
MicroDexed[instance_id]->getVoiceData(data_copy); |
|
|
|
@ -94,7 +97,9 @@ bool load_sd_voice(uint8_t b, uint8_t v, uint8_t instance_id) |
|
|
|
|
else |
|
|
|
|
Serial.println(F("E : Cannot load voice data")); |
|
|
|
|
#endif |
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
sysex.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return (false); |
|
|
|
@ -115,7 +120,9 @@ bool save_sd_voice(uint8_t b, uint8_t v, uint8_t instance_id) |
|
|
|
|
get_bank_name(b, bank_name, sizeof(bank_name)); |
|
|
|
|
sprintf(filename, "/%d/%s.syx", b, bank_name); |
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
sysex = SD.open(filename, FILE_WRITE); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
if (!sysex) |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
@ -140,7 +147,9 @@ bool save_sd_voice(uint8_t b, uint8_t v, uint8_t instance_id) |
|
|
|
|
Serial.print(voice_name); |
|
|
|
|
Serial.println(F("]")); |
|
|
|
|
#endif |
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
sysex.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
return (true); |
|
|
|
|
} |
|
|
|
@ -148,7 +157,9 @@ bool save_sd_voice(uint8_t b, uint8_t v, uint8_t instance_id) |
|
|
|
|
else |
|
|
|
|
Serial.println(F("E : Cannot load voice data")); |
|
|
|
|
#endif |
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
sysex.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return (false); |
|
|
|
@ -160,6 +171,7 @@ bool get_sd_voice(File sysex, uint8_t voice_number, uint8_t* data) |
|
|
|
|
int32_t bulk_checksum_calc = 0; |
|
|
|
|
int8_t bulk_checksum; |
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
if (sysex.size() != 4104) // check sysex size
|
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
@ -209,6 +221,7 @@ bool get_sd_voice(File sysex, uint8_t voice_number, uint8_t* data) |
|
|
|
|
bulk_checksum_calc -= d; |
|
|
|
|
} |
|
|
|
|
bulk_checksum_calc &= 0x7f; |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Bulk checksum : 0x")); |
|
|
|
@ -240,6 +253,7 @@ bool put_sd_voice(File sysex, uint8_t voice_number, uint8_t* data) |
|
|
|
|
uint16_t n; |
|
|
|
|
int32_t bulk_checksum_calc = 0; |
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
sysex.seek(0); |
|
|
|
|
|
|
|
|
|
if (sysex.size() != 4104) // check sysex size
|
|
|
|
@ -292,6 +306,7 @@ bool put_sd_voice(File sysex, uint8_t voice_number, uint8_t* data) |
|
|
|
|
} |
|
|
|
|
sysex.seek(4102); // Bulk checksum
|
|
|
|
|
sysex.write(bulk_checksum_calc & 0x7f); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Bulk checksum : 0x")); |
|
|
|
@ -319,6 +334,7 @@ bool save_sd_bank(const char* bank_filename, uint8_t* data) |
|
|
|
|
// first remove old bank
|
|
|
|
|
sscanf(bank_filename, "/%d/%s", &bank_number, tmp); |
|
|
|
|
sprintf(tmp, "/%d", bank_number); |
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
root = SD.open(tmp); |
|
|
|
|
while (42 == 42) |
|
|
|
|
{ |
|
|
|
@ -365,6 +381,7 @@ bool save_sd_bank(const char* bank_filename, uint8_t* data) |
|
|
|
|
root = SD.open(bank_filename, FILE_WRITE); |
|
|
|
|
root.write(data, 4104); |
|
|
|
|
root.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F(" done.")); |
|
|
|
|
#endif |
|
|
|
@ -393,6 +410,7 @@ bool load_sd_voiceconfig(int8_t vc, uint8_t instance_id) |
|
|
|
|
sprintf(filename, "/%s/%s%d.syx", VOICE_CONFIG_PATH, VOICE_CONFIG_NAME, vc); |
|
|
|
|
|
|
|
|
|
// first check if file exists...
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
if (SD.exists(filename)) |
|
|
|
|
{ |
|
|
|
|
// ... and if: load
|
|
|
|
@ -407,12 +425,14 @@ bool load_sd_voiceconfig(int8_t vc, uint8_t instance_id) |
|
|
|
|
get_sd_data(sysex, 0x42, (uint8_t*)&configuration.dexed[instance_id]); |
|
|
|
|
set_voiceconfig_params(instance_id); |
|
|
|
|
sysex.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
return (true); |
|
|
|
|
} |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
Serial.print(F("E : Cannot open ")); |
|
|
|
|
Serial.print(filename); |
|
|
|
|
Serial.println(F(" on SD.")); |
|
|
|
@ -452,15 +472,18 @@ bool save_sd_voiceconfig(uint8_t vc, uint8_t instance_id) |
|
|
|
|
Serial.println(filename); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
sysex = SD.open(filename, FILE_WRITE); |
|
|
|
|
if (sysex) |
|
|
|
|
{ |
|
|
|
|
if (write_sd_data(sysex, 0x42, (uint8_t*)&configuration.dexed[instance_id], sizeof(configuration.dexed[instance_id]))) |
|
|
|
|
{ |
|
|
|
|
sysex.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
return (true); |
|
|
|
|
} |
|
|
|
|
sysex.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
@ -493,6 +516,7 @@ bool load_sd_fx(int8_t fx) |
|
|
|
|
sprintf(filename, "/%s/%s%d.syx", FX_CONFIG_PATH, FX_CONFIG_NAME, fx); |
|
|
|
|
|
|
|
|
|
// first check if file exists...
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
if (SD.exists(filename)) |
|
|
|
|
{ |
|
|
|
|
// ... and if: load
|
|
|
|
@ -507,12 +531,14 @@ bool load_sd_fx(int8_t fx) |
|
|
|
|
get_sd_data(sysex, 0x43, (uint8_t*)&configuration.fx); |
|
|
|
|
set_fx_params(); |
|
|
|
|
sysex.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
return (true); |
|
|
|
|
} |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
Serial.print(F("E : Cannot open ")); |
|
|
|
|
Serial.print(filename); |
|
|
|
|
Serial.println(F(" on SD.")); |
|
|
|
@ -550,15 +576,18 @@ bool save_sd_fx(uint8_t fx) |
|
|
|
|
Serial.println(filename); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
sysex = SD.open(filename, FILE_WRITE); |
|
|
|
|
if (sysex) |
|
|
|
|
{ |
|
|
|
|
if (write_sd_data(sysex, 0x43, (uint8_t*)&configuration.fx, sizeof(configuration.fx))) |
|
|
|
|
{ |
|
|
|
|
sysex.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
return (true); |
|
|
|
|
} |
|
|
|
|
sysex.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
@ -592,6 +621,7 @@ bool load_sd_performance(int8_t p) |
|
|
|
|
sprintf(filename, "/%s/%s%d.syx", PERFORMANCE_CONFIG_PATH, PERFORMANCE_CONFIG_NAME, p); |
|
|
|
|
|
|
|
|
|
// first check if file exists...
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
if (SD.exists(filename)) |
|
|
|
|
{ |
|
|
|
|
// ... and if: load
|
|
|
|
@ -605,6 +635,7 @@ bool load_sd_performance(int8_t p) |
|
|
|
|
{ |
|
|
|
|
get_sd_data(sysex, 0x44, (uint8_t*)&configuration.performance); |
|
|
|
|
sysex.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
|
{ |
|
|
|
@ -657,15 +688,18 @@ bool save_sd_performance(uint8_t p) |
|
|
|
|
Serial.println(filename); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
sysex = SD.open(filename, FILE_WRITE); |
|
|
|
|
if (sysex) |
|
|
|
|
{ |
|
|
|
|
if (write_sd_data(sysex, 0x44, (uint8_t*)&configuration.performance, sizeof(configuration.performance))) |
|
|
|
|
{ |
|
|
|
|
sysex.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
return (true); |
|
|
|
|
} |
|
|
|
|
sysex.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
@ -695,6 +729,7 @@ bool get_sd_data(File sysex, uint8_t format, uint8_t* conf) |
|
|
|
|
Serial.println(F(" bytes.")); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
if (sysex.read() != 0xf0) // check sysex start-byte
|
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
@ -767,6 +802,7 @@ bool get_sd_data(File sysex, uint8_t format, uint8_t* conf) |
|
|
|
|
uint8_t d = sysex.read(); |
|
|
|
|
*(conf++) = d; |
|
|
|
|
} |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("SD data loaded.")); |
|
|
|
@ -786,6 +822,7 @@ bool write_sd_data(File sysex, uint8_t format, uint8_t* data, uint16_t len) |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// write sysex start
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
sysex.write(0xf0); |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("Write SYSEX start: 0xf0")); |
|
|
|
@ -820,6 +857,8 @@ bool write_sd_data(File sysex, uint8_t format, uint8_t* data, uint16_t len) |
|
|
|
|
#endif |
|
|
|
|
// write sysex end
|
|
|
|
|
sysex.write(0xf7); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("Write SYSEX end: 0xf7")); |
|
|
|
|
#endif |
|
|
|
@ -922,6 +961,7 @@ bool get_voice_name(uint8_t b, uint8_t v, char* name, uint8_t len) |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// try to open directory
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
sysex = SD.open(filename); |
|
|
|
|
if (!sysex) |
|
|
|
|
return (false); |
|
|
|
@ -941,6 +981,7 @@ bool get_voice_name(uint8_t b, uint8_t v, char* name, uint8_t len) |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
sysex.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
return (true); |
|
|
|
|
} |
|
|
|
@ -964,6 +1005,7 @@ bool get_voice_by_bank_name(uint8_t b, const char* bank_name, uint8_t v, char* v |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// try to open directory
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
sysex = SD.open(filename); |
|
|
|
|
if (!sysex) |
|
|
|
|
return (false); |
|
|
|
@ -985,6 +1027,7 @@ bool get_voice_by_bank_name(uint8_t b, const char* bank_name, uint8_t v, char* v |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
sysex.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
return (true); |
|
|
|
|
} |
|
|
|
|