From 308335d2b0f4b546e025df3d0280fe3b159f0321 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Tue, 12 Nov 2019 11:08:03 +0100 Subject: [PATCH] Fixes for filter parameter change. --- MicroDexed.ino | 38 ++++++++++++++++++++------------------ UI.hpp | 14 ++++---------- config.h | 6 ++---- 3 files changed, 26 insertions(+), 32 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 46d4aa2..af632a3 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -419,8 +419,8 @@ void setup() soften_filter_res[instance_id].init(configuration.dexed[instance_id].filter_resonance); soften_filter_cut[instance_id].init(configuration.dexed[instance_id].filter_cutoff); MicroDexed[instance_id]->fx.Gain = mapfloat(configuration.dexed[instance_id].loudness, LOUDNESS_MIN, LOUDNESS_MAX, 0.0, 1.0); - MicroDexed[instance_id]->fx.Reso = mapfloat(FILTER_RESONANCE_MAX - configuration.dexed[instance_id].filter_resonance, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 1.0, 0.0); - MicroDexed[instance_id]->fx.Cutoff = mapfloat(FILTER_CUTOFF_MAX - configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0); + MicroDexed[instance_id]->fx.Reso = mapfloat(configuration.dexed[instance_id].filter_resonance, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 1.0, 0.0); + MicroDexed[instance_id]->fx.Cutoff = mapfloat(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0); MicroDexed[instance_id]->doRefreshVoice(); } @@ -527,38 +527,40 @@ void loop() // check for value changes and unused voices soften_volume.tick(); - for (uint8_t i = 0; i < NUM_DEXED; i++) + for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) { - active_voices = MicroDexed[i]->getNumNotesPlaying(); + active_voices = MicroDexed[instance_id]->getNumNotesPlaying(); - soften_filter_res[i].tick(); - soften_filter_cut[i].tick(); + soften_filter_res[instance_id].tick(); + soften_filter_cut[instance_id].tick(); - if (soften_filter_res[i].running()) + if (soften_filter_res[instance_id].running()) { // soften filter resonance value - MicroDexed[i]->fx.Reso = (FILTER_RESONANCE_MAX - soften_filter_res[i].value()) / 100.0; + configuration.dexed[instance_id].filter_resonance=soften_filter_res[instance_id].value(); + MicroDexed[instance_id]->fx.Reso = mapfloat(configuration.dexed[instance_id].filter_resonance, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0); #ifdef DEBUG Serial.print(F("Filter-Resonance: ")); - Serial.print(MicroDexed[i]->fx.Reso, 5); + Serial.print(MicroDexed[instance_id]->fx.Reso, 5); Serial.print(F(" Filter-Resonance step: ")); - Serial.print(soften_filter_res[i].steps()); + Serial.print(soften_filter_res[instance_id].steps()); Serial.print(F(" Filter-Resonance diff: ")); - Serial.println(soften_filter_res[i].diff(), 5); + Serial.println(soften_filter_res[instance_id].diff(), 5); #endif } // soften filter cutoff value - if (soften_filter_cut[i].running()) + if (soften_filter_cut[instance_id].running()) { - MicroDexed[i]->fx.Cutoff = (FILTER_CUTOFF_MAX - soften_filter_cut[i].value()) / 100.0; + configuration.dexed[instance_id].filter_cutoff=soften_filter_cut[instance_id].value(); + MicroDexed[instance_id]->fx.Cutoff = mapfloat(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0); #ifdef DEBUG Serial.print(F("Filter-Cutoff: ")); - Serial.print(MicroDexed[i]->fx.Cutoff, 5); + Serial.print(MicroDexed[instance_id]->fx.Cutoff, 5); Serial.print(F(" Filter-Cutoff step: ")); - Serial.print(soften_filter_cut[i].steps()); + Serial.print(soften_filter_cut[instance_id].steps()); Serial.print(F(" Filter-Cutoff diff: ")); - Serial.println(soften_filter_cut[i].diff(), 5); + Serial.println(soften_filter_cut[instance_id].diff(), 5); #endif } } @@ -679,12 +681,12 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue) case 103: // CC 103: filter resonance configuration.dexed[instance_id].filter_resonance = map(inValue, 0, 0x7f, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX); //MicroDexed[instance_id]->fx.Reso = (100 - configuration.dexed[instance_id].filter_resonance) / 100.0; - soften_filter_res[instance_id].update(soften_filter_res[instance_id].value() + configuration.dexed[instance_id].filter_resonance, SOFTEN_VALUE_CHANGE_STEPS); + soften_filter_res[instance_id].update(configuration.dexed[instance_id].filter_resonance, SOFTEN_VALUE_CHANGE_STEPS); break; case 104: // CC 104: filter cutoff configuration.dexed[instance_id].filter_cutoff = map(inValue, 0, 0x7f, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX); //MicroDexed[instance_id]->fx.Cutoff = (100 - configuration.dexed[instance_id].filter_cutoff) / 100.0; - soften_filter_cut[instance_id].update(soften_filter_cut[instance_id].value() + configuration.dexed[instance_id].filter_cutoff, SOFTEN_VALUE_CHANGE_STEPS); + soften_filter_cut[instance_id].update(configuration.dexed[instance_id].filter_cutoff, SOFTEN_VALUE_CHANGE_STEPS); break; case 105: // CC 105: delay time configuration.delay_time = map(inValue, 0, 0x7f, DELAY_TIME_MIN, DELAY_TIME_MAX); diff --git a/UI.hpp b/UI.hpp index d1a7763..c675fab 100644 --- a/UI.hpp +++ b/UI.hpp @@ -1456,15 +1456,10 @@ void UI_func_filter_cutoff(uint8_t param) } } + soften_filter_cut[instance_id].update(constrain(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX), SOFTEN_VALUE_CHANGE_STEPS); + lcd.setCursor(0, 1); lcd_display_int(configuration.dexed[instance_id].filter_cutoff, 3, true, true, false); - Serial.print(LCDML.FUNC_getID(), DEC); - Serial.print(instance_id, DEC); - Serial.print(" value: "); - Serial.println(configuration.dexed[instance_id].filter_cutoff / 100.0, 3); - - //MicroDexed[instance_id]->fx.Cutoff = (100 - configuration.dexed[instance_id].filter_cutoff) / 100.0; - soften_filter_cut[instance_id].update(soften_filter_cut[instance_id].value() + configuration.dexed[instance_id].filter_cutoff, SOFTEN_VALUE_CHANGE_STEPS); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -1509,11 +1504,10 @@ void UI_func_filter_resonance(uint8_t param) } } + soften_filter_res[instance_id].update(constrain(configuration.dexed[instance_id].filter_resonance, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX), SOFTEN_VALUE_CHANGE_STEPS); + lcd.setCursor(0, 1); lcd_display_int(configuration.dexed[instance_id].filter_resonance, 3, true, true, false); - - //MicroDexed[instance_id]->fx.Reso = (100 - configuration.dexed[instance_id].filter_resonance) / 100.0; - soften_filter_res[instance_id].update(soften_filter_res[instance_id].value() + configuration.dexed[instance_id].filter_resonance--, SOFTEN_VALUE_CHANGE_STEPS); } if (LCDML.FUNC_close()) // ****** STABLE END ********* diff --git a/config.h b/config.h index efd621d..cfb8b91 100644 --- a/config.h +++ b/config.h @@ -324,13 +324,11 @@ enum { DEXED, REVERB, DELAY, CHORUS }; #define FILTER_CUTOFF_MIN 0 #define FILTER_CUTOFF_MAX 100 -#define FILTER_CUTOFF_DEFAULT 100 -#define FILTER_CUTOFF_ENC_STEPS 1 +#define FILTER_CUTOFF_DEFAULT 0 #define FILTER_RESONANCE_MIN 0 #define FILTER_RESONANCE_MAX 100 -#define FILTER_RESONANCE_DEFAULT 100 -#define FILTER_RESONANCE_ENC_STEPS 1 +#define FILTER_RESONANCE_DEFAULT 0 #define LOUDNESS_MIN 0 #define LOUDNESS_MAX 100