From b27cd00895478b6447a0bbfc9e202fa8b22fb945 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Tue, 25 Feb 2020 15:02:42 +0100 Subject: [PATCH] Replaced set_master_mixer_gain() function. --- MicroDexed.ino | 85 +++++++++----------------------------------------- UI.hpp | 24 ++++++-------- 2 files changed, 25 insertions(+), 84 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 7cba89a..3c3c6a3 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -789,9 +789,8 @@ void handleControlChange(byte inChannel, byte inCtrl, byte inValue) break; case 107: // CC 107: delay volume configuration.dexed[instance_id].delay_send = map(inValue, 0, 0x7f, DELAY_SEND_MIN, DELAY_SEND_MAX); - set_master_mixer_gain(DELAY, configuration.delay_level / 100.0); - //master_mixer_r.gain(DELAY, mapfloat(configuration.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0)); - //master_mixer_l.gain(DELAY, mapfloat(configuration.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0)); + master_mixer_r.gain(DELAY, mapfloat(configuration.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0)); + master_mixer_l.gain(DELAY, mapfloat(configuration.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0)); eeprom_write(); break; case 120: @@ -1293,17 +1292,17 @@ void initial_values_from_eeprom(bool init) MicroDexed[instance_id]->setOPs(configuration.dexed[instance_id].op_enabled); MicroDexed[instance_id]->doRefreshVoice(); - chorus_send_mixer_r.gain(instance_id, configuration.dexed[instance_id].chorus_send / 200.0); - chorus_send_mixer_r.gain(instance_id, configuration.dexed[instance_id].chorus_send / 200.0); - delay_send_mixer_l.gain(instance_id, configuration.dexed[instance_id].delay_send / 200.0); - delay_send_mixer_l.gain(instance_id, configuration.dexed[instance_id].delay_send / 200.0); + chorus_send_mixer_r.gain(instance_id, configuration.dexed[instance_id].chorus_send / 100.0); + chorus_send_mixer_r.gain(instance_id, configuration.dexed[instance_id].chorus_send / 100.0); + delay_send_mixer_l.gain(instance_id, configuration.dexed[instance_id].delay_send / 100.0); + delay_send_mixer_l.gain(instance_id, configuration.dexed[instance_id].delay_send / 100.0); delay_fb_mixer_r.gain(0, 1.0); // original signal delay_fb_mixer_r.gain(1, mapfloat(configuration.delay_feedback, DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX, 0.0, 1.0)); // amount of feedback delay_fb_mixer_l.gain(0, 1.0); // original signal delay_fb_mixer_l.gain(1, mapfloat(configuration.delay_feedback, DELAY_FEEDBACK_MIN, DELAY_FEEDBACK_MAX, 0.0, 1.0)); // amount of feedback #if defined(USE_REVERB) - reverb_send_mixer_r.gain(instance_id, configuration.dexed[instance_id].reverb_send / 200.0); - reverb_send_mixer_l.gain(instance_id, configuration.dexed[instance_id].reverb_send / 200.0); + reverb_send_mixer_r.gain(instance_id, configuration.dexed[instance_id].reverb_send / 100.0); + reverb_send_mixer_l.gain(instance_id, configuration.dexed[instance_id].reverb_send / 100.0); #endif MicroDexed[instance_id]->setOPs(configuration.dexed[instance_id].op_enabled); @@ -1383,10 +1382,14 @@ 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); } - set_master_mixer_gain(CHORUS, configuration.chorus_level / 100.0); - set_master_mixer_gain(DELAY, configuration.delay_level / 100.0); + + master_mixer_r.gain(CHORUS, mapfloat(configuration.delay_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0)); + master_mixer_l.gain(CHORUS, mapfloat(configuration.delay_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0)); + master_mixer_r.gain(DELAY, mapfloat(configuration.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0)); + master_mixer_l.gain(DELAY, mapfloat(configuration.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0)); #if defined(USE_REVERB) - set_master_mixer_gain(REVERB, configuration.reverb_level / 100.0); + master_mixer_r.gain(REVERB, mapfloat(configuration.delay_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0)); + master_mixer_l.gain(REVERB, mapfloat(configuration.delay_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0)); #endif } @@ -1486,64 +1489,6 @@ uint32_t crc32(byte * calc_start, uint16_t calc_bytes) // base code from https:/ return (crc); } -void set_master_mixer_gain(uint8_t type, float level) -{ - master_mixer_level[type] = constrain(level, 0.0, 1.0); - -#if defined(USE_REVERB) - const uint8_t num_fx = 4; -#else - const uint8_t num_fx = 3; -#endif - - float new_level[num_fx]; - - /* - new_level[CHORUS] = master_mixer_level[CHORUS] / float(num_fx); - new_level[DELAY] = master_mixer_level[DELAY] / float(num_fx); - #if defined(USE_REVERB) - new_level[REVERB] = master_mixer_level[REVERB] / float(num_fx); - new_level[DEXED] = 1.0 - new_level[CHORUS] - new_level[DELAY] - new_level[REVERB]; - #else - new_level[DEXED] = 1.0 - new_level[CHORUS] - new_level[DELAY]; - #endif - */ - new_level[CHORUS] = master_mixer_level[CHORUS]; - new_level[DELAY] = master_mixer_level[DELAY]; - new_level[REVERB] = master_mixer_level[REVERB]; - new_level[DEXED] = 1.0; - - master_mixer_r.gain(DEXED, new_level[DEXED]); - master_mixer_l.gain(DEXED, new_level[DEXED]); - master_mixer_r.gain(CHORUS, new_level[CHORUS]); - master_mixer_l.gain(CHORUS, new_level[CHORUS]); - master_mixer_r.gain(DELAY, new_level[DELAY]); - master_mixer_l.gain(DELAY, new_level[DELAY]); -#if defined(USE_REVERB) - master_mixer_r.gain(REVERB, new_level[REVERB]); - master_mixer_l.gain(REVERB, new_level[REVERB]); -#endif - -#ifdef DEBUG - Serial.print(F("Volumes for master_mixer(type=")); - Serial.print(type, DEC); - Serial.print(F(",level=")); - Serial.print(level, 2); - Serial.print(F("): DEXED=")); - Serial.print(new_level[DEXED], 2); - Serial.print(F(" CHORUS=")); - Serial.print(new_level[CHORUS], 2); - Serial.print(F(" DELAY=")); - Serial.print(new_level[DELAY], 2); -#if defined(USE_REVERB) - Serial.print(F(" REVERB=")); - Serial.print(new_level[REVERB], 2); - -#endif - Serial.println(); -#endif -} - /****************************************************************************** DEBUG HELPER ******************************************************************************/ diff --git a/UI.hpp b/UI.hpp index 16b5de3..0ee088c 100644 --- a/UI.hpp +++ b/UI.hpp @@ -58,7 +58,6 @@ extern void strip_extension(char* s, char *target); extern void eeprom_write(void); extern bool get_voice_names_from_bank(uint8_t b, uint8_t instance_id); extern bool load_sysex(uint8_t b, uint8_t v); -extern void set_master_mixer_gain(uint8_t type, float level); #ifdef DISPLAY_LCD_SPI extern void change_disp_sd(bool d); #endif @@ -1109,8 +1108,8 @@ void UI_func_reverb_send(uint8_t param) } } - reverb_send_mixer_r.gain(instance_id, configuration.dexed[instance_id].reverb_send / 200.0); - reverb_send_mixer_l.gain(instance_id, configuration.dexed[instance_id].reverb_send / 200.0); + reverb_send_mixer_r.gain(instance_id, configuration.dexed[instance_id].reverb_send / 100.0); + reverb_send_mixer_l.gain(instance_id, configuration.dexed[instance_id].reverb_send / 100.0); } lcd.setCursor(0, 1); @@ -1171,9 +1170,8 @@ void UI_func_reverb_level(uint8_t param) } } - set_master_mixer_gain(REVERB, configuration.reverb_level / 100.0); - //master_mixer_r.gain(REVERB, mapfloat(configuration.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0)); - //master_mixer_l.gain(REVERB, mapfloat(configuration.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0)); + master_mixer_r.gain(REVERB, mapfloat(configuration.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0)); + master_mixer_l.gain(REVERB, mapfloat(configuration.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0)); } lcd.setCursor(0, 1); @@ -1441,9 +1439,8 @@ void UI_func_chorus_level(uint8_t param) } } - set_master_mixer_gain(CHORUS, configuration.chorus_level / 100.0); - //master_mixer_r.gain(CHORUS, mapfloat(configuration.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0)); - //master_mixer_l.gain(CHORUS, mapfloat(configuration.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0)); + master_mixer_r.gain(CHORUS, mapfloat(configuration.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0)); + master_mixer_l.gain(CHORUS, mapfloat(configuration.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0)); } lcd.setCursor(0, 1); @@ -1597,8 +1594,8 @@ void UI_func_delay_send(uint8_t param) } } - delay_send_mixer_r.gain(instance_id, configuration.dexed[instance_id].delay_send / 200.0); - delay_send_mixer_l.gain(instance_id, configuration.dexed[instance_id].delay_send / 200.0); + delay_send_mixer_r.gain(instance_id, configuration.dexed[instance_id].delay_send / 100.0); + delay_send_mixer_l.gain(instance_id, configuration.dexed[instance_id].delay_send / 100.0); } lcd.setCursor(0, 1); @@ -1650,9 +1647,8 @@ void UI_func_delay_level(uint8_t param) } } - set_master_mixer_gain(DELAY, configuration.delay_level / 100.0); - //master_mixer_r.gain(DELAY, mapfloat(configuration.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0)); - //master_mixer_l.gain(DELAY, mapfloat(configuration.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0)); + master_mixer_r.gain(DELAY, mapfloat(configuration.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0)); + master_mixer_l.gain(DELAY, mapfloat(configuration.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0)); } lcd.setCursor(0, 1);