|
|
|
@ -23,7 +23,7 @@ |
|
|
|
|
|
|
|
|
|
#include <Arduino.h> |
|
|
|
|
#include "limits.h" |
|
|
|
|
#include "effect_modulated_chorus.h" |
|
|
|
|
#include "effect_modulated_delay.h" |
|
|
|
|
#include "interpolation.h" |
|
|
|
|
#include "config.h" |
|
|
|
|
|
|
|
|
@ -33,7 +33,7 @@ |
|
|
|
|
// Written by Pete (El Supremo) Jan 2014
|
|
|
|
|
// 140529 - change to handle mono stream - change modify() to voices()
|
|
|
|
|
// 140219 - correct storage class (not static)
|
|
|
|
|
// 190527 - added modulation input handling (by Holger Wirtz)
|
|
|
|
|
// 190527 - added modulation input (by Holger Wirtz)
|
|
|
|
|
|
|
|
|
|
boolean AudioEffectModulatedDelay::begin(short *delayline, int d_length) |
|
|
|
|
{ |
|
|
|
@ -90,9 +90,6 @@ void AudioEffectModulatedDelay::update(void) |
|
|
|
|
modulation_interpolate.valuelenXY(INTERPOLATION_WINDOW_SIZE); |
|
|
|
|
modulation_interpolate.valueX(x); |
|
|
|
|
modulation_interpolate.valueY(y); |
|
|
|
|
|
|
|
|
|
for (j = 0; j < INTERPOLATION_WINDOW_SIZE; j++) |
|
|
|
|
x[j] = float(j); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
bp = block->data; |
|
|
|
@ -108,24 +105,24 @@ void AudioEffectModulatedDelay::update(void) |
|
|
|
|
_delayline[_circ_idx] = *bp; |
|
|
|
|
|
|
|
|
|
// calculate modulation index
|
|
|
|
|
mod_idx = float(*mp) / SHRT_MAX * _delay_length_half + _circ_idx; // calculate index with modulation as a float(!!!)
|
|
|
|
|
if (mod_idx > float(_delay_length - 1)) |
|
|
|
|
mod_idx = mod_idx - float(_delay_length - 1); |
|
|
|
|
else if (mod_idx < 0.0) |
|
|
|
|
mod_idx = float(_delay_length - 1) + mod_idx; |
|
|
|
|
mod_idx = float(*mp) / SHRT_MAX * _delay_length_half; // calculate index with modulation as a float(!!!)
|
|
|
|
|
|
|
|
|
|
#ifdef INTERPOLATE |
|
|
|
|
// get x/y values around mod_idx
|
|
|
|
|
uint8_t c = 0; |
|
|
|
|
int16_t c_mod_idx = int(mod_idx + 0.5) + _circ_idx; |
|
|
|
|
for (j = INTERPOLATION_WINDOW_SIZE / -2; j <= INTERPOLATION_WINDOW_SIZE / 2; j++) |
|
|
|
|
{ |
|
|
|
|
y[c] = float(_delayline[(int(mod_idx + 0.5) + _circ_idx + j) % _delay_length]); |
|
|
|
|
if (y[c] < 0) |
|
|
|
|
y[c] = _delay_length + y[c]; |
|
|
|
|
int16_t jc_mod_idx = (c_mod_idx + j) % _delay_length; |
|
|
|
|
if (jc_mod_idx < 0) |
|
|
|
|
y[c] = float(_delayline[_delay_length + jc_mod_idx]); |
|
|
|
|
else |
|
|
|
|
y[c] = float(_delayline[jc_mod_idx]); |
|
|
|
|
x[c] = float(c); |
|
|
|
|
c++; // because 42 is the answer! ;-)
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
modulation_interpolate.valueI(mod_idx); |
|
|
|
|
modulation_interpolate.valueI(mod_idx - int(mod_idx + 0.5)); |
|
|
|
|
|
|
|
|
|
#if INTERPOLATE == CUBIC |
|
|
|
|
*bp = int(modulation_interpolate.CubicInterpolate() + 0.5); |
|
|
|
@ -139,11 +136,19 @@ void AudioEffectModulatedDelay::update(void) |
|
|
|
|
*bp = int(modulation_interpolate.QuadraticInterpolate() + 0.5); |
|
|
|
|
#else |
|
|
|
|
// No interpolation - should sound really bad...
|
|
|
|
|
*bp = _delayline[int(mod_idx + 0.5)]; |
|
|
|
|
int16_t c_mod_idx = int(mod_idx + 0.5) + _circ_idx; |
|
|
|
|
if (c_mod_idx < 0) |
|
|
|
|
*bp = _delayline[_delay_length + c_mod_idx]; |
|
|
|
|
else |
|
|
|
|
*bp = _delayline[c_mod_idx]; |
|
|
|
|
#endif |
|
|
|
|
#else |
|
|
|
|
// No interpolation - should sound really bad...
|
|
|
|
|
*bp = _delayline[int(mod_idx + 0.5)]; |
|
|
|
|
int16_t c_mod_idx = int(mod_idx + 0.5) + _circ_idx; |
|
|
|
|
if (c_mod_idx < 0) |
|
|
|
|
*bp = _delayline[_delay_length + c_mod_idx]; |
|
|
|
|
else |
|
|
|
|
*bp = _delayline[c_mod_idx]; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
bp++; |