From 0f12e11ca07af918650b9036344d0e5505d3637a Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Thu, 16 May 2019 15:10:10 +0200 Subject: [PATCH] Added all set_* functions. --- .swp | Bin 12288 -> 12288 bytes MicroMDAEPiano.ino | 28 +++--- UI.hpp | 239 ++++++++++++++++++++++++++++++++++++++++++++- config.h | 12 +-- 4 files changed, 255 insertions(+), 24 deletions(-) diff --git a/.swp b/.swp index fccdd8bfabfaab6a09cc8489426fbf0240e26c68..d2a572e624d997186089d3ba34bfd44d80084ad3 100644 GIT binary patch delta 135 zcmZojXh_%~Ai&7JSy13JKksus1_pV41_lNJ1_t)Yf(qhXML=F85XsetParameter(MDA_EP_OVERDRIVE, tmp); } +void set_comp_gain(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set COMP_GAIN ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_COMP_GAIN_MIN, ENC_COMP_GAIN_MAX, 0.0, 1.0); + sgtl5000_1.autoVolumeControl(tmp, configuration.comp_response, configuration.comp_limit, configuration.comp_threshold, configuration.comp_attack, configuration.comp_decay); // maxGain, response, hardLimit, threshold, attack, decay, e.g.: 1, 1, 1, 0.9, 0.01, 0.05 +} + +void set_comp_response(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set COMP_RESPONSE ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_COMP_RESPONSE_MIN, ENC_COMP_RESPONSE_MAX, 0.0, 1.0); + sgtl5000_1.autoVolumeControl(configuration.comp_gain, tmp, configuration.comp_limit, configuration.comp_threshold, configuration.comp_attack, configuration.comp_decay); // maxGain, response, hardLimit, threshold, attack, decay, e.g.: 1, 1, 1, 0.9, 0.01, 0.05 +} + +void set_comp_limit(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set COMP_LIMIT ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_COMP_LIMIT_MIN, ENC_COMP_LIMIT_MAX, 0.0, 1.0); + sgtl5000_1.autoVolumeControl(configuration.comp_gain, configuration.comp_response, tmp, configuration.comp_threshold, configuration.comp_attack, configuration.comp_decay); // maxGain, response, hardLimit, threshold, attack, decay, e.g.: 1, 1, 1, 0.9, 0.01, 0.05 +} + +void set_comp_threshold(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set COMP_THRESHOLD ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_COMP_THRESHOLD_MIN, ENC_COMP_THRESHOLD_MAX, 0.0, 1.0); + sgtl5000_1.autoVolumeControl(configuration.comp_gain, configuration.comp_response, configuration.comp_limit, tmp, configuration.comp_attack, configuration.comp_decay); // maxGain, response, hardLimit, threshold, attack, decay, e.g.: 1, 1, 1, 0.9, 0.01, 0.05 +} + +void set_comp_attack(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set COMP_ATTACK ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_COMP_ATTACK_MIN, ENC_COMP_ATTACK_MAX, 0.0, 1.0); + sgtl5000_1.autoVolumeControl(configuration.comp_gain, configuration.comp_response, configuration.comp_limit, configuration.comp_threshold, tmp, configuration.comp_decay); // maxGain, response, hardLimit, threshold, attack, decay, e.g.: 1, 1, 1, 0.9, 0.01, 0.05 +} + +void set_comp_decay(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set COMP_DECAY ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_COMP_DECAY_MIN, ENC_COMP_DECAY_MAX, 0.0, 1.0); + sgtl5000_1.autoVolumeControl(configuration.comp_gain, configuration.comp_response, configuration.comp_limit, configuration.comp_threshold, configuration.comp_attack, tmp); // maxGain, response, hardLimit, threshold, attack, decay, e.g.: 1, 1, 1, 0.9, 0.01, 0.05 +} + +void set_reverb_roomsize(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set REVERB_ROOMSIZE ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_REVERB_ROOMSIZE_MIN, ENC_REVERB_ROOMSIZE_MAX, 0.0, 1.0); + freeverb_r.roomsize(tmp); + freeverb_l.roomsize(tmp); +} + +void set_reverb_damping(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set REVERB_DAMPING ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_REVERB_DAMPING_MIN, ENC_REVERB_DAMPING_MAX, 0.0, 1.0); + freeverb_r.damping(tmp); + freeverb_l.damping(tmp); +} + +void set_reverb_level(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set REVERB_LEVEL ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_REVERB_DAMPING_MIN, ENC_REVERB_DAMPING_MAX, 0.0, 1.0); + mixer_r.gain(0, 1.0 - tmp); + mixer_l.gain(0, 1.0 - tmp); + mixer_r.gain(1, tmp); + mixer_l.gain(1, tmp); +} + +void set_chorus_frequency(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set CHORUS_FREQUENCY ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_CHORUS_FREQUENCY_MIN, ENC_CHORUS_FREQUENCY_MAX, 0.0, 1.0); + // TDB +} + +void set_chorus_delay(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set CHORUS_DELAY ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_CHORUS_DELAY_MIN, ENC_CHORUS_DELAY_MAX, 0.0, 1.0); + // TDB +} + +void set_chorus_level(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set CHORUS_LEVEL ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_CHORUS_LEVEL_MIN, ENC_CHORUS_LEVEL_MAX, 0.0, 1.0); + // TDB +} + +void set_bass_lr_level(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set BASS_LR_LEVEL ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_BASS_LR_LEVEL_MIN, ENC_BASS_LR_LEVEL_MAX, 0.0, 1.0); + sgtl5000_1.enhanceBass(tmp, configuration.bass_mono_level); +} + +void set_bass_mono_level(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set BASS_MONO_LEVEL ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_BASS_MONO_LEVEL_MIN, ENC_BASS_MONO_LEVEL_MAX, 0.0, 1.0); + sgtl5000_1.enhanceBass(configuration.bass_mono_level, tmp); +} + +void set_eq_bass(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set EQ_BASS ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_EQ_BASS_MIN, ENC_EQ_BASS_MAX, 0.0, 1.0); + sgtl5000_1.eqBands(tmp, configuration.eq_treble); +} + +void set_eq_treble(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set EQ_TREBLE ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_EQ_TREBLE_MIN, ENC_EQ_TREBLE_MAX, 0.0, 1.0); + sgtl5000_1.eqBands(configuration.eq_bass, tmp); +} + +void set_loudness(uint8_t value) +{ +#ifdef DEBUG + Serial.print(F("Set LOUDNESS ")); + Serial.println(value); +#endif + float tmp = mapfloat(float(value), ENC_LOUDNESS_MIN, ENC_LOUDNESS_MAX, 0.0, 1.0); + volume_r.gain(tmp); + volume_l.gain(tmp); +} + +void set_complete_configuration(void) +{ + set_decay(configuration.decay); + set_release(configuration.release); + set_hardness(configuration.hardness); + set_treble(configuration.treble); + set_stereo(configuration.stereo); + set_tune(configuration.tune); + set_detune(configuration.detune); + set_velocity_sense(configuration.velocity_sense); + set_pan_trem_frequency(configuration.pan_trem_frequency); + set_pan_trem_level(configuration.pan_trem_level); + set_overdrive(configuration.overdrive); + set_comp_gain(configuration.comp_gain); + set_comp_response(configuration.comp_response); + set_comp_limit(configuration.comp_limit); + set_comp_threshold(configuration.comp_threshold); + set_comp_attack(configuration.comp_attack); + set_comp_decay(configuration.comp_decay); + set_reverb_roomsize(configuration.reverb_roomsize); + set_reverb_damping(configuration.reverb_damping); + set_reverb_level(configuration.reverb_level); + set_chorus_frequency(configuration.chorus_frequency); + set_chorus_delay(configuration.chorus_delay); + set_chorus_level(configuration.chorus_level); + set_bass_lr_level(configuration.bass_lr_level); + set_bass_mono_level(configuration.bass_mono_level); + set_eq_bass(configuration.eq_bass); + set_eq_treble(configuration.eq_treble); + set_loudness(configuration.loudness); +} + //********************************************************************************************+ void handle_ui(void) { @@ -1780,6 +1995,7 @@ void handle_ui(void) { // value up/down configuration.comp_gain = encoder_tmp; + set_comp_gain(configuration.comp_gain); menu_system.update(); } } @@ -1789,6 +2005,7 @@ void handle_ui(void) { // value up/down configuration.comp_response = encoder_tmp; + set_comp_response(configuration.comp_response); menu_system.update(); } } @@ -1798,6 +2015,7 @@ void handle_ui(void) { // value up/down configuration.comp_limit = encoder_tmp; + set_comp_limit(configuration.comp_limit); menu_system.update(); } } @@ -1807,6 +2025,7 @@ void handle_ui(void) { // value up/down configuration.comp_threshold = encoder_tmp; + set_comp_threshold(configuration.comp_threshold); menu_system.update(); } } @@ -1816,6 +2035,7 @@ void handle_ui(void) { // value up/down configuration.comp_attack = encoder_tmp; + set_comp_attack(configuration.comp_attack); menu_system.update(); } } @@ -1825,6 +2045,7 @@ void handle_ui(void) { // value up/down configuration.comp_decay = encoder_tmp; + set_comp_decay(configuration.comp_decay); menu_system.update(); } } @@ -1834,6 +2055,7 @@ void handle_ui(void) { // value up/down configuration.reverb_roomsize = encoder_tmp; + set_reverb_roomsize(configuration.reverb_roomsize); menu_system.update(); } } @@ -1843,6 +2065,7 @@ void handle_ui(void) { // value up/down configuration.reverb_damping = encoder_tmp; + set_reverb_damping(configuration.reverb_damping); menu_system.update(); } } @@ -1852,6 +2075,7 @@ void handle_ui(void) { // value up/down configuration.reverb_level = encoder_tmp; + set_reverb_level(configuration.reverb_level); menu_system.update(); } } @@ -1861,6 +2085,7 @@ void handle_ui(void) { // value up/down configuration.chorus_frequency = encoder_tmp; + set_chorus_frequency(configuration.chorus_frequency); menu_system.update(); } } @@ -1870,6 +2095,7 @@ void handle_ui(void) { // value up/down configuration.chorus_delay = encoder_tmp; + set_chorus_delay(configuration.chorus_delay); menu_system.update(); } } @@ -1879,6 +2105,7 @@ void handle_ui(void) { // value up/down configuration.chorus_level = encoder_tmp; + set_chorus_level(configuration.chorus_level); menu_system.update(); } } @@ -1888,6 +2115,7 @@ void handle_ui(void) { // value up/down configuration.bass_lr_level = encoder_tmp; + set_bass_lr_level(configuration.bass_lr_level); menu_system.update(); } } @@ -1897,6 +2125,7 @@ void handle_ui(void) { // value up/down configuration.bass_mono_level = encoder_tmp; + set_bass_mono_level(configuration.bass_mono_level); menu_system.update(); } } @@ -1906,6 +2135,7 @@ void handle_ui(void) { // value up/down configuration.eq_bass = encoder_tmp; + set_eq_bass(configuration.eq_bass); menu_system.update(); } } @@ -1915,6 +2145,7 @@ void handle_ui(void) { // value up/down configuration.eq_treble = encoder_tmp; + set_eq_treble(configuration.eq_treble); menu_system.update(); } } @@ -1924,6 +2155,7 @@ void handle_ui(void) { // value up/down configuration.sound = encoder_tmp; + save_sound(configuration.sound); menu_system.update(); } } @@ -1933,6 +2165,7 @@ void handle_ui(void) { // value up/down configuration.loudness = encoder_tmp; + set_loudness(configuration.loudness); menu_system.update(); } } @@ -2003,7 +2236,7 @@ void handle_ui(void) Serial.print("Load sound "); Serial.println(configuration.sound); #endif - ; // TODO + load_sound(configuration.sound); } else if (menu_system.get_currentScreen() == &save_sound_screen) { @@ -2012,7 +2245,7 @@ void handle_ui(void) Serial.print("Save sound "); Serial.println(configuration.sound); #endif - ; // TODO + save_sound(configuration.sound); } else { diff --git a/config.h b/config.h index fafe67f..c0312fd 100644 --- a/config.h +++ b/config.h @@ -165,27 +165,27 @@ // #define ENC_COMP_GAIN_MIN 0 #define ENC_COMP_GAIN_MAX 99 -#define ENC_COMP_GAIN_DEFAULT 50 +#define ENC_COMP_GAIN_DEFAULT 99 // #define ENC_COMP_RESPONSE_MIN 0 #define ENC_COMP_RESPONSE_MAX 99 -#define ENC_COMP_RESPONSE_DEFAULT 50 +#define ENC_COMP_RESPONSE_DEFAULT 99 // #define ENC_COMP_LIMIT_MIN 0 #define ENC_COMP_LIMIT_MAX 99 -#define ENC_COMP_LIMIT_DEFAULT 50 +#define ENC_COMP_LIMIT_DEFAULT 99 // #define ENC_COMP_THRESHOLD_MIN 0 #define ENC_COMP_THRESHOLD_MAX 99 -#define ENC_COMP_THRESHOLD_DEFAULT 50 +#define ENC_COMP_THRESHOLD_DEFAULT 90 // #define ENC_COMP_ATTACK_MIN 0 #define ENC_COMP_ATTACK_MAX 99 -#define ENC_COMP_ATTACK_DEFAULT 50 +#define ENC_COMP_ATTACK_DEFAULT 1 // #define ENC_COMP_DECAY_MIN 0 #define ENC_COMP_DECAY_MAX 99 -#define ENC_COMP_DECAY_DEFAULT 50 +#define ENC_COMP_DECAY_DEFAULT 5 // #define ENC_REVERB_ROOMSIZE_MIN 0 #define ENC_REVERB_ROOMSIZE_MAX 99