Holger Wirtz 5 years ago
parent 263047aee4
commit 2d348affa1
  1. 10
      effect_modulated_delay.cpp

@ -65,6 +65,8 @@ void AudioEffectModulatedDelay::update(void)
{
audio_block_t *block;
audio_block_t *modulation;
float alpha = 0.9f; // 90% new value, 10% feedback
static float filteredOutput;
if (_delayline == NULL)
return;
@ -92,8 +94,12 @@ void AudioEffectModulatedDelay::update(void)
_cb_index = 0;
_delayline[_cb_index] = *bp;
// Simple 1st order IIR, mix the new value with the old value (for modulation to get a band-limited signal)
filteredOutput = (*mp * alpha) + filteredOutput * (1 - alpha);
// Calculate the modulation-index as a floating point number for interpolation
mod_index = *mp * (1 - MODULATION_MAX_FACTOR) * _delay_length; // "(1 - MODULATION_MAX_FACTOR) * _delay_length" means: maximum bytes of modulation allowed by given delay length
//mod_index = *mp * (1 - MODULATION_MAX_FACTOR) * _delay_length; // "(1 - MODULATION_MAX_FACTOR) * _delay_length" means: maximum bytes of modulation allowed by given delay length
mod_index = filteredOutput * (1 - MODULATION_MAX_FACTOR) * _delay_length; // "(1 - MODULATION_MAX_FACTOR) * _delay_length" means: maximum bytes of modulation allowed by given delay length
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
@ -102,7 +108,7 @@ void AudioEffectModulatedDelay::update(void)
cb_mod_index += _delay_length;
*bp = round(float(_delayline[cb_mod_index]) * mod_fraction + float(_delayline[cb_mod_index + 1]) * (1.0 - mod_fraction));
// push the pointers forward
bp++; // next audio data
mp++; // next modulation data

Loading…
Cancel
Save