Several fixes for loading/storing voice/fx/performance.

pull/32/head
Holger Wirtz 5 years ago
parent 9677c3788b
commit b219264fce
  1. 61
      MicroDexed.ino
  2. 75
      UI.hpp
  3. 4
      config.h
  4. 17
      dexed_sd.cpp

@ -383,6 +383,8 @@ void setup()
} }
else else
{ {
check_and_create_directories();
for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++)
{ {
// read all bank names // read all bank names
@ -1767,6 +1769,65 @@ uint8_t check_sd_cards(void)
return (ret); return (ret);
} }
void check_and_create_directories(void)
{
if (sd_card > 0)
{
uint8_t i;
char tmp[FILENAME_LEN];
#ifdef DEBUG
Serial.println(F("Directory check... "));
#endif
// create directories for banks
for (i = 0; i < MAX_BANKS; i++)
{
sprintf(tmp, "/%d", i);
if (!SD.exists(tmp))
{
#ifdef DEBUG
Serial.print(F("Creating directory "));
Serial.println(tmp);
#endif
SD.mkdir(tmp);
}
}
// create directories for confgiuration files
sprintf(tmp, "/%s", VOICE_CONFIG_PATH);
if (!SD.exists(tmp))
{
#ifdef DEBUG
Serial.print(F("Creating directory "));
Serial.println(tmp);
#endif
SD.mkdir(tmp);
}
sprintf(tmp, "/%s", PERFORMANCE_CONFIG_PATH);
if (!SD.exists(tmp))
{
#ifdef DEBUG
Serial.print(F("Creating directory "));
Serial.println(tmp);
#endif
SD.mkdir(tmp);
}
sprintf(tmp, "/%s", FX_CONFIG_PATH);
if (!SD.exists(tmp))
{
#ifdef DEBUG
Serial.print(F("Creating directory "));
Serial.println(tmp);
#endif
SD.mkdir(tmp);
}
}
#ifdef DEBUG
#else
Serial.println(F("No SD card for directory check available."));
#endif
}
/****************************************************************************** /******************************************************************************
DEBUG HELPER DEBUG HELPER
******************************************************************************/ ******************************************************************************/

@ -3350,18 +3350,16 @@ void UI_func_voice_select(uint8_t param)
encoderDir[ENC_R].reset(); encoderDir[ENC_R].reset();
if (instance_id == 0) if (instance_id == 0)
{ {
eeprom_update_var(offsetof(configuration_s, performance.voice[0]), configuration.performance.voice[0], "configuration.performance.voice[0]"); //eeprom_update_var(offsetof(configuration_s, performance.voice[0]), configuration.performance.voice[0], "configuration.performance.voice[0]");
eeprom_update_var(offsetof(configuration_s, performance.bank[0]), configuration.performance.bank[0], "configuration.performance.bank[0]"); //eeprom_update_var(offsetof(configuration_s, performance.bank[0]), configuration.performance.bank[0], "configuration.performance.bank[0]");
show_configuration(); EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, performance.voice[0]), configuration.performance.voice[0]);
EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, performance.bank[0]), configuration.performance.bank[0]);
//EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, performance.voice[0]), configuration.performance.voice[0]);
//EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, performance.bank[0]), configuration.performance.bank[0]);
} }
#if NUM_DEXED > 1 #if NUM_DEXED > 1
else else
{ {
EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, performance.voice[1]), configuration.performance.voice[1]); EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, performance.voice[0]), configuration.performance.voice[1]);
EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, performance.bank[1]), configuration.performance.bank[1]); EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, performance.bank[0]), configuration.performance.bank[1]);
} }
#endif #endif
} }
@ -3451,13 +3449,23 @@ void UI_func_load_performance(uint8_t param)
if (load_sd_performance(configuration.sys.performance_number) == false) if (load_sd_performance(configuration.sys.performance_number) == false)
lcd.print("Does not exist."); lcd.print("Does not exist.");
else else
{
load_sd_voice(configuration.performance.bank[0], configuration.performance.voice[0], 0);
load_sd_voiceconfig(configuration.performance.voiceconfig_number[0], 0);
set_voiceconfig_params(0);
#if NUM_DEXED > 1
set_voiceconfig_params(1);
load_sd_voice(configuration.performance.bank[0], configuration.performance.voice[1], 1);
load_sd_voiceconfig(configuration.performance.voiceconfig_number[1], 1);
#endif
load_sd_fx(configuration.performance.fx_number);
set_fx_params();
lcd.print("Done. "); lcd.print("Done. ");
}
delay(500); delay(500);
if (LCDML.MENU_getLastActivFunctionID() < 0xff) LCDML.FUNC_goBackToMenu();
LCDML.OTHER_jumpToID(LCDML.MENU_getLastActivFunctionID());
else
LCDML.OTHER_setCursorToID(LCDML.MENU_getLastCursorPositionID());
} }
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
@ -3513,7 +3521,7 @@ void UI_func_save_performance(uint8_t param)
} }
char tmp[FILENAME_LEN]; char tmp[FILENAME_LEN];
sprintf(tmp, "/%s%d.syx", PERFORMANCE_CONFIG_NAME, configuration.sys.performance_number); sprintf(tmp, "/%s/%s%d.syx", PERFORMANCE_CONFIG_PATH, PERFORMANCE_CONFIG_NAME, configuration.sys.performance_number);
if (SD.exists(tmp)) if (SD.exists(tmp))
overwrite = true; overwrite = true;
else else
@ -3554,7 +3562,7 @@ void UI_func_save_performance(uint8_t param)
if (yesno == true) if (yesno == true)
{ {
char tmp[FILENAME_LEN]; char tmp[FILENAME_LEN];
sprintf(tmp, "/%s%d.syx", PERFORMANCE_CONFIG_NAME, configuration.sys.performance_number); sprintf(tmp, "/%s/%s%d.syx", PERFORMANCE_CONFIG_PATH, PERFORMANCE_CONFIG_NAME, configuration.sys.performance_number);
SD.remove(tmp); SD.remove(tmp);
} }
save_sd_performance(configuration.performance.fx_number); save_sd_performance(configuration.performance.fx_number);
@ -3563,17 +3571,14 @@ void UI_func_save_performance(uint8_t param)
delay(500); delay(500);
} }
if (LCDML.MENU_getLastActivFunctionID() < 0xff) LCDML.FUNC_goBackToMenu();
LCDML.OTHER_jumpToID(LCDML.MENU_getLastActivFunctionID());
else
LCDML.OTHER_setCursorToID(LCDML.MENU_getLastCursorPositionID());
} }
} }
if (mode == 0) if (mode == 0)
{ {
char tmp[FILENAME_LEN]; char tmp[FILENAME_LEN];
sprintf(tmp, "/%s%d.syx", PERFORMANCE_CONFIG_NAME, configuration.sys.performance_number); sprintf(tmp, "/%s/%s%d.syx", PERFORMANCE_CONFIG_PATH, PERFORMANCE_CONFIG_NAME, configuration.sys.performance_number);
if (SD.exists(tmp)) if (SD.exists(tmp))
overwrite = true; overwrite = true;
else else
@ -3679,10 +3684,7 @@ void UI_func_load_voiceconfig(uint8_t param)
delay(500); delay(500);
if (LCDML.MENU_getLastActivFunctionID() < 0xff) LCDML.FUNC_goBackToMenu();
LCDML.OTHER_jumpToID(LCDML.MENU_getLastActivFunctionID());
else
LCDML.OTHER_setCursorToID(LCDML.MENU_getLastCursorPositionID());
} }
if (mode == 0) if (mode == 0)
@ -3759,7 +3761,7 @@ void UI_func_save_voiceconfig(uint8_t param)
} }
char tmp[FILENAME_LEN]; char tmp[FILENAME_LEN];
sprintf(tmp, "/%s%d.syx", VOICE_CONFIG_NAME, configuration.performance.voiceconfig_number[instance_id]); sprintf(tmp, "/%s/%s%d.syx", VOICE_CONFIG_PATH, VOICE_CONFIG_NAME, configuration.performance.voiceconfig_number[instance_id]);
if (SD.exists(tmp)) if (SD.exists(tmp))
overwrite = true; overwrite = true;
else else
@ -3805,7 +3807,7 @@ void UI_func_save_voiceconfig(uint8_t param)
if (yesno == true) if (yesno == true)
{ {
char tmp[FILENAME_LEN]; char tmp[FILENAME_LEN];
sprintf(tmp, "/%s%d.syx", VOICE_CONFIG_NAME, configuration.performance.voiceconfig_number[instance_id]); sprintf(tmp, "/%s/%s%d.syx", VOICE_CONFIG_PATH, VOICE_CONFIG_NAME, configuration.performance.voiceconfig_number[instance_id]);
SD.remove(tmp); SD.remove(tmp);
} }
save_sd_voiceconfig(configuration.performance.voiceconfig_number[instance_id], instance_id); save_sd_voiceconfig(configuration.performance.voiceconfig_number[instance_id], instance_id);
@ -3814,10 +3816,7 @@ void UI_func_save_voiceconfig(uint8_t param)
delay(500); delay(500);
} }
if (LCDML.MENU_getLastActivFunctionID() < 0xff) LCDML.FUNC_goBackToMenu();
LCDML.OTHER_jumpToID(LCDML.MENU_getLastActivFunctionID());
else
LCDML.OTHER_setCursorToID(LCDML.MENU_getLastCursorPositionID());
} }
} }
@ -3829,7 +3828,7 @@ void UI_func_save_voiceconfig(uint8_t param)
else if (mode == 1) else if (mode == 1)
{ {
char tmp[FILENAME_LEN]; char tmp[FILENAME_LEN];
sprintf(tmp, "/%s%d.syx", VOICE_CONFIG_NAME, configuration.performance.voiceconfig_number[instance_id]); sprintf(tmp, "/%s/%s%d.syx", VOICE_CONFIG_PATH, VOICE_CONFIG_NAME, configuration.performance.voiceconfig_number[instance_id]);
if (SD.exists(tmp)) if (SD.exists(tmp))
overwrite = true; overwrite = true;
else else
@ -3917,10 +3916,7 @@ void UI_func_load_fx(uint8_t param)
delay(500); delay(500);
if (LCDML.MENU_getLastActivFunctionID() < 0xff) LCDML.FUNC_goBackToMenu();
LCDML.OTHER_jumpToID(LCDML.MENU_getLastActivFunctionID());
else
LCDML.OTHER_setCursorToID(LCDML.MENU_getLastCursorPositionID());
} }
lcd.setCursor(0, 1); lcd.setCursor(0, 1);
@ -3976,7 +3972,7 @@ void UI_func_save_fx(uint8_t param)
} }
char tmp[FILENAME_LEN]; char tmp[FILENAME_LEN];
sprintf(tmp, "/%s%d.syx", FX_CONFIG_NAME, configuration.performance.fx_number); sprintf(tmp, "/%s/%s%d.syx", FX_CONFIG_PATH, FX_CONFIG_NAME, configuration.performance.fx_number);
if (SD.exists(tmp)) if (SD.exists(tmp))
overwrite = true; overwrite = true;
else else
@ -4017,7 +4013,7 @@ void UI_func_save_fx(uint8_t param)
if (yesno == true) if (yesno == true)
{ {
char tmp[FILENAME_LEN]; char tmp[FILENAME_LEN];
sprintf(tmp, "/%s%d.syx", FX_CONFIG_NAME, configuration.performance.fx_number); sprintf(tmp, "/%s/%s%d.syx", FX_CONFIG_PATH, FX_CONFIG_NAME, configuration.performance.fx_number);
SD.remove(tmp); SD.remove(tmp);
} }
save_sd_fx(configuration.performance.fx_number); save_sd_fx(configuration.performance.fx_number);
@ -4026,17 +4022,14 @@ void UI_func_save_fx(uint8_t param)
delay(500); delay(500);
} }
if (LCDML.MENU_getLastActivFunctionID() < 0xff) LCDML.FUNC_goBackToMenu();
LCDML.OTHER_jumpToID(LCDML.MENU_getLastActivFunctionID());
else
LCDML.OTHER_setCursorToID(LCDML.MENU_getLastCursorPositionID());
} }
} }
if (mode == 0) if (mode == 0)
{ {
char tmp[FILENAME_LEN]; char tmp[FILENAME_LEN];
sprintf(tmp, "/%s%d.syx", FX_CONFIG_NAME, configuration.performance.fx_number); sprintf(tmp, "/%s/%s%d.syx", FX_CONFIG_PATH, FX_CONFIG_NAME, configuration.performance.fx_number);
if (SD.exists(tmp)) if (SD.exists(tmp))
overwrite = true; overwrite = true;
else else

@ -227,8 +227,12 @@
#define BANK_NAME_LEN 13 // FAT12 filenames (plus '\0') #define BANK_NAME_LEN 13 // FAT12 filenames (plus '\0')
#define VOICE_NAME_LEN 11 // 10 (plus '\0') #define VOICE_NAME_LEN 11 // 10 (plus '\0')
#define FILENAME_LEN BANK_NAME_LEN + VOICE_NAME_LEN #define FILENAME_LEN BANK_NAME_LEN + VOICE_NAME_LEN
#define FX_CONFIG_PATH "FXCFG"
#define FX_CONFIG_NAME "FXCFG" #define FX_CONFIG_NAME "FXCFG"
#define PERFORMANCE_CONFIG_PATH "PCFG"
#define PERFORMANCE_CONFIG_NAME "PCFG" #define PERFORMANCE_CONFIG_NAME "PCFG"
#define VOICE_CONFIG_PATH "VCFG"
#define VOICE_CONFIG_NAME "VCFG" #define VOICE_CONFIG_NAME "VCFG"
//************************************************************************************************* //*************************************************************************************************

@ -184,7 +184,7 @@ bool load_sd_voiceconfig(uint8_t vc, uint8_t instance_id)
File sysex; File sysex;
char filename[FILENAME_LEN]; char filename[FILENAME_LEN];
sprintf(filename, "/%s%d.syx", VOICE_CONFIG_NAME, vc); sprintf(filename, "/%s/%s%d.syx", VOICE_CONFIG_PATH, VOICE_CONFIG_NAME, vc);
// first check if file exists... // first check if file exists...
if (SD.exists(filename)) if (SD.exists(filename))
@ -234,7 +234,7 @@ bool save_sd_voiceconfig(uint8_t vc, uint8_t instance_id)
File sysex; File sysex;
char filename[FILENAME_LEN]; char filename[FILENAME_LEN];
sprintf(filename, "/%s%d.syx", VOICE_CONFIG_NAME, vc); sprintf(filename, "/%s/%s%d.syx", VOICE_CONFIG_PATH, VOICE_CONFIG_NAME, vc);
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Saving voice config ")); Serial.print(F("Saving voice config "));
@ -281,7 +281,7 @@ bool load_sd_fx(uint8_t fx)
File sysex; File sysex;
char filename[FILENAME_LEN]; char filename[FILENAME_LEN];
sprintf(filename, "/%s%d.syx", FX_CONFIG_NAME, fx); sprintf(filename, "/%s/%s%d.syx", FX_CONFIG_PATH, FX_CONFIG_NAME, fx);
// first check if file exists... // first check if file exists...
if (SD.exists(filename)) if (SD.exists(filename))
@ -332,7 +332,7 @@ bool save_sd_fx(uint8_t fx)
File sysex; File sysex;
char filename[FILENAME_LEN]; char filename[FILENAME_LEN];
sprintf(filename, "/%s%d.syx", FX_CONFIG_NAME, fx); sprintf(filename, "/%s/%s%d.syx", FX_CONFIG_PATH, FX_CONFIG_NAME, fx);
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Saving fx config ")); Serial.print(F("Saving fx config "));
@ -377,7 +377,7 @@ bool load_sd_performance(uint8_t p)
File sysex; File sysex;
char filename[FILENAME_LEN]; char filename[FILENAME_LEN];
sprintf(filename, "/%s%d.syx", PERFORMANCE_CONFIG_NAME, p); sprintf(filename, "/%s/%s%d.syx", PERFORMANCE_CONFIG_PATH, PERFORMANCE_CONFIG_NAME, p);
// first check if file exists... // first check if file exists...
if (SD.exists(filename)) if (SD.exists(filename))
@ -426,7 +426,7 @@ bool save_sd_performance(uint8_t p)
File sysex; File sysex;
char filename[FILENAME_LEN]; char filename[FILENAME_LEN];
sprintf(filename, "/%s%d.syx", PERFORMANCE_CONFIG_NAME, p); sprintf(filename, "/%s/%s%d.syx", PERFORMANCE_CONFIG_PATH, PERFORMANCE_CONFIG_NAME, p);
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Saving performance config ")); Serial.print(F("Saving performance config "));
@ -778,11 +778,6 @@ uint8_t get_bank_names(uint8_t instance_id)
File entry = root.openNextFile(); File entry = root.openNextFile();
if (!entry.isDirectory()) if (!entry.isDirectory())
{ {
while ((strncmp(entry.name(), VOICE_CONFIG_NAME, sizeof(VOICE_CONFIG_NAME) - 1) == 0))
{
entry = root.openNextFile();
}
strcpy(bank_names[instance_id][bank_counter], entry.name()); strcpy(bank_names[instance_id][bank_counter], entry.name());
#ifdef DEBUG #ifdef DEBUG
Serial.print(F("Found bank [")); Serial.print(F("Found bank ["));

Loading…
Cancel
Save