|
|
|
@ -437,6 +437,139 @@ bool save_sd_bank(const char* bank_filename, uint8_t* data) |
|
|
|
|
return (true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|
SD DRUMSETTINGS |
|
|
|
|
******************************************************************************/ |
|
|
|
|
|
|
|
|
|
bool load_sd_drumsettings_json(uint8_t number, uint8_t target) |
|
|
|
|
{ |
|
|
|
|
if (number < 0) |
|
|
|
|
return (false); |
|
|
|
|
|
|
|
|
|
number = constrain(number, 0, 99); |
|
|
|
|
|
|
|
|
|
if (sd_card > 0) |
|
|
|
|
{ |
|
|
|
|
File json; |
|
|
|
|
StaticJsonDocument<JSON_BUFFER_SIZE> data_json; |
|
|
|
|
char filename[FILENAME_LEN]; |
|
|
|
|
if (target == 0) |
|
|
|
|
sprintf(filename, "/%s/%s%d.json", DRUM_CONFIG_PATH, DRUM_CONFIG_NAME, number); |
|
|
|
|
else |
|
|
|
|
sprintf(filename, "/%s/%d-d.json", SEQ_CONFIG_PATH, number); |
|
|
|
|
// first check if file exists...
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
if (SD.exists(filename)) |
|
|
|
|
{ |
|
|
|
|
// ... and if: load
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Found drums configuration [")); |
|
|
|
|
Serial.print(filename); |
|
|
|
|
Serial.println(F("]... loading...")); |
|
|
|
|
#endif |
|
|
|
|
json = SD.open(filename); |
|
|
|
|
if (json) |
|
|
|
|
{ |
|
|
|
|
deserializeJson(data_json, json); |
|
|
|
|
json.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("Read JSON data:")); |
|
|
|
|
serializeJsonPretty(data_json, Serial); |
|
|
|
|
Serial.println(); |
|
|
|
|
#endif |
|
|
|
|
drums_volume = data_json["drums_volume"]; |
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG; i++) |
|
|
|
|
{ |
|
|
|
|
drum_config[i].pan = data_json["pan"][i] ; |
|
|
|
|
drum_config[i].vol_max = data_json["vol_max"][i] ; |
|
|
|
|
drum_config[i].vol_min = data_json["vol_min"][i] ; |
|
|
|
|
drum_config[i].reverb_send = data_json["reverb_send"][i]; |
|
|
|
|
} |
|
|
|
|
return (true); |
|
|
|
|
} |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
Serial.print(F("E : Cannot open ")); |
|
|
|
|
Serial.print(filename); |
|
|
|
|
Serial.println(F(" on SD.")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
Serial.print(F("No ")); |
|
|
|
|
Serial.print(filename); |
|
|
|
|
Serial.println(F(" available.")); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return (false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool save_sd_drumsettings_json(uint8_t number, uint8_t target) |
|
|
|
|
{ |
|
|
|
|
char filename[FILENAME_LEN]; |
|
|
|
|
number = constrain(number, 0, 99); |
|
|
|
|
|
|
|
|
|
if (sd_card > 0) |
|
|
|
|
{ |
|
|
|
|
File json; |
|
|
|
|
StaticJsonDocument<JSON_BUFFER_SIZE> data_json; |
|
|
|
|
if (target == 0) |
|
|
|
|
sprintf(filename, "/%s/%s%d.json", DRUM_CONFIG_PATH, DRUM_CONFIG_NAME, number); |
|
|
|
|
else |
|
|
|
|
sprintf(filename, "/%s/%d-d.json", SEQ_CONFIG_PATH, number); |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Saving drums config ")); |
|
|
|
|
Serial.print(number); |
|
|
|
|
Serial.print(F(" to ")); |
|
|
|
|
Serial.println(filename); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
|
|
|
|
|
if (SD.exists(filename)) { |
|
|
|
|
Serial.println("remove old drumsettings file"); |
|
|
|
|
SD.remove(filename); |
|
|
|
|
} |
|
|
|
|
json = SD.open(filename, FILE_WRITE); |
|
|
|
|
if (json) |
|
|
|
|
{ |
|
|
|
|
data_json["drums_volume"] = drums_volume; |
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG; i++) |
|
|
|
|
{ |
|
|
|
|
data_json["pan"][i] = drum_config[i].pan; |
|
|
|
|
data_json["vol_max"][i] = drum_config[i].vol_max; |
|
|
|
|
data_json["vol_min"][i] = drum_config[i].vol_min; |
|
|
|
|
data_json["reverb_send"][i] = drum_config[i].reverb_send; |
|
|
|
|
} |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("Write JSON data:")); |
|
|
|
|
serializeJsonPretty(data_json, Serial); |
|
|
|
|
Serial.println(); |
|
|
|
|
#endif |
|
|
|
|
serializeJsonPretty(data_json, json); |
|
|
|
|
json.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
return (true); |
|
|
|
|
} |
|
|
|
|
json.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("E : Cannot open ")); |
|
|
|
|
Serial.print(filename); |
|
|
|
|
Serial.println(F(" on SD.")); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
return (false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|
SD VOICECONFIG |
|
|
|
|
******************************************************************************/ |
|
|
|
@ -626,7 +759,7 @@ bool load_sd_fx_json(uint8_t fx, uint8_t target) |
|
|
|
|
{ |
|
|
|
|
if (fx < 0) |
|
|
|
|
return (false); |
|
|
|
|
|
|
|
|
|
load_sd_drumsettings_json(fx, target); |
|
|
|
|
fx = constrain(fx, 0, MAX_FX); |
|
|
|
|
|
|
|
|
|
if (sd_card > 0) |
|
|
|
@ -676,6 +809,8 @@ bool load_sd_fx_json(uint8_t fx, uint8_t target) |
|
|
|
|
configuration.fx.delay_level[i] = data_json["delay_level"][i]; |
|
|
|
|
configuration.fx.delay_sync[i] = data_json["delay_sync"][i]; |
|
|
|
|
configuration.fx.reverb_send[i] = data_json["reverb_send"][i]; |
|
|
|
|
if (configuration.fx.delay_sync[i] > 0) |
|
|
|
|
configuration.fx.delay_time[i] = 0; |
|
|
|
|
} |
|
|
|
|
configuration.fx.reverb_roomsize = data_json["reverb_roomsize"]; |
|
|
|
|
configuration.fx.reverb_damping = data_json["reverb_damping"]; |
|
|
|
@ -722,7 +857,7 @@ bool save_sd_fx_json(uint8_t fx, uint8_t target) |
|
|
|
|
char filename[FILENAME_LEN]; |
|
|
|
|
|
|
|
|
|
fx = constrain(fx, 0, MAX_FX); |
|
|
|
|
|
|
|
|
|
save_sd_drumsettings_json(fx, target); |
|
|
|
|
if (sd_card > 0) |
|
|
|
|
{ |
|
|
|
|
File json; |
|
|
|
@ -795,145 +930,12 @@ bool save_sd_fx_json(uint8_t fx, uint8_t target) |
|
|
|
|
return (false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool load_sd_drumsettings_json(uint8_t number, uint8_t target) |
|
|
|
|
{ |
|
|
|
|
if (number < 0) |
|
|
|
|
return (false); |
|
|
|
|
|
|
|
|
|
number = constrain(number, 0, 99); |
|
|
|
|
|
|
|
|
|
if (sd_card > 0) |
|
|
|
|
{ |
|
|
|
|
File json; |
|
|
|
|
StaticJsonDocument<JSON_BUFFER_SIZE> data_json; |
|
|
|
|
char filename[FILENAME_LEN]; |
|
|
|
|
if (target == 0) |
|
|
|
|
sprintf(filename, "/%s/%s%d.json", SEQ_CONFIG_PATH, DRUM_CONFIG_NAME, number); //change to DRUM
|
|
|
|
|
else |
|
|
|
|
sprintf(filename, "/%s/%d-d.json", SEQ_CONFIG_PATH, number); |
|
|
|
|
// first check if file exists...
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
if (SD.exists(filename)) |
|
|
|
|
{ |
|
|
|
|
// ... and if: load
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Found drums configuration [")); |
|
|
|
|
Serial.print(filename); |
|
|
|
|
Serial.println(F("]... loading...")); |
|
|
|
|
#endif |
|
|
|
|
json = SD.open(filename); |
|
|
|
|
if (json) |
|
|
|
|
{ |
|
|
|
|
deserializeJson(data_json, json); |
|
|
|
|
json.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("Read JSON data:")); |
|
|
|
|
serializeJsonPretty(data_json, Serial); |
|
|
|
|
Serial.println(); |
|
|
|
|
#endif |
|
|
|
|
drums_volume = data_json["drums_volume"]; |
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG; i++) |
|
|
|
|
{ |
|
|
|
|
drum_config[i].pan = data_json["pan"][i] ; |
|
|
|
|
drum_config[i].vol_max = data_json["vol_max"][i] ; |
|
|
|
|
drum_config[i].vol_min = data_json["vol_min"][i] ; |
|
|
|
|
drum_config[i].reverb_send = data_json["reverb_send"][i]; |
|
|
|
|
} |
|
|
|
|
return (true); |
|
|
|
|
} |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
Serial.print(F("E : Cannot open ")); |
|
|
|
|
Serial.print(filename); |
|
|
|
|
Serial.println(F(" on SD.")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
Serial.print(F("No ")); |
|
|
|
|
Serial.print(filename); |
|
|
|
|
Serial.println(F(" available.")); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool save_sd_drumsettings_json(uint8_t number, uint8_t target) |
|
|
|
|
{ |
|
|
|
|
char filename[FILENAME_LEN]; |
|
|
|
|
number = constrain(number, 0, 99); |
|
|
|
|
|
|
|
|
|
if (sd_card > 0) |
|
|
|
|
{ |
|
|
|
|
File json; |
|
|
|
|
StaticJsonDocument<JSON_BUFFER_SIZE> data_json; |
|
|
|
|
if (target == 0) |
|
|
|
|
sprintf(filename, "/%s/%s%d-d.json", DRUM_CONFIG_PATH, DRUM_CONFIG_NAME, number); |
|
|
|
|
else |
|
|
|
|
sprintf(filename, "/%s/%d-d.json", SEQ_CONFIG_PATH, number); |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Saving drums config ")); |
|
|
|
|
Serial.print(number); |
|
|
|
|
Serial.print(F(" to ")); |
|
|
|
|
Serial.println(filename); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
|
|
|
|
|
if (SD.exists(filename)) { |
|
|
|
|
Serial.println("remove old drumsettings file"); |
|
|
|
|
SD.remove(filename); |
|
|
|
|
} |
|
|
|
|
json = SD.open(filename, FILE_WRITE); |
|
|
|
|
if (json) |
|
|
|
|
{ |
|
|
|
|
data_json["drums_volume"] = drums_volume; |
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG; i++) |
|
|
|
|
{ |
|
|
|
|
data_json["pan"][i] = drum_config[i].pan; |
|
|
|
|
data_json["vol_max"][i] = drum_config[i].vol_max; |
|
|
|
|
data_json["vol_min"][i] = drum_config[i].vol_min; |
|
|
|
|
data_json["reverb_send"][i] = drum_config[i].reverb_send; |
|
|
|
|
} |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("Write JSON data:")); |
|
|
|
|
serializeJsonPretty(data_json, Serial); |
|
|
|
|
Serial.println(); |
|
|
|
|
#endif |
|
|
|
|
serializeJsonPretty(data_json, json); |
|
|
|
|
json.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
return (true); |
|
|
|
|
} |
|
|
|
|
json.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("E : Cannot open ")); |
|
|
|
|
Serial.print(filename); |
|
|
|
|
Serial.println(F(" on SD.")); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
return (false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool save_sd_seq_json(uint8_t seq_number) |
|
|
|
|
{ |
|
|
|
|
char filename[FILENAME_LEN]; |
|
|
|
|
int count = 0; |
|
|
|
|
seq_number = constrain(seq_number, 0, 99); |
|
|
|
|
|
|
|
|
|
save_sd_drumsettings_json(seq_number, 1); // Destination (1) = sequencer path
|
|
|
|
|
|
|
|
|
|
sprintf(filename, "/%s/%d-fx.json", SEQ_CONFIG_PATH, seq_number); |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
@ -1072,7 +1074,6 @@ bool load_sd_seq_json(uint8_t seq_number) |
|
|
|
|
|
|
|
|
|
seq_number = constrain(seq_number, 0, 99); |
|
|
|
|
|
|
|
|
|
load_sd_drumsettings_json(seq_number, 1); |
|
|
|
|
load_sd_fx_json(seq_number, 1); |
|
|
|
|
|
|
|
|
|
if (sd_card > 0) |
|
|
|
|