From 111d5e27223f554df02ad216f00f8eca9be88663 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Tue, 10 Sep 2019 09:54:34 +0200 Subject: [PATCH] Added menus for chorus feedback and waveform. --- MicroMDAEPiano.ino | 2 + UI.hpp | 192 ++++++++++++++++++++++++++++++++++++++------- config.h | 10 +++ 3 files changed, 177 insertions(+), 27 deletions(-) diff --git a/MicroMDAEPiano.ino b/MicroMDAEPiano.ino index 29e1390..8fb6f66 100644 --- a/MicroMDAEPiano.ino +++ b/MicroMDAEPiano.ino @@ -126,6 +126,8 @@ config_t configuration = { ENC_CHORUS_FREQUENCY_DEFAULT, // chorus_frequency ENC_CHORUS_DELAY_DEFAULT, // chorus_delay ENC_CHORUS_INTENSITY_DEFAULT, // chorus_intensity + ENC_CHORUS_FEEDBACK_DEFAULT, // chorus_feedback + ENC_CHORUS_WAVEFORM_DEFAULT, // chorus_waveform ENC_CHORUS_LEVEL_DEFAULT, // chorus_level ENC_BASS_LR_LEVEL_DEFAULT, // bass_lr_level ENC_BASS_MONO_LEVEL_DEFAULT, // bass_mono_level diff --git a/UI.hpp b/UI.hpp index 084d28e..76b993d 100644 --- a/UI.hpp +++ b/UI.hpp @@ -28,7 +28,7 @@ const uint8_t MAX_VARIABLES = 5; ///< @note Default: 5 /// Configures the number of available functions per line. - const uint8_t MAX_FUNCTIONS = 40; ///< @note Default: 8 + const uint8_t MAX_FUNCTIONS = 42; ///< @note Default: 8 /// Configures the number of available lines per screen. const uint8_t MAX_LINES = 20; ///< @note Default: 12 @@ -37,7 +37,7 @@ const uint8_t MAX_SCREENS = 2; ///< @note Default: 14 /// Configures the number of available menus per menus system. - const uint8_t MAX_MENUS = 43; ///< @note Default: 8 + const uint8_t MAX_MENUS = 45; ///< @note Default: 8 */ @@ -56,7 +56,7 @@ int32_t encoder_value[NUM_ENCODER]; Bounce but[NUM_ENCODER] = {Bounce(BUT_L_PIN, BUT_DEBOUNCE_MS), Bounce(BUT_R_PIN, BUT_DEBOUNCE_MS)}; elapsedMillis back_to_main; -#define NUM_MENUS 43 +#define NUM_MENUS 45 #define MAIN 0 /*************************************/ @@ -92,20 +92,22 @@ elapsedMillis back_to_main; #define CHORUS_FREQ 28 #define CHORUS_DELAY 29 #define CHORUS_INTENSITY 30 -#define CHORUS_LEVEL 31 -#define BASS_LR_LEVEL 32 -#define BASS_MONO_LEVEL 33 -#define EQ_BASS 34 -#define EQ_TREBLE 35 +#define CHORUS_FEEDBACK 31 +#define CHORUS_WAVEFORM 32 +#define CHORUS_LEVEL 33 +#define BASS_LR_LEVEL 34 +#define BASS_MONO_LEVEL 35 +#define EQ_BASS 36 +#define EQ_TREBLE 37 /*************************************/ -#define LOUDNESS 36 -#define MIDI_CHANNEL 37 -#define MIDI_SOFT_THRU 38 -#define MAX_POLY 39 +#define LOUDNESS 38 +#define MIDI_CHANNEL 39 +#define MIDI_SOFT_THRU 40 +#define MAX_POLY 41 /*************************************/ -#define STORE_QUESTION 40 +#define STORE_QUESTION 42 /*************************************/ -#define MASTER_VOLUME 41 +#define MASTER_VOLUME 43 /*************************************/ int8_t menu_position[NUM_MENUS]; @@ -423,7 +425,7 @@ LiquidMenu velocity_sense_menu(lcd); /****************************************** EFFECTS MENU ******************************************/ -#define NUM_EFFECTS_MENUS 20 +#define NUM_EFFECTS_MENUS 22 const char effects_text1[] PROGMEM = "Pan/Trem Freq."; const char effects_text2[] PROGMEM = "Pan/Trem Level"; const char effects_text3[] PROGMEM = "Overdrive"; @@ -439,11 +441,13 @@ const char effects_text12[] PROGMEM = "Rev. Level"; const char effects_text13[] PROGMEM = "Chorus Freq."; const char effects_text14[] PROGMEM = "Chorus Delay"; const char effects_text15[] PROGMEM = "Chorus Intens."; -const char effects_text16[] PROGMEM = "Chorus Level"; -const char effects_text17[] PROGMEM = "Bass LR Level"; -const char effects_text18[] PROGMEM = "Bass M Level"; -const char effects_text19[] PROGMEM = "EQ Bass"; -const char effects_text20[] PROGMEM = "EQ Treble"; +const char effects_text16[] PROGMEM = "Chorus FB"; +const char effects_text17[] PROGMEM = "Chorus Wave"; +const char effects_text18[] PROGMEM = "Chorus Level"; +const char effects_text19[] PROGMEM = "Bass LR Level"; +const char effects_text20[] PROGMEM = "Bass M Level"; +const char effects_text21[] PROGMEM = "EQ Bass"; +const char effects_text22[] PROGMEM = "EQ Treble"; LiquidLine effects_line1(1, 0, effects_text1); LiquidLine effects_line2(1, 1, effects_text2); LiquidLine effects_line3(1, 1, effects_text3); @@ -464,6 +468,8 @@ LiquidLine effects_line17(1, 1, effects_text17); LiquidLine effects_line18(1, 1, effects_text18); LiquidLine effects_line19(1, 1, effects_text19); LiquidLine effects_line20(1, 1, effects_text20); +LiquidLine effects_line21(1, 1, effects_text21); +LiquidLine effects_line22(1, 1, effects_text22); LiquidScreen effects_screen; LiquidMenu effects_menu(lcd); @@ -619,6 +625,26 @@ LiquidLine chorus_intensity_line2(1, 1, configuration.chorus_intensity); LiquidScreen chorus_intensity_screen; LiquidMenu chorus_intensity_menu(lcd); +/****************************************** + CHORUS_FEEDBACK MENU + ******************************************/ +#define NUM_CHORUS_FEEDBACK_MENUS 1 +const char chorus_feedback_text1[] PROGMEM = "Chorus FB"; +LiquidLine chorus_feedback_line1(1, 0, chorus_feedback_text1); +LiquidLine chorus_feedback_line2(1, 1, configuration.chorus_feedback); +LiquidScreen chorus_feedback_screen; +LiquidMenu chorus_feedback_menu(lcd); + +/****************************************** + CHORUS_WAVEFORM MENU + ******************************************/ +#define NUM_CHORUS_WAVEFORM_MENUS 1 +const char chorus_waveform_text1[] PROGMEM = "Chorus Wave"; +LiquidLine chorus_waveform_line1(1, 0, chorus_waveform_text1); +LiquidLine chorus_waveform_line2(1, 1, configuration.chorus_waveform); +LiquidScreen chorus_waveform_screen; +LiquidMenu chorus_waveform_menu(lcd); + /****************************************** CHORUS_LEVEL MENU ******************************************/ @@ -1124,6 +1150,34 @@ void callback_chorus_intensity_function(void) menu_system.update(); } +void callback_chorus_feedback_function(void) +{ +#ifdef SHOW_DEBUG + Serial.println(F("callback_chorus_feedback_function")); +#endif + Serial.println("D-1");delay(100); + menu_system.change_menu(chorus_feedback_menu); + Serial.println("D0");delay(100); + menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; + encoder_value[RIGHT_ENCODER] = configuration.chorus_feedback; + enc[RIGHT_ENCODER].write(configuration.chorus_feedback, ENC_CHORUS_FEEDBACK_MIN, ENC_CHORUS_FEEDBACK_MAX); + Serial.println("D1");delay(100); + menu_system.update(); + Serial.println("D2"); +} + +void callback_chorus_waveform_function(void) +{ +#ifdef SHOW_DEBUG + Serial.println(F("callback_chorus_waveform_function")); +#endif + menu_system.change_menu(chorus_waveform_menu); + menu_position[EFFECTS] = encoder_value[RIGHT_ENCODER]; + encoder_value[RIGHT_ENCODER] = configuration.chorus_waveform; + enc[RIGHT_ENCODER].write(configuration.chorus_waveform, ENC_CHORUS_WAVEFORM_MIN, ENC_CHORUS_WAVEFORM_MAX); + menu_system.update(); +} + void callback_chorus_level_function(void) { #ifdef SHOW_DEBUG @@ -1509,6 +1563,8 @@ void init_menus(void) effects_screen.add_line(effects_line18); effects_screen.add_line(effects_line19); effects_screen.add_line(effects_line20); + effects_screen.add_line(effects_line21); + effects_screen.add_line(effects_line22); effects_screen.set_displayLineCount(2); effects_menu.add_screen(effects_screen); @@ -1527,11 +1583,13 @@ void init_menus(void) effects_line13.attach_function(CHORUS_FREQ, callback_chorus_frequency_function); effects_line14.attach_function(CHORUS_DELAY, callback_chorus_delay_function); effects_line15.attach_function(CHORUS_INTENSITY, callback_chorus_intensity_function); - effects_line16.attach_function(CHORUS_LEVEL, callback_chorus_level_function); - effects_line17.attach_function(BASS_LR_LEVEL, callback_bass_lr_level_function); - effects_line18.attach_function(BASS_MONO_LEVEL, callback_bass_mono_level_function); - effects_line19.attach_function(EQ_BASS, callback_eq_bass_function); - effects_line20.attach_function(EQ_TREBLE, callback_eq_treble_function); + effects_line16.attach_function(CHORUS_FEEDBACK, callback_chorus_feedback_function); + effects_line17.attach_function(CHORUS_WAVEFORM, callback_chorus_waveform_function); + effects_line18.attach_function(CHORUS_LEVEL, callback_chorus_level_function); + effects_line19.attach_function(BASS_LR_LEVEL, callback_bass_lr_level_function); + effects_line20.attach_function(BASS_MONO_LEVEL, callback_bass_mono_level_function); + effects_line21.attach_function(EQ_BASS, callback_eq_bass_function); + effects_line22.attach_function(EQ_TREBLE, callback_eq_treble_function); // setup pan_trem_frequency menu pan_trem_frequency_screen.add_line(pan_trem_frequency_line1); @@ -1623,6 +1681,18 @@ void init_menus(void) chorus_intensity_screen.set_displayLineCount(2); chorus_intensity_menu.add_screen(chorus_intensity_screen); + // setup chorus_feedback menu + chorus_feedback_screen.add_line(chorus_feedback_line1); + chorus_feedback_screen.add_line(chorus_feedback_line2); + chorus_feedback_screen.set_displayLineCount(2); + chorus_feedback_menu.add_screen(chorus_feedback_screen); + + // setup chorus_waveform menu + chorus_waveform_screen.add_line(chorus_waveform_line1); + chorus_waveform_screen.add_line(chorus_waveform_line2); + chorus_waveform_screen.set_displayLineCount(2); + chorus_waveform_menu.add_screen(chorus_waveform_screen); + // setup chorus_level menu chorus_level_screen.add_line(chorus_level_line1); chorus_level_screen.add_line(chorus_level_line2); @@ -1746,6 +1816,8 @@ void init_menus(void) menu_system.add_menu(chorus_frequency_menu); menu_system.add_menu(chorus_delay_menu); menu_system.add_menu(chorus_intensity_menu); + menu_system.add_menu(chorus_feedback_menu); + menu_system.add_menu(chorus_waveform_menu); menu_system.add_menu(chorus_level_menu); menu_system.add_menu(bass_lr_level_menu); menu_system.add_menu(bass_mono_level_menu); @@ -2061,6 +2133,38 @@ void set_chorus_intensity(uint8_t value) configuration.chorus_intensity = value; } +void set_chorus_feedback(uint8_t value) +{ +#ifdef SHOW_DEBUG + Serial.print(F("Set CHORUS_FEEDBACK ")); + Serial.println(value); +#endif + modchorus_r.feedback(mapfloat(float(value), ENC_CHORUS_FEEDBACK_MIN, ENC_CHORUS_FEEDBACK_MAX, 0.0, 1.0)); + modchorus_l.feedback(mapfloat(float(value), ENC_CHORUS_FEEDBACK_MIN, ENC_CHORUS_FEEDBACK_MAX, 0.0, 1.0)); + configuration.chorus_feedback = value; +} + +void set_chorus_waveform(uint8_t value) +{ +#ifdef SHOW_DEBUG + Serial.print(F("Set CHORUS_WAVEFORM ")); + //Serial.println(value); + Serial.println("=> Setting CHORUS_WAVEFORM not yet available!"); +#endif + switch (value) + { + case 1: + //modulator.waveform(WAVEFORM_TRIANGLE); + break; + case 2: + //modulator.waveform(WAVEFORM_SINE); + default: + //modulator.waveform(WAVEFORM_TRIANGLE); + break; + } + configuration.chorus_waveform = value; +} + void set_chorus_level(uint8_t value) { #ifdef SHOW_DEBUG @@ -2189,6 +2293,8 @@ void set_complete_configuration(void) set_chorus_frequency(configuration.chorus_frequency); set_chorus_delay(configuration.chorus_delay); set_chorus_intensity(configuration.chorus_intensity); + set_chorus_feedback(configuration.chorus_feedback); + set_chorus_waveform(configuration.chorus_waveform); set_chorus_level(configuration.chorus_level); set_bass_lr_level(configuration.bass_lr_level); set_bass_mono_level(configuration.bass_mono_level); @@ -2433,6 +2539,15 @@ void handle_ui(void) menu_system.update(); } } + else if (menu_system.get_currentScreen() == &chorus_delay_screen) + { + if (encoder_tmp != encoder_value[RIGHT_ENCODER]) + { + // value up/down + set_chorus_delay(encoder_tmp); + menu_system.update(); + } + } else if (menu_system.get_currentScreen() == &chorus_intensity_screen) { if (encoder_tmp != encoder_value[RIGHT_ENCODER]) @@ -2442,12 +2557,21 @@ void handle_ui(void) menu_system.update(); } } - else if (menu_system.get_currentScreen() == &chorus_delay_screen) + else if (menu_system.get_currentScreen() == &chorus_feedback_screen) { if (encoder_tmp != encoder_value[RIGHT_ENCODER]) { // value up/down - set_chorus_delay(encoder_tmp); + set_chorus_feedback(encoder_tmp); + menu_system.update(); + } + } + else if (menu_system.get_currentScreen() == &chorus_waveform_screen) + { + if (encoder_tmp != encoder_value[RIGHT_ENCODER]) + { + // value up/down + set_chorus_waveform(encoder_tmp); menu_system.update(); } } @@ -2886,6 +3010,20 @@ void handle_ui(void) #endif goto_effects_menu(CHORUS_INTENSITY); } + else if (menu_system.get_currentScreen() == &chorus_feedback_screen) // chorus_feedback menu + { +#ifdef SHOW_DEBUG + Serial.println(F("from chorus_feedback to effects")); +#endif + goto_effects_menu(CHORUS_FEEDBACK); + } + else if (menu_system.get_currentScreen() == &chorus_waveform_screen) // chorus_waveform menu + { +#ifdef SHOW_DEBUG + Serial.println(F("from chorus_waveform to effects")); +#endif + goto_effects_menu(CHORUS_WAVEFORM); + } else if (menu_system.get_currentScreen() == &chorus_level_screen) // chorus_level menu { #ifdef SHOW_DEBUG diff --git a/config.h b/config.h index 522584c..c1ad9d0 100644 --- a/config.h +++ b/config.h @@ -238,6 +238,14 @@ #define ENC_CHORUS_INTENSITY_MAX 100 #define ENC_CHORUS_INTENSITY_DEFAULT 50 // +#define ENC_CHORUS_FEEDBACK_MIN 0 +#define ENC_CHORUS_FEEDBACK_MAX 10 +#define ENC_CHORUS_FEEDBACK_DEFAULT 0 +// +#define ENC_CHORUS_WAVEFORM_MIN 1 +#define ENC_CHORUS_WAVEFORM_MAX 2 +#define ENC_CHORUS_WAVEFORM_DEFAULT 1 +// #define ENC_CHORUS_LEVEL_MIN 0 #define ENC_CHORUS_LEVEL_MAX 99 #define ENC_CHORUS_LEVEL_DEFAULT 50 @@ -328,6 +336,8 @@ struct config_t { uint8_t chorus_frequency; uint8_t chorus_delay; uint8_t chorus_intensity; + uint8_t chorus_feedback; + uint8_t chorus_waveform; uint8_t chorus_level; uint8_t bass_lr_level; uint8_t bass_mono_level;