|
|
@ -70,6 +70,11 @@ void AudioModulatedEffectChorus::update(void) |
|
|
|
short *mp; |
|
|
|
short *mp; |
|
|
|
float mod_idx; |
|
|
|
float mod_idx; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef INTERPOLATE |
|
|
|
|
|
|
|
interpolation* modulation_interpolate; |
|
|
|
|
|
|
|
modulation_interpolate = new interpolation; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
if (l_delayline == NULL) |
|
|
|
if (l_delayline == NULL) |
|
|
|
return; |
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
@ -81,8 +86,11 @@ void AudioModulatedEffectChorus::update(void) |
|
|
|
#ifdef INTERPOLATE |
|
|
|
#ifdef INTERPOLATE |
|
|
|
uint8_t j; |
|
|
|
uint8_t j; |
|
|
|
int16_t interpolation_idx; |
|
|
|
int16_t interpolation_idx; |
|
|
|
interpolation modulation_interpolate; |
|
|
|
float x[INTERPOLATION_WINDOW_SIZE]; |
|
|
|
modulation_interpolate.valuelenXY(INTERPOLATION_WINDOW_SIZE); |
|
|
|
float y[INTERPOLATION_WINDOW_SIZE]; |
|
|
|
|
|
|
|
modulation_interpolate->valuelenXY(INTERPOLATION_WINDOW_SIZE); |
|
|
|
|
|
|
|
modulation_interpolate->valueX(x); |
|
|
|
|
|
|
|
modulation_interpolate->valueY(y); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
bp = block->data; |
|
|
|
bp = block->data; |
|
|
@ -90,11 +98,6 @@ void AudioModulatedEffectChorus::update(void) |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < AUDIO_BLOCK_SAMPLES; i++) |
|
|
|
for (int i = 0; i < AUDIO_BLOCK_SAMPLES; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef INTERPOLATE |
|
|
|
|
|
|
|
float x[INTERPOLATION_WINDOW_SIZE]; |
|
|
|
|
|
|
|
float y[INTERPOLATION_WINDOW_SIZE]; |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// write data into circular buffer
|
|
|
|
// write data into circular buffer
|
|
|
|
if (l_circ_idx >= delay_length) |
|
|
|
if (l_circ_idx >= delay_length) |
|
|
|
l_circ_idx = 0; |
|
|
|
l_circ_idx = 0; |
|
|
@ -102,45 +105,43 @@ void AudioModulatedEffectChorus::update(void) |
|
|
|
|
|
|
|
|
|
|
|
// calculate modulation index
|
|
|
|
// calculate modulation index
|
|
|
|
mod_idx = float(*mp) / SHRT_MAX * delay_length_half + l_circ_idx; // calculate index with modulation as a float
|
|
|
|
mod_idx = float(*mp) / SHRT_MAX * delay_length_half + l_circ_idx; // calculate index with modulation as a float
|
|
|
|
if (mod_idx > delay_length) |
|
|
|
if (mod_idx > float(delay_length - 1)) |
|
|
|
mod_idx = mod_idx - delay_length; |
|
|
|
mod_idx = mod_idx - float(delay_length - 1); |
|
|
|
else if (mod_idx < 0) |
|
|
|
else if (mod_idx < 0.0) |
|
|
|
mod_idx = delay_length + mod_idx; |
|
|
|
mod_idx = float(delay_length - 1) + mod_idx; |
|
|
|
|
|
|
|
|
|
|
|
#ifdef INTERPOLATE |
|
|
|
#ifdef INTERPOLATE |
|
|
|
// get value with interpolation
|
|
|
|
// get value with interpolation
|
|
|
|
for (j = 0; j < INTERPOLATION_WINDOW_SIZE; j++) |
|
|
|
interpolation_idx = int(mod_idx + 0.5) + (INTERPOLATION_WINDOW_SIZE / -2); |
|
|
|
|
|
|
|
for (j = interpolation_idx; j < INTERPOLATION_WINDOW_SIZE; j++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
interpolation_idx = mod_idx + (INTERPOLATION_WINDOW_SIZE / -2) + j; |
|
|
|
|
|
|
|
if (interpolation_idx > delay_length) |
|
|
|
|
|
|
|
interpolation_idx = interpolation_idx - delay_length; |
|
|
|
|
|
|
|
else if (interpolation_idx < 0) |
|
|
|
|
|
|
|
interpolation_idx = delay_length + interpolation_idx; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
x[j] = interpolation_idx; |
|
|
|
x[j] = interpolation_idx; |
|
|
|
y[j] = l_delayline[interpolation_idx]; |
|
|
|
|
|
|
|
|
|
|
|
if (j >= delay_length) |
|
|
|
|
|
|
|
y[j] = l_delayline[j - delay_length]; |
|
|
|
|
|
|
|
else if (j < 0) |
|
|
|
|
|
|
|
y[j] = l_delayline[delay_length + j]; |
|
|
|
} |
|
|
|
} |
|
|
|
modulation_interpolate.valueX(x); |
|
|
|
|
|
|
|
modulation_interpolate.valueY(y); |
|
|
|
modulation_interpolate->valueI(mod_idx); |
|
|
|
modulation_interpolate.valueI(mod_idx); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if INTERPOLATE == CUBIC |
|
|
|
#if INTERPOLATE == CUBIC |
|
|
|
*bp = int(modulation_interpolate.CubicInterpolate() + 0.5); |
|
|
|
*bp = int(modulation_interpolate->CubicInterpolate() + 0.5); |
|
|
|
#elif INTERPOLATE == LINEAR |
|
|
|
#elif INTERPOLATE == LINEAR |
|
|
|
*bp = int(modulation_interpolate.LinearInterpolate() + 0.5); |
|
|
|
*bp = int(modulation_interpolate->LinearInterpolate() + 0.5); |
|
|
|
#elif INTERPOLATE == COSINE |
|
|
|
#elif INTERPOLATE == COSINE |
|
|
|
*bp = int(modulation_interpolate.CosineInterpolate() + 0.5); |
|
|
|
*bp = int(modulation_interpolate->CosineInterpolate() + 0.5); |
|
|
|
#elif INTERPOLATE == LAGRANGE |
|
|
|
#elif INTERPOLATE == LAGRANGE |
|
|
|
*bp = int(modulation_interpolate.LagrangeInterpolate() + 0.5); |
|
|
|
*bp = int(modulation_interpolate->LagrangeInterpolate() + 0.5); |
|
|
|
#elif INTERPOLATE == QUDRATIC |
|
|
|
#elif INTERPOLATE == QUDRATIC |
|
|
|
*bp = int(modulation_interpolate.QuadraticInterpolate() + 0.5); |
|
|
|
*bp = int(modulation_interpolate->QuadraticInterpolate() + 0.5); |
|
|
|
#else |
|
|
|
#else |
|
|
|
// No interpolation - should sound really bad...
|
|
|
|
// No interpolation - should sound really bad...
|
|
|
|
*bp = int(mod_idx + 0.5); |
|
|
|
*bp = l_delayline[int(mod_idx + 0.5)]; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#else |
|
|
|
#else |
|
|
|
// No interpolation - should sound really bad...
|
|
|
|
// No interpolation - should sound really bad...
|
|
|
|
*bp = int(mod_idx + 0.5); |
|
|
|
*bp = l_delayline[int(mod_idx + 0.5)]; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
bp++; |
|
|
|
bp++; |
|
|
@ -153,4 +154,9 @@ void AudioModulatedEffectChorus::update(void) |
|
|
|
release(block); |
|
|
|
release(block); |
|
|
|
release(modulation); |
|
|
|
release(modulation); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef INTERPOLATION |
|
|
|
|
|
|
|
if (modulation_interpolate) |
|
|
|
|
|
|
|
delete(modulation_interpolate); |
|
|
|
|
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|