|
|
|
@ -38,6 +38,7 @@ using namespace TeensyTimerTool; |
|
|
|
|
#include "drums.h" |
|
|
|
|
extern void set_drums_volume(float vol); |
|
|
|
|
extern drum_config_t drum_config[]; |
|
|
|
|
extern custom_midi_map_t custom_midi_map[NUM_CUSTOM_MIDI_MAPPINGS]; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
extern void init_MIDI_send_CC(void); |
|
|
|
@ -434,6 +435,148 @@ bool save_sd_bank(const char* bank_filename, uint8_t* data) |
|
|
|
|
return (true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|
SD DRUM CUSTOM MAPPINGS |
|
|
|
|
******************************************************************************/ |
|
|
|
|
|
|
|
|
|
bool load_sd_drummappings_json(uint8_t number) |
|
|
|
|
{ |
|
|
|
|
if (number < 0) |
|
|
|
|
return (false); |
|
|
|
|
|
|
|
|
|
number = constrain(number, PERFORMANCE_NUM_MIN, PERFORMANCE_NUM_MAX); |
|
|
|
|
|
|
|
|
|
if (sd_card > 0) |
|
|
|
|
{ |
|
|
|
|
File json; |
|
|
|
|
StaticJsonDocument<JSON_BUFFER_SIZE> data_json; |
|
|
|
|
char filename[CONFIG_FILENAME_LEN]; |
|
|
|
|
|
|
|
|
|
sprintf(filename, "/%s/%d/%s.json", PERFORMANCE_CONFIG_PATH, number, DRUMS_MAPPING_NAME); |
|
|
|
|
|
|
|
|
|
// first check if file exists...
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
if (SD.exists(filename)) |
|
|
|
|
{ |
|
|
|
|
// ... and if: load
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Found drum mapping [")); |
|
|
|
|
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 |
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < NUM_CUSTOM_MIDI_MAPPINGS - 1; i++) |
|
|
|
|
{ |
|
|
|
|
custom_midi_map[i].type = data_json["type"][i]; |
|
|
|
|
custom_midi_map[i].in = data_json["in"][i]; |
|
|
|
|
custom_midi_map[i].out = data_json["out"][i]; |
|
|
|
|
custom_midi_map[i].channel = data_json["channel"][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_drummappings_json(uint8_t number) |
|
|
|
|
{ |
|
|
|
|
char filename[CONFIG_FILENAME_LEN]; |
|
|
|
|
number = constrain(number, 0, 99); |
|
|
|
|
|
|
|
|
|
if (sd_card > 0) |
|
|
|
|
{ |
|
|
|
|
File json; |
|
|
|
|
StaticJsonDocument<JSON_BUFFER_SIZE> data_json; |
|
|
|
|
|
|
|
|
|
if (check_performance_directory(number)) |
|
|
|
|
{ |
|
|
|
|
sprintf(filename, "/%s/%d/%s.json", PERFORMANCE_CONFIG_PATH, number, DRUMS_MAPPING_NAME); |
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Saving drum mapping ")); |
|
|
|
|
Serial.print(number); |
|
|
|
|
Serial.print(F(" to ")); |
|
|
|
|
Serial.println(filename); |
|
|
|
|
#endif |
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
if (SD.exists(filename)) { |
|
|
|
|
Serial.println("remove old drum mapping file"); |
|
|
|
|
SD.begin(); |
|
|
|
|
SD.remove(filename); |
|
|
|
|
} |
|
|
|
|
json = SD.open(filename, FILE_WRITE); |
|
|
|
|
if (json) |
|
|
|
|
{ |
|
|
|
|
for (uint8_t i = 0; i < NUM_CUSTOM_MIDI_MAPPINGS - 1; i++) |
|
|
|
|
{ |
|
|
|
|
data_json["type"][i] = custom_midi_map[i].type; |
|
|
|
|
data_json["in"][i] = custom_midi_map[i].in; |
|
|
|
|
data_json["out"][i] = custom_midi_map[i].out; |
|
|
|
|
data_json["channel"][i] = custom_midi_map[i].channel; |
|
|
|
|
} |
|
|
|
|
#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 |
|
|
|
|
Serial.print(F("E : Cannot open ")); |
|
|
|
|
Serial.print(filename); |
|
|
|
|
Serial.println(F(" on SD.")); |
|
|
|
|
#endif |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
return (false); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
return (false); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
Serial.println(F("E: SD card not available")); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
return (false); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
|
SD DRUMSETTINGS |
|
|
|
|
******************************************************************************/ |
|
|
|
@ -532,7 +675,9 @@ bool save_sd_drumsettings_json(uint8_t number) |
|
|
|
|
#endif |
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
if (SD.exists(filename)) { |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println("remove old drumsettings file"); |
|
|
|
|
#endif |
|
|
|
|
SD.begin(); |
|
|
|
|
SD.remove(filename); |
|
|
|
|
} |
|
|
|
@ -1371,6 +1516,7 @@ bool save_sd_performance_json(uint8_t number) |
|
|
|
|
|
|
|
|
|
save_sd_seq_sub_vel_json(number); |
|
|
|
|
save_sd_seq_sub_patterns_json(number); |
|
|
|
|
save_sd_drummappings_json(number); |
|
|
|
|
save_sd_fx_json(number); |
|
|
|
|
save_sd_epiano_json(number); |
|
|
|
|
|
|
|
|
@ -1456,6 +1602,7 @@ bool save_sd_performance_json(uint8_t number) |
|
|
|
|
return (true); |
|
|
|
|
} |
|
|
|
|
json.close(); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
} |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
else |
|
|
|
@ -1463,6 +1610,7 @@ bool save_sd_performance_json(uint8_t number) |
|
|
|
|
Serial.print(F("E : Cannot open ")); |
|
|
|
|
Serial.print(filename); |
|
|
|
|
Serial.println(F(" on SD.")); |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
@ -1718,6 +1866,7 @@ bool load_sd_performance_json(uint8_t number) |
|
|
|
|
load_sd_seq_sub_vel_json(number); |
|
|
|
|
load_sd_fx_json(number); |
|
|
|
|
load_sd_epiano_json(number); |
|
|
|
|
load_sd_drummappings_json(number); |
|
|
|
|
|
|
|
|
|
if (sd_card > 0) |
|
|
|
|
{ |
|
|
|
|