|
|
@ -537,55 +537,69 @@ bool save_sd_drumsettings_json(uint8_t number) |
|
|
|
File json; |
|
|
|
File json; |
|
|
|
StaticJsonDocument<JSON_BUFFER_SIZE> data_json; |
|
|
|
StaticJsonDocument<JSON_BUFFER_SIZE> data_json; |
|
|
|
|
|
|
|
|
|
|
|
sprintf(filename, "/%s/%d/%s.json", PERFORMANCE_CONFIG_PATH, number, DRUMS_CONFIG_NAME); |
|
|
|
if (check_performance_directory(number)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
sprintf(filename, "/%s/%d/%s.json", PERFORMANCE_CONFIG_PATH, number, DRUMS_CONFIG_NAME); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.print(F("Saving drums config ")); |
|
|
|
Serial.print(F("Saving drums config ")); |
|
|
|
Serial.print(number); |
|
|
|
Serial.print(number); |
|
|
|
Serial.print(F(" to ")); |
|
|
|
Serial.print(F(" to ")); |
|
|
|
Serial.println(filename); |
|
|
|
Serial.println(filename); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
AudioNoInterrupts(); |
|
|
|
AudioNoInterrupts(); |
|
|
|
if (SD.exists(filename)) { |
|
|
|
if (SD.exists(filename)) { |
|
|
|
Serial.println("remove old drumsettings file"); |
|
|
|
Serial.println("remove old drumsettings file"); |
|
|
|
SD.begin(); |
|
|
|
SD.begin(); |
|
|
|
SD.remove(filename); |
|
|
|
SD.remove(filename); |
|
|
|
} |
|
|
|
} |
|
|
|
json = SD.open(filename, FILE_WRITE); |
|
|
|
json = SD.open(filename, FILE_WRITE); |
|
|
|
if (json) |
|
|
|
if (json) |
|
|
|
{ |
|
|
|
|
|
|
|
data_json["drums_volume"] = drums_volume; |
|
|
|
|
|
|
|
for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG - 1; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
data_json["note"][i] = get_sample_note(i); |
|
|
|
data_json["drums_volume"] = drums_volume; |
|
|
|
data_json["pitch"][i] = get_sample_pitch(i); |
|
|
|
for (uint8_t i = 0; i < NUM_DRUMSET_CONFIG - 1; i++) |
|
|
|
data_json["p_offset"][i] = get_sample_p_offset(i); |
|
|
|
{ |
|
|
|
data_json["pan"][i] = get_sample_pan(i); |
|
|
|
data_json["note"][i] = get_sample_note(i); |
|
|
|
data_json["vol_max"][i] = get_sample_vol_max(i); |
|
|
|
data_json["pitch"][i] = get_sample_pitch(i); |
|
|
|
data_json["vol_min"][i] = get_sample_vol_min(i); |
|
|
|
data_json["p_offset"][i] = get_sample_p_offset(i); |
|
|
|
data_json["reverb_send"][i] = get_sample_reverb_send(i); |
|
|
|
data_json["pan"][i] = get_sample_pan(i); |
|
|
|
|
|
|
|
data_json["vol_max"][i] = get_sample_vol_max(i); |
|
|
|
|
|
|
|
data_json["vol_min"][i] = get_sample_vol_min(i); |
|
|
|
|
|
|
|
data_json["reverb_send"][i] = get_sample_reverb_send(i); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
Serial.println(F("Write JSON data:")); |
|
|
|
|
|
|
|
serializeJsonPretty(data_json, Serial); |
|
|
|
|
|
|
|
Serial.println(); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
serializeJsonPretty(data_json, json); |
|
|
|
|
|
|
|
json.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
return (true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.println(F("Write JSON data:")); |
|
|
|
Serial.print(F("E : Cannot open ")); |
|
|
|
serializeJsonPretty(data_json, Serial); |
|
|
|
Serial.print(filename); |
|
|
|
Serial.println(); |
|
|
|
Serial.println(F(" on SD.")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
serializeJsonPretty(data_json, json); |
|
|
|
AudioInterrupts(); |
|
|
|
json.close(); |
|
|
|
return (false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
AudioInterrupts(); |
|
|
|
AudioInterrupts(); |
|
|
|
return (true); |
|
|
|
return (false); |
|
|
|
} |
|
|
|
} |
|
|
|
json.close(); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.println(F("E: SD card not available")); |
|
|
|
Serial.print(F("E : Cannot open ")); |
|
|
|
|
|
|
|
Serial.print(filename); |
|
|
|
|
|
|
|
Serial.println(F(" on SD.")); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
return (false); |
|
|
|
return (false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -694,7 +708,7 @@ bool save_sd_voiceconfig_json(uint8_t vc, uint8_t instance_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
File json; |
|
|
|
File json; |
|
|
|
StaticJsonDocument<JSON_BUFFER_SIZE> data_json; |
|
|
|
StaticJsonDocument<JSON_BUFFER_SIZE> data_json; |
|
|
|
sprintf(filename, "/%s/%d/%s%d.json", PERFORMANCE_CONFIG_PATH, vc, VOICE_CONFIG_NAME, instance_id); |
|
|
|
sprintf(filename, "/%s/%d/%s%d.json", PERFORMANCE_CONFIG_PATH, vc, VOICE_CONFIG_NAME, instance_id + 1); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.print(F("Saving voice config ")); |
|
|
|
Serial.print(F("Saving voice config ")); |
|
|
@ -1134,7 +1148,7 @@ bool save_sd_seq_sub_patterns_json(uint8_t seq_number) |
|
|
|
{ |
|
|
|
{ |
|
|
|
File json; |
|
|
|
File json; |
|
|
|
StaticJsonDocument<JSON_BUFFER_SIZE> data_json; |
|
|
|
StaticJsonDocument<JSON_BUFFER_SIZE> data_json; |
|
|
|
sprintf(filename, "/%s/%d/%s.json", PERFORMANCE_CONFIG_PATH, seq_number, VELOCITY_CONFIG_NAME); |
|
|
|
sprintf(filename, "/%s/%d/%s.json", PERFORMANCE_CONFIG_PATH, seq_number, PATTERN_CONFIG_NAME); |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.print(F("Saving sequencer patterns ")); |
|
|
|
Serial.print(F("Saving sequencer patterns ")); |
|
|
|
Serial.print(seq_number); |
|
|
|
Serial.print(seq_number); |
|
|
@ -1192,22 +1206,24 @@ bool save_sd_performance_json(uint8_t seq_number) |
|
|
|
handleStop(); |
|
|
|
handleStop(); |
|
|
|
} |
|
|
|
} |
|
|
|
dac_mute(); |
|
|
|
dac_mute(); |
|
|
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
AudioNoInterrupts(); |
|
|
|
|
|
|
|
|
|
|
|
save_sd_seq_sub_vel_json(seq_number); |
|
|
|
save_sd_seq_sub_vel_json(seq_number); |
|
|
|
save_sd_seq_sub_patterns_json(seq_number); |
|
|
|
save_sd_seq_sub_patterns_json(seq_number); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.print(F("Write performance config ")); |
|
|
|
Serial.print(F("Write performance config ")); |
|
|
|
Serial.print(seq_number); |
|
|
|
Serial.println(seq_number); |
|
|
|
Serial.print(F(" ")); |
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
save_sd_fx_json(seq_number); |
|
|
|
save_sd_fx_json(seq_number); |
|
|
|
for (uint8_t i = 0; i < MAX_DEXED; i++) |
|
|
|
for (uint8_t i = 0; i < MAX_DEXED; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
sprintf(filename, "/%s/%d/%s%d.json", PERFORMANCE_CONFIG_PATH, seq_number, VOICE_CONFIG_NAME, i); |
|
|
|
sprintf(filename, "/%s/%d/%s%d.json", PERFORMANCE_CONFIG_PATH, seq_number, VOICE_CONFIG_NAME, i); |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.print(F("Write Voice-Config for sequencer")); |
|
|
|
Serial.print(F("Write Voice-Config for sequencer")); |
|
|
|
Serial.print(filename); |
|
|
|
Serial.println(filename); |
|
|
|
Serial.print(F(" ")); |
|
|
|
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
save_sd_voiceconfig_json(seq_number, i); |
|
|
|
save_sd_voiceconfig_json(seq_number, i); |
|
|
|
} |
|
|
|
} |
|
|
@ -1226,7 +1242,6 @@ bool save_sd_performance_json(uint8_t seq_number) |
|
|
|
int columns = sizeof(seq_patternchain[0]); |
|
|
|
int columns = sizeof(seq_patternchain[0]); |
|
|
|
int rows = total / columns; |
|
|
|
int rows = total / columns; |
|
|
|
Serial.print(F(" ")); |
|
|
|
Serial.print(F(" ")); |
|
|
|
SD.begin(); |
|
|
|
|
|
|
|
SD.remove(filename); |
|
|
|
SD.remove(filename); |
|
|
|
json = SD.open(filename, FILE_WRITE); |
|
|
|
json = SD.open(filename, FILE_WRITE); |
|
|
|
if (json) |
|
|
|
if (json) |
|
|
@ -1290,14 +1305,56 @@ bool save_sd_performance_json(uint8_t seq_number) |
|
|
|
} |
|
|
|
} |
|
|
|
json.close(); |
|
|
|
json.close(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
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.")); |
|
|
|
|
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool check_performance_directory(uint8_t seq_number) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
char dir[CONFIG_FILENAME_LEN]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sd_card > 0) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
sprintf(dir, "/%s/%d", PERFORMANCE_CONFIG_PATH, seq_number); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
|
|
|
SD.begin(); |
|
|
|
|
|
|
|
if (!SD.exists(dir)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
if (SD.mkdir(dir)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Serial.print(F("Creating directory ")); |
|
|
|
|
|
|
|
Serial.println(dir); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Serial.print(F("E: Cannot create ")); |
|
|
|
|
|
|
|
Serial.println(dir); |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
return (false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
SD.mkdir(dir); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
return (true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Serial.println(F("E: SD card not available")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
return (false); |
|
|
|
return (false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|