From 6993cdcb0b69456e6d69af6afcbb9397ca0f5d67 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Sun, 1 Jan 2023 10:42:44 +0100 Subject: [PATCH] Several fixes fir loading and saving performances. Additional small fixes. --- MicroDexed.ino | 5 +- UI.hpp | 73 +++++++++++-------- config.h | 5 +- dexed_sd.cpp | 4 +- disp_plus.h | 2 +- .../TeensyVariablePlayback/src/playresmp.h | 4 +- 6 files changed, 53 insertions(+), 40 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 59541cb..7e3d49d 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -1986,8 +1986,6 @@ void check_configuration_epiano(void) { configuration.epiano.midi_channel = constrain(configuration.epiano.midi_channel, EP_MIDI_CHANNEL_MIN, EP_MIDI_CHANNEL_MAX); } - - void check_configuration_drums(void) { configuration.drums.main_vol = constrain(configuration.drums.main_vol, DRUMS_MAIN_VOL_MIN, DRUMS_MAIN_VOL_MAX); configuration.drums.midi_channel = constrain(configuration.drums.midi_channel, DRUMS_MIDI_CHANNEL_MIN, DRUMS_MIDI_CHANNEL_MAX); @@ -2108,6 +2106,9 @@ void init_configuration(void) { #endif #endif + strlcpy(configuration.performance.name, "INIT Perf", sizeof(configuration.performance.name)); + strlcpy(configuration.performance.name_temp, "INIT Perf", sizeof(configuration.performance.name_temp)); + eeprom_update(); } diff --git a/UI.hpp b/UI.hpp index c2597b8..66f02d3 100644 --- a/UI.hpp +++ b/UI.hpp @@ -4056,7 +4056,7 @@ void _check_display_name_min_max(uint8_t input_mode, uint8_t input_type, uint8_t #endif void UI_func_drum_midi_channel(uint8_t param) { -#if NUM_DRUMS > 0 +#if NUM_DRUMS == 0 if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -4109,7 +4109,7 @@ void UI_func_drum_midi_channel(uint8_t param) { } void UI_func_drums_main_volume(uint8_t param) { -#if NUM_DRUMS > 0 +#if NUM_DRUMS == 0 if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -4148,7 +4148,7 @@ void UI_func_drums_main_volume(uint8_t param) { } void UI_func_drum_pitch(uint8_t param) { -#if NUM_DRUMS > 0 +#if NUM_DRUMS == 0 if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -4225,7 +4225,7 @@ void UI_func_drum_pitch(uint8_t param) { } void UI_func_drum_vol_min_max(uint8_t param) { -#if NUM_DRUMS > 0 +#if NUM_DRUMS == 0 if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -4334,7 +4334,7 @@ void UI_func_drum_vol_min_max(uint8_t param) { } void UI_func_drum_pan(uint8_t param) { -#if NUM_DRUMS > 0 +#if NUM_DRUMS == 0 if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -4412,7 +4412,7 @@ void UI_func_drum_pan(uint8_t param) { } void UI_func_drum_reverb_send(uint8_t param) { -#if NUM_DRUMS > 0 +#if NUM_DRUMS == 0 if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -4490,7 +4490,7 @@ void UI_func_drum_reverb_send(uint8_t param) { } void UI_func_drum_midi_note(uint8_t param) { -#if NUM_DRUMS > 0 +#if NUM_DRUMS == 0 if (LCDML.FUNC_setup()) // ****** SETUP ********* { encoderDir[ENC_R].reset(); @@ -4605,9 +4605,11 @@ void UI_func_save_performance(uint8_t param) { if (configuration.performance.name_temp[0] != 0) display.show(1, 5, 11, configuration.performance.name_temp); else - display.print(" -- DATA --"); - } + display.print("-- DATA -- "); + } else + display.print("-- EMPTY --"); } + if (LCDML.FUNC_loop()) // ****** LOOP ********* { if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { @@ -4629,8 +4631,7 @@ void UI_func_save_performance(uint8_t param) { } else { mode = 0xff; if (overwrite == false || yesno == true) { - display.show(1, 0, 16, "Done."); - delay(MESSAGE_WAIT_TIME); + display.show(1, 0, 16, "Writing..."); LCDML.FUNC_goBackToMenu(); } else if (overwrite == true && yesno == false) { char tmp[10]; @@ -4661,9 +4662,8 @@ void UI_func_save_performance(uint8_t param) { get_sd_performance_name_json(temp_int); if (configuration.performance.name_temp[0] != 0) display.show(1, 5, 11, configuration.performance.name_temp); - else - display.print("-- DATA --"); - } else display.print(" "); + else display.print("-- DATA -- "); + } else display.print("-- EMPTY --"); } else if (mode < 0xff) { display.setCursor(12, 1); if (yesno == true) { @@ -4672,7 +4672,7 @@ void UI_func_save_performance(uint8_t param) { display.print(F("NO ")); } } - encoderDir[ENC_R].reset(); + //encoderDir[ENC_R].reset(); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -4689,18 +4689,28 @@ void UI_func_save_performance(uint8_t param) { void UI_func_load_performance(uint8_t param) { static uint8_t mode; + if (LCDML.FUNC_setup()) // ****** SETUP ********* { - char tmp[10]; + char tmp[CONFIG_FILENAME_LEN]; temp_int = 0; mode = 0; encoderDir[ENC_R].reset(); display.setCursor(0, 0); display.print(F("Load Performance ")); + display.setCursor(0, 1); - snprintf_P(tmp, sizeof(tmp), PSTR("[%2d]"), param); + snprintf_P(tmp, sizeof(tmp), PSTR("[%2d]"), temp_int); display.print(tmp); + if (check_sd_performance_exists(temp_int)) { + get_sd_performance_name_json(temp_int); + if (configuration.performance.name_temp[0] != 0) + display.show(1, 5, 11, configuration.performance.name_temp); + else + display.print(" -- DATA -- "); + } else display.print(" -- EMPTY --"); } + if (LCDML.FUNC_loop()) // ****** LOOP ********* { if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { @@ -4712,27 +4722,29 @@ void UI_func_load_performance(uint8_t param) { mode = 0xff; display.setCursor(0, 1); if (load_sd_performance_json(temp_int) == false) - display.print("Does not exist."); + display.print("Does not exist. "); else { + display.print("Loading... "); load_sd_performance_json(temp_int); - display.print("Done. "); } delay(MESSAGE_WAIT_TIME); LCDML.FUNC_goBackToMenu(); } + + display.setCursor(0, 1); + char tmp[10]; + snprintf_P(tmp, sizeof(tmp), PSTR("[%2d]"), temp_int); + display.print(tmp); + if (check_sd_performance_exists(temp_int)) { + get_sd_performance_name_json(temp_int); + if (configuration.performance.name_temp[0] != 0) + display.show(1, 5, 11, configuration.performance.name_temp); + else + display.print(" -- DATA -- "); + } else display.print(" -- EMPTY --"); } - display.setCursor(0, 1); - char tmp[10]; - snprintf_P(tmp, sizeof(tmp), PSTR("[%2d]"), temp_int); - display.print(tmp); - if (check_sd_performance_exists(temp_int)) { - get_sd_performance_name_json(temp_int); - if (configuration.performance.name_temp[0] != 0) - display.show(1, 5, 11, configuration.performance.name_temp); - else - display.print(" -- DATA --"); - } else display.print(" "); } + if (LCDML.FUNC_close()) // ****** STABLE END ********* { if (mode < 0xff) { @@ -4740,7 +4752,6 @@ void UI_func_load_performance(uint8_t param) { delay(MESSAGE_WAIT_TIME); } else { configuration.sys.performance_number = temp_int; - save_sd_sys_json(); encoderDir[ENC_R].reset(); } } diff --git a/config.h b/config.h index 448317b..901c088 100644 --- a/config.h +++ b/config.h @@ -319,6 +319,7 @@ #define FILENAME_LEN BANK_NAME_LEN + VOICE_NAME_LEN #define CONFIG_FILENAME_LEN 50 #define DRUM_NAME_LEN 9 +#define PERFORMANCE_NAME_LEN 12 #define FAV_CONFIG_PATH "FAVCFG" #define FAV_CONFIG_NAME "FAVCFG" @@ -907,8 +908,8 @@ typedef struct sys_s { } sys_t; typedef struct performance_s { - char name[FILENAME_LEN]; - char name_temp[FILENAME_LEN]; + char name[PERFORMANCE_NAME_LEN]; + char name_temp[PERFORMANCE_NAME_LEN]; } performance_t; typedef struct drums_s { diff --git a/dexed_sd.cpp b/dexed_sd.cpp index 6fa88dd..1ce4420 100644 --- a/dexed_sd.cpp +++ b/dexed_sd.cpp @@ -1258,9 +1258,9 @@ void get_sd_performance_name_json(uint8_t number) { #ifdef DEBUG Serial.print(F("Get performance name for ")); Serial.print(number); - Serial.print(F(": ")); + Serial.print(F(": [")); Serial.print(configuration.performance.name_temp); - Serial.println(); + Serial.println("]"); #endif } } diff --git a/disp_plus.h b/disp_plus.h index b082e9d..b50bd55 100644 --- a/disp_plus.h +++ b/disp_plus.h @@ -66,7 +66,7 @@ private: s += field_size - l; strncpy(s, str, l); - s[l] = '\0'; + //s[l] = '\0'; //setCursor(pos_x * getMaxCharWidth(), pos_y * getMaxCharHeight()); this->setCursor(pos_x, pos_y); diff --git a/third-party/TeensyVariablePlayback/src/playresmp.h b/third-party/TeensyVariablePlayback/src/playresmp.h index 12df93f..984c5c8 100644 --- a/third-party/TeensyVariablePlayback/src/playresmp.h +++ b/third-party/TeensyVariablePlayback/src/playresmp.h @@ -91,7 +91,7 @@ class AudioPlayResmp : public AudioStream if (_numChannels == -1) return; - unsigned int i, n; + unsigned int n; audio_block_t *blocks[_numChannels]; int16_t *data[_numChannels]; // only update if we're playing @@ -136,4 +136,4 @@ class AudioPlayResmp : public AudioStream TResamplingReader *reader; }; -#endif // TEENSY_RESAMPLING_SDREADER_PLAYRESMP_H \ No newline at end of file +#endif // TEENSY_RESAMPLING_SDREADER_PLAYRESMP_H