|
|
|
@ -33,19 +33,29 @@ |
|
|
|
|
|
|
|
|
|
extern drum_config_t drum_config[DRUM_MAX_INSTRUMENTS]; |
|
|
|
|
|
|
|
|
|
uint8_t read_drum_config(void) |
|
|
|
|
uint8_t read_drum_config(const char* drumset) |
|
|
|
|
{ |
|
|
|
|
uint8_t config_drums = 0; |
|
|
|
|
char ds[26]; |
|
|
|
|
File json; |
|
|
|
|
DynamicJsonDocument drums_json(4096); |
|
|
|
|
|
|
|
|
|
sprintf(ds, "/DRM/%s.json", drumset); |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.print(F("Searching for drum configuration file [")); |
|
|
|
|
Serial.print(ds); |
|
|
|
|
Serial.println(F("]")); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
if (SD.exists("/DRM/CFGDrums.json")) |
|
|
|
|
if (SD.exists(ds)) |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
Serial.println(F("Found drum configuration file.")); |
|
|
|
|
Serial.print(F("Found drum configuration file [")); |
|
|
|
|
Serial.print(ds); |
|
|
|
|
Serial.println(F("]")); |
|
|
|
|
#endif |
|
|
|
|
json = SD.open("/DRM/CFGDrums.json"); |
|
|
|
|
json = SD.open(ds); |
|
|
|
|
if (json) |
|
|
|
|
{ |
|
|
|
|
deserializeJson(drums_json, json); |
|
|
|
@ -64,13 +74,21 @@ uint8_t read_drum_config(void) |
|
|
|
|
config_drums = constrain(config_drums, 0, DRUM_MAX_INSTRUMENTS); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#ifdef DEBUG |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
Serial.print(F("Drum configuration file [")); |
|
|
|
|
Serial.print(ds); |
|
|
|
|
Serial.println(F("] not found!")); |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
uint8_t drum = 0; |
|
|
|
|
JsonObject root = drums_json["drums"].as<JsonObject>(); |
|
|
|
|
for (JsonPair kv : root) |
|
|
|
|
{ |
|
|
|
|
sprintf(drum_config[drum].filename, "/drm/%s.wav", kv.key().c_str()); |
|
|
|
|
sprintf(drum_config[drum].filename, "%s/%s.wav", ds, kv.key().c_str()); |
|
|
|
|
if (!SD.exists(drum_config[drum].filename)) |
|
|
|
|
{ |
|
|
|
|
#ifdef DEBUG |
|
|
|
|