From 67826b21ed32e85c5f3fdaec505ca1e6a0e7a082 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Wed, 3 Nov 2021 15:55:34 +0100 Subject: [PATCH] Small fixes. --- MicroDexed.ino | 63 ++++++++++++++++++++++++++------------------------ UI.hpp | 18 +++++++-------- config.h | 9 ++++++++ 3 files changed, 51 insertions(+), 39 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index 5752117..f924509 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -61,7 +61,9 @@ using namespace TeensyTimerTool; // Audio engines AudioSynthDexed* MicroDexed[NUM_DEXED]; +#if defined(USE_EPIANO) AudioSynthEPiano ep(NUM_EPIANO_VOICES); +#endif #if defined(USE_FX) AudioSynthWaveform* chorus_modulator[NUM_DEXED]; @@ -108,11 +110,11 @@ AudioEffectFreeverbStereoFloat freeverb; #endif #if defined(USE_EPIANO) -AudioMixer<4> master_mixer_r; -AudioMixer<4> master_mixer_l; -#else AudioMixer<5> master_mixer_r; AudioMixer<5> master_mixer_l; +#else +AudioMixer<4> master_mixer_r; +AudioMixer<4> master_mixer_l; #endif AudioAmplifier volume_r; AudioAmplifier volume_l; @@ -179,13 +181,13 @@ AudioConnection patchCord[] = { #ifdef USE_PLATEREVERB {reverb_mixer_r, 0, reverb, 0}, {reverb_mixer_l, 0, reverb, 1}, - {reverb, 0, master_mixer_r, 3}, - {reverb, 1, master_mixer_l, 3}, + {reverb, 0, master_mixer_r, CH_REVERB}, + {reverb, 1, master_mixer_l, CH_REVERB}, #else {reverb_mixer_r, 0, freeverb, 0}, {reverb_mixer_l, 0, freeverb, 1}, - {freeverb, 0, master_mixer_r, 3}, - {freeverb, 1, master_mixer_l, 3}, + {freeverb, 0, master_mixer_r, CH_REVERB}, + {freeverb, 1, master_mixer_l, CH_REVERB}, #endif #endif {master_mixer_r, volume_r}, @@ -236,11 +238,11 @@ AudioConnection patchCord[] = { #ifdef USE_FX {drum_reverb_send_mixer_r, 0, reverb_mixer_r, 2}, {drum_reverb_send_mixer_l, 0, reverb_mixer_l, 2}, - {drum_mixer_r, 0, master_mixer_r, 2}, - {drum_mixer_l, 0, master_mixer_l, 2}, + {drum_mixer_r, 0, master_mixer_r, CH_DRUMS}, + {drum_mixer_l, 0, master_mixer_l, CH_DRUMS}, #else - {drum_mixer_r, 0, master_mixer_r, 2}, - {drum_mixer_l, 0, master_mixer_l, 2}, + {drum_mixer_r, 0, master_mixer_r, CH_DRUMS}, + {drum_mixer_l, 0, master_mixer_l, CH_DRUMS}, #endif #endif @@ -264,8 +266,8 @@ AudioConnection patchCord[] = { {ep_chorus_mixer_r, 0, reverb_mixer_r, 3}, {ep_chorus_mixer_l, 0, reverb_mixer_l, 3}, #else - {ep, 0, master_mixer_r, 4}, - {ep, 1, master_mixer_l, 4}, + {ep, 0, master_mixer_r, CH_EPIANO}, + {ep, 1, master_mixer_l, CH_EPIANO}, #endif #endif }; @@ -580,7 +582,6 @@ void setup() // Setup EPiano #if defined(USE_FX) #if defined(USE_EPIANO) - // EP_CHORUS memset(ep_delayline_r, 0, sizeof(ep_delayline_r)); if (!ep_modchorus_r.begin(ep_delayline_r, MOD_DELAY_SAMPLE_BUFFER)) @@ -714,24 +715,24 @@ void setup() master_mixer_l.gain(instance_id, VOL_MAX_FLOAT); } #else - master_mixer_r.gain(0, VOL_MAX_FLOAT); - master_mixer_l.gain(0, VOL_MAX_FLOAT); - master_mixer_r.gain(1, 0.0); - master_mixer_l.gain(1, 0.0); + master_mixer_r.gain(CH_DEXED1, VOL_MAX_FLOAT); + master_mixer_l.gain(CH_DEXED1, VOL_MAX_FLOAT); + master_mixer_r.gain(CH_DEXED2, 0.0); + master_mixer_l.gain(CH_DEXED2, 0.0); #endif + master_mixer_r.gain(CH_REVERB, VOL_MAX_FLOAT); + master_mixer_l.gain(CH_REVERB, VOL_MAX_FLOAT); #if NUM_DRUMS > 0 - master_mixer_r.gain(2, VOL_MAX_FLOAT); - master_mixer_l.gain(2, VOL_MAX_FLOAT); + master_mixer_r.gain(CH_DRUMS, VOL_MAX_FLOAT); + master_mixer_l.gain(CH_DRUMS, VOL_MAX_FLOAT); seq.drums_volume = VOL_MAX_FLOAT; #else - master_mixer_r.gain(2, 0.0); - master_mixer_l.gain(2, 0.0); + master_mixer_r.gain(CH_DRUMS, 0.0); + master_mixer_l.gain(CH_DRUMS, 0.0); #endif - master_mixer_r.gain(3, VOL_MAX_FLOAT); - master_mixer_l.gain(3, VOL_MAX_FLOAT); #if defined(USE_EPIANO) - master_mixer_r.gain(4, VOL_MAX_FLOAT); - master_mixer_l.gain(4, VOL_MAX_FLOAT); + master_mixer_r.gain(CH_EPIANO, VOL_MAX_FLOAT); + master_mixer_l.gain(CH_EPIANO, VOL_MAX_FLOAT); #endif #if defined(TEENSY_AUDIO_BOARD) && defined(SGTL5000_AUDIO_THRU) @@ -760,6 +761,8 @@ void setup() void loop() { + master_mixer_r.gain(CH_EPIANO, VOL_MAX_FLOAT); + master_mixer_l.gain(CH_EPIANO, VOL_MAX_FLOAT); // MIDI input handling check_midi_devices(); @@ -2012,8 +2015,8 @@ void init_MIDI_send_CC(void) void set_drums_volume(float vol) { - master_mixer_r.gain(2, vol); - master_mixer_l.gain(2, vol); + master_mixer_r.gain(CH_DRUMS, vol); + master_mixer_l.gain(CH_DRUMS, vol); } void set_volume(uint8_t v, uint8_t m) { @@ -2561,8 +2564,8 @@ void set_fx_params(void) ep_chorus_inverter.gain(-1.0); #endif - master_mixer_r.gain(3, volume_transform(mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, VOL_MAX_FLOAT))); - master_mixer_l.gain(3, volume_transform(mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, VOL_MAX_FLOAT))); + master_mixer_r.gain(CH_REVERB, volume_transform(mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, VOL_MAX_FLOAT))); + master_mixer_l.gain(CH_REVERB, volume_transform(mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, VOL_MAX_FLOAT))); #endif #ifdef SGTL5000_AUDIO_ENHANCE diff --git a/UI.hpp b/UI.hpp index 973b618..2022651 100644 --- a/UI.hpp +++ b/UI.hpp @@ -139,11 +139,11 @@ extern AudioMixer<2> ep_delay_mixer_l; #endif #if defined(USE_EPIANO) -extern AudioMixer<4> master_mixer_r; -extern AudioMixer<4> master_mixer_l; -#else extern AudioMixer<5> master_mixer_r; extern AudioMixer<5> master_mixer_l; +#else +extern AudioMixer<4> master_mixer_r; +extern AudioMixer<4> master_mixer_l; #endif extern AudioEffectStereoMono stereo2mono; extern AudioAnalyzePeak master_peak_r; @@ -1305,10 +1305,10 @@ void UI_func_reverb_level(uint8_t param) lcd_display_bar_int("Reverb Level", configuration.fx.reverb_level, 1.0, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 3, false, false, true); - //master_mixer_r.gain(3, pseudo_log_curve(mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0))); - //master_mixer_l.gain(3, pseudo_log_curve(mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0))); - master_mixer_r.gain(3, volume_transform(mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, VOL_MAX_FLOAT))); - master_mixer_l.gain(3, volume_transform(mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, VOL_MAX_FLOAT))); + //master_mixer_r.gain(CH_REVERB, pseudo_log_curve(mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0))); + //master_mixer_l.gain(CH_REVERB, pseudo_log_curve(mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, 1.0))); + master_mixer_r.gain(CH_REVERB, volume_transform(mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, VOL_MAX_FLOAT))); + master_mixer_l.gain(CH_REVERB, volume_transform(mapfloat(configuration.fx.reverb_level, REVERB_LEVEL_MIN, REVERB_LEVEL_MAX, 0.0, VOL_MAX_FLOAT))); } if (LCDML.FUNC_close()) // ****** STABLE END ********* @@ -3672,8 +3672,8 @@ void UI_func_drums_main_volume(uint8_t param) lcd.print(displayname); lcd.setCursor(8, 1); lcd.print("/100"); - master_mixer_r.gain (2, volume_transform(mapfloat(temp_int, 0, 100, 0.0, VOL_MAX_FLOAT))); - master_mixer_l.gain (2, volume_transform(mapfloat(temp_int, 0, 100, 0.0, VOL_MAX_FLOAT))); + master_mixer_r.gain (CH_DRUMS, volume_transform(mapfloat(temp_int, 0, 100, 0.0, VOL_MAX_FLOAT))); + master_mixer_l.gain (CH_DRUMS, volume_transform(mapfloat(temp_int, 0, 100, 0.0, VOL_MAX_FLOAT))); seq.drums_volume = mapfloat(temp_int, 0, 100, 0.0, VOL_MAX_FLOAT); } if (LCDML.FUNC_close()) // ****** STABLE END ********* diff --git a/config.h b/config.h index ecbd239..db94fd3 100644 --- a/config.h +++ b/config.h @@ -904,6 +904,15 @@ typedef struct configuration_s { fx_t fx; } config_t; + +enum master_mixer_ports { + CH_DEXED2, + CH_DEXED1, + CH_REVERB, + CH_DRUMS, + CH_EPIANO +}; + #if !defined(_MAPFLOAT) #define _MAPFLOAT inline float mapfloat(float val, float in_min, float in_max, float out_min, float out_max)