From 103cc5ae76a838b74a94640cb751cf8c81e721f7 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Tue, 30 Apr 2019 15:07:33 +0200 Subject: [PATCH] Fixes. --- MicroDexed.ino | 32 +++++++++++++++++++++++++++++++- UI.cpp | 41 ++++++++++++++++++++++++++++------------- UI.h | 2 ++ 3 files changed, 61 insertions(+), 14 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 42a7148..e2fb008 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -112,6 +112,8 @@ elapsedMillis cpu_mem_millis; config_t configuration = {0xffff, 0, 0, VOLUME, 0.5f, DEFAULT_MIDI_CHANNEL}; bool eeprom_update_flag = false; value_change_t soften_volume = {0.0, 0}; +value_change_t soften_filter_res = {0.0, 0}; +value_change_t soften_filter_cut = {0.0, 0}; void setup() { @@ -348,6 +350,34 @@ void loop() Serial.print(soften_volume.steps); Serial.print(F(" Volume diff: ")); Serial.println(soften_volume.diff, 5); +#endif + } + if (soften_filter_res.steps > 0) + { + // soften filter resonance value + soften_filter_res.steps--; + dexed->fx.Reso = dexed->fx.Reso + soften_filter_res.diff; +#ifdef DEBUG + Serial.print(F("Filter-Resonance: ")); + Serial.print(dexed->fx.Reso, 5); + Serial.print(F(" Filter-Resonance step: ")); + Serial.print(soften_filter_res.steps); + Serial.print(F(" Filter-Resonance diff: ")); + Serial.println(soften_filter_res.diff, 5); +#endif + } + if (soften_filter_cut.steps > 0) + { + // soften filter cutoff value + soften_filter_cut.steps--; + dexed->fx.Cutoff = dexed->fx.Cutoff + soften_filter_cut.diff; +#ifdef DEBUG + Serial.print(F("Filter-Cutoff: ")); + Serial.print(dexed->fx.Cutoff, 5); + Serial.print(F(" Filter-Cutoff step: ")); + Serial.print(soften_filter_cut.steps); + Serial.print(F(" Filter-Cutoff diff: ")); + Serial.println(soften_filter_cut.diff, 5); #endif } } @@ -795,7 +825,7 @@ void initial_values_from_eeprom(void) void eeprom_write(void) { - autostore=0; + autostore = 0; eeprom_update_flag = true; } diff --git a/UI.cpp b/UI.cpp index 47f4893..2d4824e 100644 --- a/UI.cpp +++ b/UI.cpp @@ -211,16 +211,17 @@ void handle_ui(void) enc[i].write(0); else if (enc[i].read() >= ENC_VOL_STEPS) enc[i].write(ENC_VOL_STEPS); + enc_val[i] = enc[i].read(); //set_volume(float(map(enc[i].read(), 0, ENC_VOL_STEPS, 0, 100)) / 100, configuration.pan); tmp = (float(map(enc[i].read(), 0, ENC_VOL_STEPS, 0, 100)) / 100) - configuration.vol; soften_volume.diff = tmp / SOFTEN_VALUE_CHANGE_STEPS; - soften_volume.steps = SOFTEN_VALUE_CHANGE_STEPS + 1; + soften_volume.steps = SOFTEN_VALUE_CHANGE_STEPS; #ifdef DEBUG Serial.print(F("Setting soften volume from: ")); Serial.print(configuration.vol, 5); - Serial.print(F(" Volume step: ")); + Serial.print(F("/Volume step: ")); Serial.print(soften_volume.steps); - Serial.print(F(" Volume diff: ")); + Serial.print(F("/Volume diff: ")); Serial.println(soften_volume.diff, 5); #endif eeprom_write(); @@ -300,25 +301,39 @@ void handle_ui(void) case UI_MAIN_FILTER_RES: if (enc[i].read() <= 0) enc[i].write(0); - else if (enc[i].read() > ENC_FILTER_RES_STEPS) + else if (enc[i].read() >= ENC_FILTER_RES_STEPS) enc[i].write(ENC_FILTER_RES_STEPS); + enc_val[i] = enc[i].read(); effect_filter_resonance = enc[i].read(); - dexed->fx.Reso = 1.0 - float(effect_filter_resonance) / ENC_FILTER_RES_STEPS; + tmp = 1.0 - (float(map(enc[i].read(), 0, ENC_FILTER_RES_STEPS, 0, 100)) / 100) - dexed->fx.Reso; + soften_filter_res.diff = tmp / SOFTEN_VALUE_CHANGE_STEPS; + soften_filter_res.steps = SOFTEN_VALUE_CHANGE_STEPS; #ifdef DEBUG - Serial.print(F("Setting filter resonance to: ")); - Serial.println(1.0 - float(effect_filter_resonance) / ENC_FILTER_RES_STEPS, 5); + Serial.print(F("Setting soften filter-resonance from: ")); + Serial.print(dexed->fx.Reso, 5); + Serial.print(F("/Filter-Resonance step: ")); + Serial.print(soften_filter_res.steps); + Serial.print(F("/Filter-Resonance diff: ")); + Serial.println(soften_filter_res.diff, 5); #endif break; case UI_MAIN_FILTER_CUT: if (enc[i].read() <= 0) enc[i].write(0); - else if (enc[i].read() > ENC_FILTER_CUT_STEPS) + else if (enc[i].read() >= ENC_FILTER_CUT_STEPS) enc[i].write(ENC_FILTER_CUT_STEPS); + enc_val[i] = enc[i].read(); effect_filter_cutoff = enc[i].read(); - dexed->fx.Cutoff = 1.0 - float(effect_filter_cutoff) / ENC_FILTER_CUT_STEPS; + tmp = 1.0 - (float(map(enc[i].read(), 0, ENC_FILTER_CUT_STEPS, 0, 100)) / 100) - dexed->fx.Cutoff; + soften_filter_cut.diff = tmp / SOFTEN_VALUE_CHANGE_STEPS; + soften_filter_cut.steps = SOFTEN_VALUE_CHANGE_STEPS; #ifdef DEBUG - Serial.print(F("Setting filter cutoff to: ")); - Serial.println(1.0 - float(effect_filter_cutoff) / ENC_FILTER_CUT_STEPS, 5); + Serial.print(F("Setting soften filter-cutoff from: ")); + Serial.print(dexed->fx.Cutoff, 5); + Serial.print(F("/Filter-Cutoff step: ")); + Serial.print(soften_filter_cut.steps); + Serial.print(F("/Filter-Cutoff diff: ")); + Serial.println(soften_filter_cut.diff, 5); #endif break; } @@ -434,12 +449,12 @@ void ui_show_volume(void) ui_back_to_main = 0; // erase old marker and show new marker - pos = map(configuration.vol * 100 + 0.5, 0, 100, 0, LCD_CHARS-1); + pos = map(configuration.vol * 100 + 0.5, 0, 100, 0, LCD_CHARS - 1); if (ui_state != UI_VOLUME) { lcd.clear(); - lcd.show(0, 0, LCD_CHARS-1, "Volume"); + lcd.show(0, 0, LCD_CHARS - 1, "Volume"); lcd.show(1, pos, 1, "*"); old_pos = pos; } diff --git a/UI.h b/UI.h index 40c5435..452df34 100644 --- a/UI.h +++ b/UI.h @@ -57,6 +57,8 @@ extern AudioEffectDelay delay1; extern AudioMixer4 mixer1; extern AudioMixer4 mixer2; extern value_change_t soften_volume; +extern value_change_t soften_filter_res; +extern value_change_t soften_filter_cut; void handle_ui(void); void ui_show_main(void);