From 7ff1c6575d0be105246002fe29e91d4f4089ef1f Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Tue, 19 May 2020 16:22:57 +0200 Subject: [PATCH] Trying to fix delay... --- MicroDexed.ino | 24 +++++++++++++++--------- UI.hpp | 1 + config.h | 2 ++ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/MicroDexed.ino b/MicroDexed.ino index ea0c24d..e46d55b 100644 --- a/MicroDexed.ino +++ b/MicroDexed.ino @@ -356,8 +356,6 @@ void setup() #endif #endif - initial_values_from_eeprom(false); - #if defined(USE_FX) // Init effects for (uint8_t instance_id = 0; instance_id < NUM_DEXED; instance_id++) @@ -379,6 +377,8 @@ void setup() #endif #endif + initial_values_from_eeprom(false); + // start SD card #ifdef DISPLAY_LCD_SPI change_disp_sd(false); @@ -1465,8 +1465,9 @@ void initial_values_from_eeprom(bool init) MicroDexed[instance_id]->fx.Gain = 1.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); + + dexed_level[instance_id]->gain(pseudo_log_curve(mapfloat(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, SOUND_INTENSITY_AMP_MAX))); */ - //dexed_level[instance_id]->gain(pseudo_log_curve(mapfloat(configuration.dexed[instance_id].sound_intensity, SOUND_INTENSITY_MIN, SOUND_INTENSITY_MAX, 0.0, SOUND_INTENSITY_AMP_MAX))); } set_fx_params(); set_sys_params(); @@ -1845,6 +1846,11 @@ void set_sys_params(void) HELPERS ******************************************************************************/ +float mapfloat(float val, float in_min, float in_max, float out_min, float out_max) +{ + return (val - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; +} + // https://www.reddit.com/r/Teensy/comments/7r19uk/reset_and_reboot_teensy_lc_via_code/ #define SCB_AIRCR (*(volatile uint32_t *)0xE000ED0C) // Application Interrupt and Reset Control location void _softRestart(void) @@ -1857,12 +1863,12 @@ float pseudo_log_curve(float value) { const float _pseudo_log = 1048575 / (float)(1 << 20); - /* #ifdef DEBUG - Serial.print(F("value in: ")); - Serial.print(value, 3); - Serial.print(F(" value out: ")); - Serial.println(mapfloat(_pseudo_log * arm_sin_f32(value), 0.0, _pseudo_log * arm_sin_f32(1.0), 0.0, 1.0), 3); - #endif */ +#ifdef DEBUG + Serial.print(F("value in: ")); + Serial.print(value, 3); + Serial.print(F(" value out: ")); + Serial.println(mapfloat(_pseudo_log * arm_sin_f32(value), 0.0, _pseudo_log * arm_sin_f32(1.0), 0.0, 1.0), 3); +#endif return (mapfloat(_pseudo_log * arm_sin_f32(value), 0.0, _pseudo_log * arm_sin_f32(1.0), 0.0, 1.0)); } diff --git a/UI.hpp b/UI.hpp index afa42b2..3f63fb0 100644 --- a/UI.hpp +++ b/UI.hpp @@ -57,6 +57,7 @@ extern void eeprom_update_performance(void); extern void eeprom_update_fx(void); extern void eeprom_update_dexed(uint8_t instance_id); extern float pseudo_log_curve(float value); +extern float mapfloat(float val, float in_min, float in_max, float out_min, float out_max); extern uint8_t selected_instance_id; #ifdef DISPLAY_LCD_SPI diff --git a/config.h b/config.h index 12b30fb..edca821 100644 --- a/config.h +++ b/config.h @@ -601,6 +601,7 @@ typedef struct configuration_s { uint32_t _marker_; } config_t; +/* #if !defined(_MAPFLOAT) #define _MAPFLOAT inline float mapfloat(float val, float in_min, float in_max, float out_min, float out_max) @@ -608,5 +609,6 @@ inline float mapfloat(float val, float in_min, float in_max, float out_min, floa return (val - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } #endif +*/ #endif // CONFIG_H_INCLUDED