|
|
@ -33,19 +33,29 @@ |
|
|
|
|
|
|
|
|
|
|
|
extern drum_config_t drum_config[DRUM_MAX_INSTRUMENTS]; |
|
|
|
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; |
|
|
|
uint8_t config_drums = 0; |
|
|
|
|
|
|
|
char ds[26]; |
|
|
|
File json; |
|
|
|
File json; |
|
|
|
DynamicJsonDocument drums_json(4096); |
|
|
|
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(); |
|
|
|
AudioNoInterrupts(); |
|
|
|
if (SD.exists("/DRM/CFGDrums.json")) |
|
|
|
if (SD.exists(ds)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|
Serial.println(F("Found drum configuration file.")); |
|
|
|
Serial.print(F("Found drum configuration file [")); |
|
|
|
|
|
|
|
Serial.print(ds); |
|
|
|
|
|
|
|
Serial.println(F("]")); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
json = SD.open("/DRM/CFGDrums.json"); |
|
|
|
json = SD.open(ds); |
|
|
|
if (json) |
|
|
|
if (json) |
|
|
|
{ |
|
|
|
{ |
|
|
|
deserializeJson(drums_json, json); |
|
|
|
deserializeJson(drums_json, json); |
|
|
@ -57,20 +67,28 @@ uint8_t read_drum_config(void) |
|
|
|
Serial.println(config_drums); |
|
|
|
Serial.println(config_drums); |
|
|
|
if (config_drums > DRUM_MAX_INSTRUMENTS) |
|
|
|
if (config_drums > DRUM_MAX_INSTRUMENTS) |
|
|
|
Serial.println(F("*** Maximum number of drum samples exceeded! ***")); |
|
|
|
Serial.println(F("*** Maximum number of drum samples exceeded! ***")); |
|
|
|
//Serial.println(F("Drum Configuration:"));
|
|
|
|
//Serial.println(F("Drum Configuration: "));
|
|
|
|
//serializeJsonPretty(drums_json, Serial);
|
|
|
|
//serializeJsonPretty(drums_json, Serial);
|
|
|
|
//Serial.println();
|
|
|
|
//Serial.println();
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
config_drums = constrain(config_drums, 0, DRUM_MAX_INSTRUMENTS); |
|
|
|
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(); |
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
|
|
uint8_t drum = 0; |
|
|
|
uint8_t drum = 0; |
|
|
|
JsonObject root = drums_json["drums"].as<JsonObject>(); |
|
|
|
JsonObject root = drums_json["drums"].as<JsonObject>(); |
|
|
|
for (JsonPair kv : root) |
|
|
|
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)) |
|
|
|
if (!SD.exists(drum_config[drum].filename)) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
@ -235,31 +253,31 @@ uint8_t read_drum_config(void) |
|
|
|
Serial.print(F("[Drum ")); |
|
|
|
Serial.print(F("[Drum ")); |
|
|
|
Serial.print(drum, DEC); |
|
|
|
Serial.print(drum, DEC); |
|
|
|
Serial.println(F("]")); |
|
|
|
Serial.println(F("]")); |
|
|
|
Serial.print(F("drum_class=")); |
|
|
|
Serial.print(F("drum_class = ")); |
|
|
|
Serial.println(drum_config[drum].drum_class, DEC); |
|
|
|
Serial.println(drum_config[drum].drum_class, DEC); |
|
|
|
Serial.print(F("midinote=")); |
|
|
|
Serial.print(F("midinote = ")); |
|
|
|
Serial.println(drum_config[drum].midinote, DEC); |
|
|
|
Serial.println(drum_config[drum].midinote, DEC); |
|
|
|
Serial.print(F("filename=")); |
|
|
|
Serial.print(F("filename = ")); |
|
|
|
Serial.println(drum_config[drum].filename); |
|
|
|
Serial.println(drum_config[drum].filename); |
|
|
|
Serial.print(F("shortname=")); |
|
|
|
Serial.print(F("shortname = ")); |
|
|
|
Serial.println(drum_config[drum].shortname); |
|
|
|
Serial.println(drum_config[drum].shortname); |
|
|
|
Serial.print(F("pan=")); |
|
|
|
Serial.print(F("pan = ")); |
|
|
|
Serial.println(drum_config[drum].pan); |
|
|
|
Serial.println(drum_config[drum].pan); |
|
|
|
Serial.print(F("vol_max=")); |
|
|
|
Serial.print(F("vol_max = ")); |
|
|
|
Serial.println(drum_config[drum].vol_max); |
|
|
|
Serial.println(drum_config[drum].vol_max); |
|
|
|
Serial.print(F("vol_min=")); |
|
|
|
Serial.print(F("vol_min = ")); |
|
|
|
Serial.println(drum_config[drum].vol_min); |
|
|
|
Serial.println(drum_config[drum].vol_min); |
|
|
|
Serial.print(F("reverb_send=")); |
|
|
|
Serial.print(F("reverb_send = ")); |
|
|
|
Serial.println(drum_config[drum].reverb_send); |
|
|
|
Serial.println(drum_config[drum].reverb_send); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
drum++; |
|
|
|
drum++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
drum++; |
|
|
|
drum++; |
|
|
|
drum_config[drum].drum_class = DRUM_NONE; |
|
|
|
drum_config[drum].drum_class = DRUM_NONE; |
|
|
|
drum_config[drum].midinote = 0; |
|
|
|
drum_config[drum].midinote = 0; |
|
|
|
strcpy(drum_config[drum].filename, "EMPTY"); |
|
|
|
strcpy(drum_config[drum].filename, "EMPTY"); |
|
|
|
strcpy(drum_config[drum].shortname, "-"); |
|
|
|
strcpy(drum_config[drum].shortname, " - "); |
|
|
|
drum_config[drum].pan = 0.0; |
|
|
|
drum_config[drum].pan = 0.0; |
|
|
|
drum_config[drum].vol_max = 0.0; |
|
|
|
drum_config[drum].vol_max = 0.0; |
|
|
|
drum_config[drum].vol_min = 0.0; |
|
|
|
drum_config[drum].vol_min = 0.0; |
|
|
|