From f1d67892b00a9f7a075599bbdb41a17cb3125f6f Mon Sep 17 00:00:00 2001 From: positionhigh Date: Fri, 20 Aug 2021 09:17:15 +0200 Subject: [PATCH 1/5] =?UTF-8?q?Dateien=20hochladen=20nach=20=E2=80=9E?= =?UTF-8?q?=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MicroDexed.ino | 20 +++- dexed_sd.cpp | 273 +++++++++++++++++++++++++------------------------ 2 files changed, 154 insertions(+), 139 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 17999e2..86c4d1e 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -1877,7 +1877,8 @@ void check_configuration_fx(void) configuration.fx.chorus_waveform[instance_id] = constrain(configuration.fx.chorus_waveform[instance_id], CHORUS_WAVEFORM_MIN, CHORUS_WAVEFORM_MAX); configuration.fx.chorus_depth[instance_id] = constrain(configuration.fx.chorus_depth[instance_id], CHORUS_DEPTH_MIN, CHORUS_DEPTH_MAX); configuration.fx.chorus_level[instance_id] = constrain(configuration.fx.chorus_level[instance_id], CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX); - configuration.fx.delay_time[instance_id] = constrain(configuration.fx.delay_time[instance_id], DELAY_TIME_MIN, DELAY_TIME_MAX); + if (configuration.fx.delay_sync[instance_id] == 0) + configuration.fx.delay_time[instance_id] = constrain(configuration.fx.delay_time[instance_id], DELAY_TIME_MIN, DELAY_TIME_MAX); configuration.fx.delay_feedback[instance_id] = constrain(configuration.fx.delay_feedback[instance_id], DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX); configuration.fx.delay_level[instance_id] = constrain(configuration.fx.delay_level[instance_id], DELAY_LEVEL_MIN, DELAY_LEVEL_MAX); configuration.fx.delay_sync[instance_id] = constrain(configuration.fx.delay_sync[instance_id], DELAY_SYNC_MIN, DELAY_SYNC_MAX); @@ -2165,9 +2166,13 @@ void set_fx_params(void) delay_fb_mixer[instance_id]->gain(1, pseudo_log_curve(mapfloat(configuration.fx.delay_feedback[instance_id], DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX, 0.0, 1.0))); if (configuration.fx.delay_level[selected_instance_id] <= DELAY_LEVEL_MIN) delay_fx[instance_id]->disable(0); - else + else if (configuration.fx.delay_sync[instance_id] == 0) delay_fx[instance_id]->delay(0, constrain(configuration.fx.delay_time[instance_id], DELAY_TIME_MIN, DELAY_TIME_MAX) * 10); - + if (configuration.fx.delay_sync[instance_id] > 0) + { + uint16_t midi_sync_delay_time = uint16_t(60000.0 * midi_ticks_factor[configuration.fx.delay_sync[instance_id]] / seq_bpm); + delay_fx[instance_id]->delay(0, constrain(midi_sync_delay_time, DELAY_TIME_MIN, DELAY_TIME_MAX * 10)); + } // REVERB SEND reverb_mixer_r.gain(instance_id, pseudo_log_curve(mapfloat(configuration.fx.reverb_send[instance_id], REVERB_SEND_MIN, REVERB_SEND_MAX, 0.0, 1.0))); reverb_mixer_l.gain(instance_id, pseudo_log_curve(mapfloat(configuration.fx.reverb_send[instance_id], REVERB_SEND_MIN, REVERB_SEND_MAX, 0.0, 1.0))); @@ -2473,6 +2478,15 @@ void check_and_create_directories(void) #ifdef DEBUG Serial.print(F("Creating directory ")); Serial.println(tmp); +#endif + SD.mkdir(tmp); + } + sprintf(tmp, "/%s", DRUM_CONFIG_PATH); + if (!SD.exists(tmp)) + { +#ifdef DEBUG + Serial.print(F("Creating directory ")); + Serial.println(tmp); #endif SD.mkdir(tmp); } diff --git a/dexed_sd.cpp b/dexed_sd.cpp index b9291cc..eae3c84 100644 --- a/dexed_sd.cpp +++ b/dexed_sd.cpp @@ -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 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 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 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 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) From 88446cc902ee3282517d11fba1160c3c0b621364 Mon Sep 17 00:00:00 2001 From: positionhigh Date: Fri, 20 Aug 2021 09:19:51 +0200 Subject: [PATCH 4/5] =?UTF-8?q?Dateien=20hochladen=20nach=20=E2=80=9E?= =?UTF-8?q?=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UI.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/UI.hpp b/UI.hpp index 23902e1..8824ec7 100644 --- a/UI.hpp +++ b/UI.hpp @@ -6472,13 +6472,13 @@ void UI_func_load_performance(uint8_t param) lcd.print("Does not exist."); else { - load_sd_voiceconfig_json(configuration.performance.voiceconfig_number[0], 0); + load_sd_voiceconfig_json(configuration.performance.voiceconfig_number[0], 0, 0); set_voiceconfig_params(0); #if NUM_DEXED > 1 - load_sd_voiceconfig_json(configuration.performance.voiceconfig_number[1], 1); + load_sd_voiceconfig_json(configuration.performance.voiceconfig_number[1], 1, 0); set_voiceconfig_params(1); #endif - load_sd_fx_json(configuration.performance.fx_number); + load_sd_fx_json(configuration.performance.fx_number, 0); set_fx_params(); lcd.print("Done. "); @@ -6686,7 +6686,7 @@ void UI_func_load_voiceconfig(uint8_t param) if (mode > 0) { mode = 0xff; lcd.setCursor(0, 1); - if (load_sd_voiceconfig_json(configuration.performance.voiceconfig_number[selected_instance_id], selected_instance_id) == false) + if (load_sd_voiceconfig_json(configuration.performance.voiceconfig_number[selected_instance_id], selected_instance_id, 0) == false) lcd.print("Does not exist. "); else lcd.print("Done. "); @@ -6816,7 +6816,7 @@ void UI_func_save_voiceconfig(uint8_t param) sprintf(tmp, "/%s/%s%d.json", VOICE_CONFIG_PATH, VOICE_CONFIG_NAME, configuration.performance.voiceconfig_number[selected_instance_id]); SD.remove(tmp); } - save_sd_voiceconfig_json(configuration.performance.voiceconfig_number[selected_instance_id], selected_instance_id); + save_sd_voiceconfig_json(configuration.performance.voiceconfig_number[selected_instance_id], selected_instance_id, 0); lcd.show(1, 0, 16, "Done."); delay(MESSAGE_WAIT_TIME); LCDML.FUNC_goBackToMenu(); @@ -6925,7 +6925,7 @@ void UI_func_load_fx(uint8_t param) mode = 0xff; lcd.setCursor(0, 1); - if (load_sd_fx_json(configuration.performance.fx_number) == false) + if (load_sd_fx_json(configuration.performance.fx_number, 0) == false) lcd.print("Does not exist. "); else lcd.print("Done. "); @@ -7023,7 +7023,7 @@ void UI_func_save_fx(uint8_t param) sprintf(tmp, "/%s/%s%d.json", FX_CONFIG_PATH, FX_CONFIG_NAME, configuration.performance.fx_number); SD.remove(tmp); } - save_sd_fx_json(configuration.performance.fx_number); + save_sd_fx_json(configuration.performance.fx_number, 0); lcd.show(1, 0, 16, "Done."); LCDML.FUNC_goBackToMenu(); From cb4741f7b47bf5ec03da493d8a8817429aa3182f Mon Sep 17 00:00:00 2001 From: positionhigh Date: Fri, 20 Aug 2021 09:19:58 +0200 Subject: [PATCH 5/5] =?UTF-8?q?Dateien=20hochladen=20nach=20=E2=80=9E?= =?UTF-8?q?=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dexed_sd.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dexed_sd.h b/dexed_sd.h index 0e7b34b..c2c6853 100644 --- a/dexed_sd.h +++ b/dexed_sd.h @@ -55,13 +55,13 @@ bool get_sd_voice(File sysex, uint8_t voice_number, uint8_t* data); bool put_sd_voice(File sysex, uint8_t voice_number, uint8_t* data); bool save_sd_bank(const char* bank_filename, uint8_t* data); -bool load_sd_voiceconfig_json(int8_t vc, uint8_t instance_id); -bool save_sd_voiceconfig_json(uint8_t vc, uint8_t instance_id); +bool load_sd_voiceconfig_json(uint8_t vc, uint8_t instance_id, uint8_t target); +bool save_sd_voiceconfig_json(uint8_t vc, uint8_t instance_id, uint8_t target); -bool load_sd_fx_json(int8_t fx); -bool save_sd_fx_json(uint8_t fx); +bool load_sd_fx_json(uint8_t fx, uint8_t target); +bool save_sd_fx_json(uint8_t fx, uint8_t target); -bool load_sd_performance_json(int8_t p); +bool load_sd_performance_json(uint8_t p); bool save_sd_performance_json(uint8_t p); bool load_sd_seq_json(uint8_t p);