From c7a77470a7c599d3dda0e58bb4565e1dad3e48bb Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Tue, 5 May 2020 16:07:40 +0200 Subject: [PATCH] Adding cross-fading for chorus mix-in. --- MicroDexed.ino | 21 +++++++++++++-------- UI.hpp | 8 ++++++-- config.h | 4 ++-- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index a23cbfb..2343f28 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -218,6 +218,7 @@ char sd_string[LCD_cols + 1]; char g_voice_name[NUM_DEXED][VOICE_NAME_LEN]; char g_bank_name[NUM_DEXED][BANK_NAME_LEN]; char receive_bank_filename[FILENAME_LEN]; +const float _pseudo_log = 1048575 / (float)(1 << 20); #if defined(USE_FX) // Allocate the delay lines for chorus @@ -1399,10 +1400,10 @@ void initial_values_from_eeprom(bool init) Serial.println(F("OK, loaded!")); #endif - master_mixer_r.gain(DEXED, 1.0); - master_mixer_l.gain(DEXED, 1.0); - master_mixer_r.gain(CHORUS, mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0)); - master_mixer_l.gain(CHORUS, mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0)); + master_mixer_r.gain(DEXED, _pseudo_log * arm_sin_f32(1.0 - mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5))); + master_mixer_l.gain(DEXED, _pseudo_log * arm_sin_f32(1.0 - mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5))); + master_mixer_r.gain(CHORUS, _pseudo_log * arm_cos_f32(mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5))); + master_mixer_l.gain(CHORUS, _pseudo_log * arm_cos_f32(mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5))); master_mixer_r.gain(DELAY, mapfloat(configuration.fx.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0)); master_mixer_l.gain(DELAY, mapfloat(configuration.fx.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0)); master_mixer_r.gain(REVERB, mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0)); @@ -1483,8 +1484,10 @@ void check_configuration(void) configuration.dexed[instance_id].op_enabled = constrain(configuration.dexed[instance_id].op_enabled, OP_ENABLED_MIN, OP_ENABLED_MAX); } - master_mixer_r.gain(CHORUS, mapfloat(configuration.fx.delay_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0)); - master_mixer_l.gain(CHORUS, mapfloat(configuration.fx.delay_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0)); + master_mixer_r.gain(DEXED, _pseudo_log * arm_sin_f32(1.0 - mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5))); + master_mixer_l.gain(DEXED, _pseudo_log * arm_sin_f32(1.0 - mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5))); + master_mixer_r.gain(CHORUS, _pseudo_log * arm_cos_f32(mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5))); + master_mixer_l.gain(CHORUS, _pseudo_log * arm_cos_f32(mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5))); master_mixer_r.gain(DELAY, mapfloat(configuration.fx.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0)); master_mixer_l.gain(DELAY, mapfloat(configuration.fx.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0)); master_mixer_r.gain(REVERB, mapfloat(configuration.fx.delay_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0)); @@ -1690,8 +1693,10 @@ bool eeprom_get_performance() void set_fx_params(void) { - master_mixer_r.gain(CHORUS, mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0)); - master_mixer_l.gain(CHORUS, mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0)); + master_mixer_r.gain(DEXED, _pseudo_log * arm_sin_f32(1.0 - mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5))); + master_mixer_l.gain(DEXED, _pseudo_log * arm_sin_f32(1.0 - mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5))); + master_mixer_r.gain(CHORUS, _pseudo_log * arm_cos_f32(mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5))); + master_mixer_l.gain(CHORUS, _pseudo_log * arm_cos_f32(mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5))); master_mixer_r.gain(DELAY, mapfloat(configuration.fx.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0)); master_mixer_l.gain(DELAY, mapfloat(configuration.fx.delay_level, DELAY_LEVEL_MIN, DELAY_LEVEL_MAX, 0.0, 1.0)); master_mixer_r.gain(REVERB, mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0)); diff --git a/UI.hpp b/UI.hpp index 917b3e6..90ef2ac 100644 --- a/UI.hpp +++ b/UI.hpp @@ -90,6 +90,7 @@ extern char sd_string[LCD_cols + 1]; extern char g_voice_name[NUM_DEXED][VOICE_NAME_LEN]; extern char g_bank_name[NUM_DEXED][BANK_NAME_LEN]; extern char receive_bank_filename[FILENAME_LEN]; +extern const float _pseudo_log; /*********************************************************************** GLOBAL @@ -1190,8 +1191,11 @@ void UI_func_chorus_level(uint8_t param) lcd_display_bar_int("Chorus Lvl.", configuration.fx.chorus_level, 1.0, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 3, false, false, false, false); - master_mixer_r.gain(CHORUS, mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0)); - master_mixer_l.gain(CHORUS, mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 1.0)); + master_mixer_r.gain(DEXED, _pseudo_log * arm_sin_f32(1.0 - mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5))); + master_mixer_l.gain(DEXED, _pseudo_log * arm_sin_f32(1.0 - mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5))); + master_mixer_r.gain(CHORUS, _pseudo_log * arm_cos_f32(mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5))); + master_mixer_l.gain(CHORUS, _pseudo_log * arm_cos_f32(mapfloat(configuration.fx.chorus_level, CHORUS_LEVEL_MIN, CHORUS_LEVEL_MAX, 0.0, 0.5))); + } if (LCDML.FUNC_close()) // ****** STABLE END ********* diff --git a/config.h b/config.h index a954b30..70a5f57 100644 --- a/config.h +++ b/config.h @@ -43,7 +43,7 @@ // Tools for testing MIDI: https://github.com/gbevin/SendMIDI // https://github.com/gbevin/ReceiveMIDI -#define VERSION "0.9.9a" +#define VERSION "0.9.9b" //************************************************************************************************* //* DEVICE SETTINGS @@ -80,7 +80,7 @@ //************************************************************************************************* //* DEBUG OUTPUT SETTINGS //************************************************************************************************* -#define DEBUG 1 +//#define DEBUG 1 #define SERIAL_SPEED 230400 #define SHOW_XRUN 1 #define SHOW_CPU_LOAD_MSEC 5000