From 27d9adb0a1b50eaf8380683a7a7c97d8e2e18bab Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Fri, 27 Sep 2019 10:50:41 +0200 Subject: [PATCH] Fix for modulated delay. --- MicroMDAEPiano.ino | 7 ++++++- config.h | 4 ++-- effect_modulated_delay.cpp | 12 +++++------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/MicroMDAEPiano.ino b/MicroMDAEPiano.ino index e69770e..05d0e9e 100644 --- a/MicroMDAEPiano.ino +++ b/MicroMDAEPiano.ino @@ -239,11 +239,16 @@ void setup() Serial.println(F("AudioEffectModulatedDelay - left channel begin failed")); while (1); } +#ifdef DEBUG + Serial.print(F("MOD_DELAY_SAMPLE_BUFFER=")); + Serial.print(MOD_DELAY_SAMPLE_BUFFER, DEC); + Serial.println(F(" samples")); +#endif // chorus modulation fixed modulator.begin(MOD_WAVEFORM); modulator.phase(0); - modulator.amplitude(0.0); + modulator.amplitude(0.5); modulator.offset(0.0); #if MOD_FILTER_OUTPUT == MOD_BUTTERWORTH_FILTER_OUTPUT // Butterworth filter, 12 db/octave diff --git a/config.h b/config.h index c1a963a..c9256cd 100644 --- a/config.h +++ b/config.h @@ -76,7 +76,7 @@ #define SERIAL_SPEED 38400 #define SHOW_XRUN 1 #define SHOW_CPU_LOAD_MSEC 5000 -//#define DEBUG_AUDIO 50 +#define DEBUG_AUDIO 50 //************************************************************************************************* //* HARDWARE SETTINGS @@ -275,7 +275,7 @@ #define ENC_REVERB_DAMPING_MAX 99 #define ENC_REVERB_DAMPING_DEFAULT 50 // -#define ENC_REVERB_LEVEL_MIN 0 +#define ENC_REVERB_LEVEL_MIN 1 #define ENC_REVERB_LEVEL_MAX 99 #define ENC_REVERB_LEVEL_DEFAULT 15 // diff --git a/effect_modulated_delay.cpp b/effect_modulated_delay.cpp index 84bb5bb..d9a1f99 100644 --- a/effect_modulated_delay.cpp +++ b/effect_modulated_delay.cpp @@ -50,17 +50,15 @@ boolean AudioEffectModulatedDelay::begin(short *delayline, uint16_t d_length) _cb_index = 0; _delay_offset = 0; - if (delayline == NULL) { + if (delayline == NULL) return (false); - } - if (d_length < 10) { + if (d_length < 10) return (false); - } _delayline = delayline; _delay_length = d_length; - memset(_delayline, 0, _delay_length); - _delay_offset = (_delay_length - 1) >> 1; + memset(_delayline, 0, _delay_length * sizeof(int16_t)); + _delay_offset = _delay_length >> 1 ; return (true); } @@ -107,7 +105,7 @@ void AudioEffectModulatedDelay::update(void) mod_fraction = modff(mod_index, &mod_number); // split float of mod_index into integer (= mod_number) and fraction part // calculate modulation index into circular buffer - cb_mod_index = _cb_index - mod_number; + cb_mod_index = _cb_index - (_delay_offset + mod_number); if (cb_mod_index < 0) // check for negative offsets and correct them cb_mod_index += _delay_length;