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 *block;
audio_block_t *modulation; audio_block_t *modulation;
float alpha = 0.9f; // 90% new value, 10% feedback
static float filteredOutput;
if (_delayline == NULL) if (_delayline == NULL)
return; return;
@ -92,8 +94,12 @@ void AudioEffectModulatedDelay::update(void)
_cb_index = 0; _cb_index = 0;
_delayline[_cb_index] = *bp; _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 // 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 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 // calculate modulation index into circular buffer
@ -102,7 +108,7 @@ void AudioEffectModulatedDelay::update(void)
cb_mod_index += _delay_length; cb_mod_index += _delay_length;
*bp = round(float(_delayline[cb_mod_index]) * mod_fraction + float(_delayline[cb_mod_index + 1]) * (1.0 - mod_fraction)); *bp = round(float(_delayline[cb_mod_index]) * mod_fraction + float(_delayline[cb_mod_index + 1]) * (1.0 - mod_fraction));
// push the pointers forward // push the pointers forward
bp++; // next audio data bp++; // next audio data
mp++; // next modulation data mp++; // next modulation data

Loading…
Cancel
Save