From 81b7d276cf1fb7886f3c9bd4c83e8e7006739ffa Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Tue, 30 Jun 2020 08:07:44 +0200 Subject: [PATCH] Fixed issue #29: Voice-config has filter parameters inside, should be better located in fx-config. --- MicroDexed.ino | 20 ++++++++++---------- UI.hpp | 28 ++++++++++++++-------------- config.h | 4 ++-- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 3e43b22..a1d13ae 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -762,8 +762,8 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue) break; #if defined(USE_FX) 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 = mapfloat(configuration.dexed[instance_id].filter_resonance, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 1.0, 0.0); + configuration.fx.filter_resonance[instance_id] = map(inValue, 0, 0x7f, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX); + MicroDexed[instance_id]->fx.Reso = mapfloat(configuration.fx.filter_resonance[instance_id], FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 1.0, 0.0); if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_filter_resonance)) { LCDML.OTHER_updateFunc(); @@ -771,8 +771,8 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue) } 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 = mapfloat(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0); + configuration.fx.filter_cutoff[instance_id] = map(inValue, 0, 0x7f, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX); + MicroDexed[instance_id]->fx.Cutoff = mapfloat(configuration.fx.filter_cutoff[instance_id], FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0); if (LCDML.FUNC_getID() == LCDML.OTHER_getIDFromFunction(UI_func_filter_cutoff)) { LCDML.OTHER_updateFunc(); @@ -1503,8 +1503,6 @@ void check_configuration(void) configuration.dexed[instance_id].midi_channel = constrain(configuration.dexed[instance_id].midi_channel, MIDI_CHANNEL_MIN, MIDI_CHANNEL_MAX); configuration.dexed[instance_id].lowest_note = constrain(configuration.dexed[instance_id].lowest_note, INSTANCE_LOWEST_NOTE_MIN, INSTANCE_LOWEST_NOTE_MAX); configuration.dexed[instance_id].highest_note = constrain(configuration.dexed[instance_id].highest_note, INSTANCE_HIGHEST_NOTE_MIN, INSTANCE_HIGHEST_NOTE_MAX); - configuration.dexed[instance_id].filter_cutoff = constrain(configuration.dexed[instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX); - configuration.dexed[instance_id].filter_resonance = constrain(configuration.dexed[instance_id].filter_resonance, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX); configuration.dexed[instance_id].sound_intensity = constrain(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX); configuration.dexed[instance_id].pan = constrain(configuration.dexed[instance_id].pan, PANORAMA_MIN, PANORAMA_MAX); configuration.dexed[instance_id].transpose = constrain(configuration.dexed[instance_id].transpose, TRANSPOSE_MIN, TRANSPOSE_MAX); @@ -1533,6 +1531,8 @@ void check_configuration(void) configuration.dexed[instance_id].portamento_time = constrain(configuration.dexed[instance_id].portamento_time, PORTAMENTO_TIME_MIN, PORTAMENTO_TIME_MAX); configuration.dexed[instance_id].op_enabled = constrain(configuration.dexed[instance_id].op_enabled, OP_ENABLED_MIN, OP_ENABLED_MAX); + configuration.fx.filter_cutoff[instance_id] = constrain(configuration.fx.filter_cutoff[instance_id], FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX); + configuration.fx.filter_resonance[instance_id] = constrain(configuration.fx.filter_resonance[instance_id], FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX); configuration.fx.chorus_frequency[instance_id] = constrain(configuration.fx.chorus_frequency[instance_id], CHORUS_FREQUENCY_MIN, CHORUS_FREQUENCY_MAX); configuration.fx.chorus_waveform[instance_id] = constrain(configuration.fx.chorus_waveform[instance_id], CHORUS_WAVEFORM_MIN, CHORUS_WAVEFORM_MAX); configuration.fx.chorus_depth[instance_id] = constrain(configuration.fx.chorus_depth[instance_id], CHORUS_DEPTH_MIN, CHORUS_DEPTH_MAX); @@ -1571,8 +1571,6 @@ void init_configuration(void) configuration.dexed[instance_id].midi_channel = DEFAULT_MIDI_CHANNEL; configuration.dexed[instance_id].lowest_note = INSTANCE_LOWEST_NOTE_MIN; configuration.dexed[instance_id].highest_note = INSTANCE_HIGHEST_NOTE_MAX; - configuration.dexed[instance_id].filter_cutoff = FILTER_CUTOFF_DEFAULT; - configuration.dexed[instance_id].filter_resonance = FILTER_RESONANCE_DEFAULT; configuration.dexed[instance_id].sound_intensity = SOUND_INTENSITY_DEFAULT; configuration.dexed[instance_id].pan = PANORAMA_DEFAULT; configuration.dexed[instance_id].transpose = TRANSPOSE_DEFAULT; @@ -1601,6 +1599,8 @@ void init_configuration(void) configuration.dexed[instance_id].portamento_time = PORTAMENTO_TIME_DEFAULT; configuration.dexed[instance_id].op_enabled = OP_ENABLED_DEFAULT; + configuration.fx.filter_cutoff[instance_id] = FILTER_CUTOFF_DEFAULT; + configuration.fx.filter_resonance[instance_id] = FILTER_RESONANCE_DEFAULT; configuration.fx.chorus_frequency[instance_id] = CHORUS_FREQUENCY_DEFAULT; configuration.fx.chorus_waveform[instance_id] = CHORUS_WAVEFORM_DEFAULT; configuration.fx.chorus_depth[instance_id] = CHORUS_DEPTH_DEFAULT; @@ -1785,8 +1785,8 @@ void set_fx_params(void) reverb_mixer_l.gain(instance_id, pseudo_log_curve(mapfloat(configuration.fx.reverb_send[instance_id], REVERB_SEND_MIN, REVERB_SEND_MAX, 0.0, 1.0))); // DEXED FILTER - 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]->fx.Reso = mapfloat(configuration.fx.filter_resonance[instance_id], FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 1.0, 0.0); + MicroDexed[instance_id]->fx.Cutoff = mapfloat(configuration.fx.filter_cutoff[instance_id], FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0); MicroDexed[instance_id]->doRefreshVoice(); } diff --git a/UI.hpp b/UI.hpp index 82e4e34..98ba461 100644 --- a/UI.hpp +++ b/UI.hpp @@ -1440,7 +1440,7 @@ void UI_func_filter_cutoff(uint8_t param) encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_int("Filter Cut", configuration.dexed[selected_instance_id].filter_cutoff, 1.0, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 3, false, false, true); + lcd_display_bar_int("Filter Cut", configuration.fx.filter_cutoff[selected_instance_id], 1.0, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 3, false, false, true); lcd_active_instance_number(selected_instance_id); lcd.setCursor(14, 0); @@ -1454,9 +1454,9 @@ void UI_func_filter_cutoff(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[selected_instance_id].filter_cutoff = constrain(configuration.dexed[selected_instance_id].filter_cutoff + ENCODER[ENC_R].speed(), FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX); + configuration.fx.filter_cutoff[selected_instance_id] = constrain(configuration.fx.filter_cutoff[selected_instance_id] + ENCODER[ENC_R].speed(), FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[selected_instance_id].filter_cutoff = constrain(configuration.dexed[selected_instance_id].filter_cutoff - ENCODER[ENC_R].speed(), FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX); + configuration.fx.filter_cutoff[selected_instance_id] = constrain(configuration.fx.filter_cutoff[selected_instance_id] - ENCODER[ENC_R].speed(), FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { @@ -1470,18 +1470,18 @@ void UI_func_filter_cutoff(uint8_t param) #endif } - lcd_display_bar_int("Filter Cut", configuration.dexed[selected_instance_id].filter_cutoff, 1.0, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 3, false, false, false); + lcd_display_bar_int("Filter Cut", configuration.fx.filter_cutoff[selected_instance_id], 1.0, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 3, false, false, false); - MicroDexed[selected_instance_id]->fx.Cutoff = mapfloat(configuration.dexed[selected_instance_id].filter_cutoff, FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0); + MicroDexed[selected_instance_id]->fx.Cutoff = mapfloat(configuration.fx.filter_cutoff[selected_instance_id], FILTER_CUTOFF_MIN, FILTER_CUTOFF_MAX, 1.0, 0.0); } if (LCDML.FUNC_close()) // ****** STABLE END ********* { lcd_special_chars(SCROLLBAR); encoderDir[ENC_R].reset(); - EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, dexed[0].filter_cutoff), configuration.dexed[0].filter_cutoff); + EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, fx.filter_cutoff[0]), configuration.fx.filter_cutoff[0]); #if NUM_DEXED > 1 - EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, dexed[1].filter_cutoff), configuration.dexed[1].filter_cutoff); + EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, fx[1].filter_cutoff[1]), configuration.fx.filter_cutoff[1]); #endif } } @@ -1493,7 +1493,7 @@ void UI_func_filter_resonance(uint8_t param) encoderDir[ENC_R].reset(); lcd_special_chars(BLOCKBAR); - lcd_display_bar_int("Filter Res", configuration.dexed[selected_instance_id].filter_resonance, 1.0, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 3, false, false, true); + lcd_display_bar_int("Filter Res", configuration.fx.filter_resonance[selected_instance_id], 1.0, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 3, false, false, true); lcd_active_instance_number(selected_instance_id); lcd.setCursor(14, 0); @@ -1507,9 +1507,9 @@ void UI_func_filter_resonance(uint8_t param) if ((LCDML.BT_checkDown() && encoderDir[ENC_R].Down()) || (LCDML.BT_checkUp() && encoderDir[ENC_R].Up()) || (LCDML.BT_checkEnter() && encoderDir[ENC_R].ButtonShort())) { if (LCDML.BT_checkDown()) - configuration.dexed[selected_instance_id].filter_resonance = constrain(configuration.dexed[selected_instance_id].filter_resonance + ENCODER[ENC_R].speed(), FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX); + configuration.fx.filter_resonance[selected_instance_id] = constrain(configuration.fx.filter_resonance[selected_instance_id] + ENCODER[ENC_R].speed(), FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX); else if (LCDML.BT_checkUp()) - configuration.dexed[selected_instance_id].filter_resonance = constrain(configuration.dexed[selected_instance_id].filter_resonance - ENCODER[ENC_R].speed(), FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX); + configuration.fx.filter_resonance[selected_instance_id] = constrain(configuration.fx.filter_resonance[selected_instance_id] - ENCODER[ENC_R].speed(), FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX); #if NUM_DEXED > 1 else if (LCDML.BT_checkEnter()) { @@ -1523,18 +1523,18 @@ void UI_func_filter_resonance(uint8_t param) #endif } - lcd_display_bar_int("Filter Res", configuration.dexed[selected_instance_id].filter_resonance, 1.0, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 3, false, false, false); + lcd_display_bar_int("Filter Res", configuration.fx.filter_resonance[selected_instance_id], 1.0, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 3, false, false, false); - MicroDexed[selected_instance_id]->fx.Reso = mapfloat(configuration.dexed[selected_instance_id].filter_resonance, FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 1.0, 0.0); + MicroDexed[selected_instance_id]->fx.Reso = mapfloat(configuration.fx.filter_resonance[selected_instance_id], FILTER_RESONANCE_MIN, FILTER_RESONANCE_MAX, 1.0, 0.0); } if (LCDML.FUNC_close()) // ****** STABLE END ********* { lcd_special_chars(SCROLLBAR); encoderDir[ENC_R].reset(); - EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, dexed[0].filter_resonance), configuration.dexed[0].filter_resonance); + EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, fx.filter_resonance[0]), configuration.fx.filter_resonance[0]); #if NUM_DEXED > 1 - EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, dexed[1].filter_resonance), configuration.dexed[1].filter_resonance); + EEPROM.update(EEPROM_START_ADDRESS + offsetof(configuration_s, fx.filter_resonance[1]), configuration.fx.filter_resonance[1]); #endif } } diff --git a/config.h b/config.h index 40b61e6..03bec14 100644 --- a/config.h +++ b/config.h @@ -579,8 +579,6 @@ typedef struct dexed_s { uint8_t lowest_note; uint8_t highest_note; - uint8_t filter_cutoff; - uint8_t filter_resonance; uint8_t transpose; uint8_t tune; uint8_t sound_intensity; @@ -612,6 +610,8 @@ typedef struct dexed_s { } dexed_t; typedef struct fx_s { + uint8_t filter_cutoff[MAX_DEXED]; + uint8_t filter_resonance[MAX_DEXED]; uint8_t chorus_frequency[MAX_DEXED]; uint8_t chorus_waveform[MAX_DEXED]; uint8_t chorus_depth[MAX_DEXED];