|
|
@ -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)); |
|
|
|
get_bank_name(b, bank_name, sizeof(bank_name)); |
|
|
|
sprintf(filename, "/%d/%s.syx", b, bank_name); |
|
|
|
sprintf(filename, "/%d/%s.syx", b, bank_name); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
sysex = SD.open(filename); |
|
|
|
sysex = SD.open(filename); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
if (!sysex) |
|
|
|
if (!sysex) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
@ -81,8 +83,9 @@ bool load_sd_voice(uint8_t b, uint8_t v, uint8_t instance_id) |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
configuration.dexed[instance_id].transpose = MicroDexed[instance_id]->getTranspose(); |
|
|
|
configuration.dexed[instance_id].transpose = MicroDexed[instance_id]->getTranspose(); |
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
sysex.close(); |
|
|
|
sysex.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
|
|
uint8_t data_copy[155]; |
|
|
|
uint8_t data_copy[155]; |
|
|
|
MicroDexed[instance_id]->getVoiceData(data_copy); |
|
|
|
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 |
|
|
|
else |
|
|
|
Serial.println(F("E : Cannot load voice data")); |
|
|
|
Serial.println(F("E : Cannot load voice data")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
sysex.close(); |
|
|
|
sysex.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return (false); |
|
|
|
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)); |
|
|
|
get_bank_name(b, bank_name, sizeof(bank_name)); |
|
|
|
sprintf(filename, "/%d/%s.syx", b, bank_name); |
|
|
|
sprintf(filename, "/%d/%s.syx", b, bank_name); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
sysex = SD.open(filename, FILE_WRITE); |
|
|
|
sysex = SD.open(filename, FILE_WRITE); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
if (!sysex) |
|
|
|
if (!sysex) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef DEBUG |
|
|
|
#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.print(voice_name); |
|
|
|
Serial.println(F("]")); |
|
|
|
Serial.println(F("]")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
sysex.close(); |
|
|
|
sysex.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
|
|
return (true); |
|
|
|
return (true); |
|
|
|
} |
|
|
|
} |
|
|
@ -148,7 +157,9 @@ bool save_sd_voice(uint8_t b, uint8_t v, uint8_t instance_id) |
|
|
|
else |
|
|
|
else |
|
|
|
Serial.println(F("E : Cannot load voice data")); |
|
|
|
Serial.println(F("E : Cannot load voice data")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
sysex.close(); |
|
|
|
sysex.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return (false); |
|
|
|
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; |
|
|
|
int32_t bulk_checksum_calc = 0; |
|
|
|
int8_t bulk_checksum; |
|
|
|
int8_t bulk_checksum; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
if (sysex.size() != 4104) // check sysex size
|
|
|
|
if (sysex.size() != 4104) // check sysex size
|
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef DEBUG |
|
|
|
#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 -= d; |
|
|
|
} |
|
|
|
} |
|
|
|
bulk_checksum_calc &= 0x7f; |
|
|
|
bulk_checksum_calc &= 0x7f; |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.print(F("Bulk checksum : 0x")); |
|
|
|
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; |
|
|
|
uint16_t n; |
|
|
|
int32_t bulk_checksum_calc = 0; |
|
|
|
int32_t bulk_checksum_calc = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
sysex.seek(0); |
|
|
|
sysex.seek(0); |
|
|
|
|
|
|
|
|
|
|
|
if (sysex.size() != 4104) // check sysex size
|
|
|
|
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.seek(4102); // Bulk checksum
|
|
|
|
sysex.write(bulk_checksum_calc & 0x7f); |
|
|
|
sysex.write(bulk_checksum_calc & 0x7f); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.print(F("Bulk checksum : 0x")); |
|
|
|
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
|
|
|
|
// first remove old bank
|
|
|
|
sscanf(bank_filename, "/%d/%s", &bank_number, tmp); |
|
|
|
sscanf(bank_filename, "/%d/%s", &bank_number, tmp); |
|
|
|
sprintf(tmp, "/%d", bank_number); |
|
|
|
sprintf(tmp, "/%d", bank_number); |
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
root = SD.open(tmp); |
|
|
|
root = SD.open(tmp); |
|
|
|
while (42 == 42) |
|
|
|
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 = SD.open(bank_filename, FILE_WRITE); |
|
|
|
root.write(data, 4104); |
|
|
|
root.write(data, 4104); |
|
|
|
root.close(); |
|
|
|
root.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.println(F(" done.")); |
|
|
|
Serial.println(F(" done.")); |
|
|
|
#endif |
|
|
|
#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); |
|
|
|
sprintf(filename, "/%s/%s%d.syx", VOICE_CONFIG_PATH, VOICE_CONFIG_NAME, vc); |
|
|
|
|
|
|
|
|
|
|
|
// first check if file exists...
|
|
|
|
// first check if file exists...
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
if (SD.exists(filename)) |
|
|
|
if (SD.exists(filename)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// ... and if: load
|
|
|
|
// ... 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]); |
|
|
|
get_sd_data(sysex, 0x42, (uint8_t*)&configuration.dexed[instance_id]); |
|
|
|
set_voiceconfig_params(instance_id); |
|
|
|
set_voiceconfig_params(instance_id); |
|
|
|
sysex.close(); |
|
|
|
sysex.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
|
|
return (true); |
|
|
|
return (true); |
|
|
|
} |
|
|
|
} |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
Serial.print(F("E : Cannot open ")); |
|
|
|
Serial.print(F("E : Cannot open ")); |
|
|
|
Serial.print(filename); |
|
|
|
Serial.print(filename); |
|
|
|
Serial.println(F(" on SD.")); |
|
|
|
Serial.println(F(" on SD.")); |
|
|
@ -452,15 +472,18 @@ bool save_sd_voiceconfig(uint8_t vc, uint8_t instance_id) |
|
|
|
Serial.println(filename); |
|
|
|
Serial.println(filename); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
sysex = SD.open(filename, FILE_WRITE); |
|
|
|
sysex = SD.open(filename, FILE_WRITE); |
|
|
|
if (sysex) |
|
|
|
if (sysex) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (write_sd_data(sysex, 0x42, (uint8_t*)&configuration.dexed[instance_id], sizeof(configuration.dexed[instance_id]))) |
|
|
|
if (write_sd_data(sysex, 0x42, (uint8_t*)&configuration.dexed[instance_id], sizeof(configuration.dexed[instance_id]))) |
|
|
|
{ |
|
|
|
{ |
|
|
|
sysex.close(); |
|
|
|
sysex.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
return (true); |
|
|
|
return (true); |
|
|
|
} |
|
|
|
} |
|
|
|
sysex.close(); |
|
|
|
sysex.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
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); |
|
|
|
sprintf(filename, "/%s/%s%d.syx", FX_CONFIG_PATH, FX_CONFIG_NAME, fx); |
|
|
|
|
|
|
|
|
|
|
|
// first check if file exists...
|
|
|
|
// first check if file exists...
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
if (SD.exists(filename)) |
|
|
|
if (SD.exists(filename)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// ... and if: load
|
|
|
|
// ... and if: load
|
|
|
@ -507,12 +531,14 @@ bool load_sd_fx(int8_t fx) |
|
|
|
get_sd_data(sysex, 0x43, (uint8_t*)&configuration.fx); |
|
|
|
get_sd_data(sysex, 0x43, (uint8_t*)&configuration.fx); |
|
|
|
set_fx_params(); |
|
|
|
set_fx_params(); |
|
|
|
sysex.close(); |
|
|
|
sysex.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
|
|
return (true); |
|
|
|
return (true); |
|
|
|
} |
|
|
|
} |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
Serial.print(F("E : Cannot open ")); |
|
|
|
Serial.print(F("E : Cannot open ")); |
|
|
|
Serial.print(filename); |
|
|
|
Serial.print(filename); |
|
|
|
Serial.println(F(" on SD.")); |
|
|
|
Serial.println(F(" on SD.")); |
|
|
@ -550,15 +576,18 @@ bool save_sd_fx(uint8_t fx) |
|
|
|
Serial.println(filename); |
|
|
|
Serial.println(filename); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
sysex = SD.open(filename, FILE_WRITE); |
|
|
|
sysex = SD.open(filename, FILE_WRITE); |
|
|
|
if (sysex) |
|
|
|
if (sysex) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (write_sd_data(sysex, 0x43, (uint8_t*)&configuration.fx, sizeof(configuration.fx))) |
|
|
|
if (write_sd_data(sysex, 0x43, (uint8_t*)&configuration.fx, sizeof(configuration.fx))) |
|
|
|
{ |
|
|
|
{ |
|
|
|
sysex.close(); |
|
|
|
sysex.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
return (true); |
|
|
|
return (true); |
|
|
|
} |
|
|
|
} |
|
|
|
sysex.close(); |
|
|
|
sysex.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
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); |
|
|
|
sprintf(filename, "/%s/%s%d.syx", PERFORMANCE_CONFIG_PATH, PERFORMANCE_CONFIG_NAME, p); |
|
|
|
|
|
|
|
|
|
|
|
// first check if file exists...
|
|
|
|
// first check if file exists...
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
if (SD.exists(filename)) |
|
|
|
if (SD.exists(filename)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// ... and if: load
|
|
|
|
// ... and if: load
|
|
|
@ -605,6 +635,7 @@ bool load_sd_performance(int8_t p) |
|
|
|
{ |
|
|
|
{ |
|
|
|
get_sd_data(sysex, 0x44, (uint8_t*)&configuration.performance); |
|
|
|
get_sd_data(sysex, 0x44, (uint8_t*)&configuration.performance); |
|
|
|
sysex.close(); |
|
|
|
sysex.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
|
|
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) |
|
|
|
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); |
|
|
|
Serial.println(filename); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
sysex = SD.open(filename, FILE_WRITE); |
|
|
|
sysex = SD.open(filename, FILE_WRITE); |
|
|
|
if (sysex) |
|
|
|
if (sysex) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (write_sd_data(sysex, 0x44, (uint8_t*)&configuration.performance, sizeof(configuration.performance))) |
|
|
|
if (write_sd_data(sysex, 0x44, (uint8_t*)&configuration.performance, sizeof(configuration.performance))) |
|
|
|
{ |
|
|
|
{ |
|
|
|
sysex.close(); |
|
|
|
sysex.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
return (true); |
|
|
|
return (true); |
|
|
|
} |
|
|
|
} |
|
|
|
sysex.close(); |
|
|
|
sysex.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
@ -695,6 +729,7 @@ bool get_sd_data(File sysex, uint8_t format, uint8_t* conf) |
|
|
|
Serial.println(F(" bytes.")); |
|
|
|
Serial.println(F(" bytes.")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
if (sysex.read() != 0xf0) // check sysex start-byte
|
|
|
|
if (sysex.read() != 0xf0) // check sysex start-byte
|
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
@ -767,6 +802,7 @@ bool get_sd_data(File sysex, uint8_t format, uint8_t* conf) |
|
|
|
uint8_t d = sysex.read(); |
|
|
|
uint8_t d = sysex.read(); |
|
|
|
*(conf++) = d; |
|
|
|
*(conf++) = d; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.println(F("SD data loaded.")); |
|
|
|
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 |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
// write sysex start
|
|
|
|
// write sysex start
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
sysex.write(0xf0); |
|
|
|
sysex.write(0xf0); |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.println(F("Write SYSEX start: 0xf0")); |
|
|
|
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 |
|
|
|
#endif |
|
|
|
// write sysex end
|
|
|
|
// write sysex end
|
|
|
|
sysex.write(0xf7); |
|
|
|
sysex.write(0xf7); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.println(F("Write SYSEX end: 0xf7")); |
|
|
|
Serial.println(F("Write SYSEX end: 0xf7")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
@ -922,6 +961,7 @@ bool get_voice_name(uint8_t b, uint8_t v, char* name, uint8_t len) |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
// try to open directory
|
|
|
|
// try to open directory
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
sysex = SD.open(filename); |
|
|
|
sysex = SD.open(filename); |
|
|
|
if (!sysex) |
|
|
|
if (!sysex) |
|
|
|
return (false); |
|
|
|
return (false); |
|
|
@ -941,6 +981,7 @@ bool get_voice_name(uint8_t b, uint8_t v, char* name, uint8_t len) |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
sysex.close(); |
|
|
|
sysex.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
|
|
return (true); |
|
|
|
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 |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
// try to open directory
|
|
|
|
// try to open directory
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
sysex = SD.open(filename); |
|
|
|
sysex = SD.open(filename); |
|
|
|
if (!sysex) |
|
|
|
if (!sysex) |
|
|
|
return (false); |
|
|
|
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 |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
sysex.close(); |
|
|
|
sysex.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
|
|
return (true); |
|
|
|
return (true); |
|
|
|
} |
|
|
|
} |
|
|
|