|
|
|
@ -58,7 +58,7 @@ boolean AudioEffectModulatedDelay::begin(short *delayline, int d_length) |
|
|
|
|
_delay_length = d_length; |
|
|
|
|
_delay_length_half = d_length / 2; |
|
|
|
|
|
|
|
|
|
memset(_delayline, 0, sizeof(short)*_delay_length); |
|
|
|
|
memset(_delayline, 0, sizeof(int16_t)*_delay_length); |
|
|
|
|
|
|
|
|
|
return (true); |
|
|
|
|
} |
|
|
|
@ -69,8 +69,8 @@ void AudioEffectModulatedDelay::update(void) |
|
|
|
|
audio_block_t *block; |
|
|
|
|
audio_block_t *modulation; |
|
|
|
|
|
|
|
|
|
short *bp; |
|
|
|
|
short *mp; |
|
|
|
|
int16_t *bp; |
|
|
|
|
int16_t *mp; |
|
|
|
|
float mod_idx; |
|
|
|
|
|
|
|
|
|
if (_delayline == NULL) |
|
|
|
@ -83,8 +83,6 @@ void AudioEffectModulatedDelay::update(void) |
|
|
|
|
block = receiveWritable(0); |
|
|
|
|
modulation = receiveReadOnly(1); |
|
|
|
|
|
|
|
|
|
if (block && modulation) |
|
|
|
|
{ |
|
|
|
|
#ifdef INTERPOLATE |
|
|
|
|
int8_t j; |
|
|
|
|
float x[INTERPOLATION_WINDOW_SIZE]; |
|
|
|
@ -94,13 +92,15 @@ void AudioEffectModulatedDelay::update(void) |
|
|
|
|
modulation_interpolate.valueY(y); |
|
|
|
|
|
|
|
|
|
for (j = 0; j < INTERPOLATION_WINDOW_SIZE; j++) |
|
|
|
|
x[j] = j; |
|
|
|
|
x[j] = float(j); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
bp = block->data; |
|
|
|
|
mp = modulation->data; |
|
|
|
|
|
|
|
|
|
for (int i = 0; i < AUDIO_BLOCK_SAMPLES; i++) |
|
|
|
|
if (block && modulation) |
|
|
|
|
{ |
|
|
|
|
for (uint16_t i = 0; i < AUDIO_BLOCK_SAMPLES; i++) |
|
|
|
|
{ |
|
|
|
|
// write data into circular buffer
|
|
|
|
|
if (_circ_idx >= _delay_length) |
|
|
|
@ -117,15 +117,17 @@ void AudioEffectModulatedDelay::update(void) |
|
|
|
|
#ifdef INTERPOLATE |
|
|
|
|
// get x/y values around mod_idx
|
|
|
|
|
uint16_t i_mod_idx = int(mod_idx + 0.5); |
|
|
|
|
uint8_t c = 0; |
|
|
|
|
for (j = INTERPOLATION_WINDOW_SIZE / -2; j <= INTERPOLATION_WINDOW_SIZE / 2; j++) |
|
|
|
|
{ |
|
|
|
|
int16_t ji_mod_idx = i_mod_idx + j; |
|
|
|
|
if (ji_mod_idx > _delay_length) |
|
|
|
|
y[j] = _delayline[ji_mod_idx - _delay_length - 1]; |
|
|
|
|
y[c] = float(_delayline[ji_mod_idx - _delay_length - 1]); |
|
|
|
|
else if (ji_mod_idx < 0) |
|
|
|
|
y[j] = _delayline[_delay_length + j + 1]; |
|
|
|
|
y[c] = float(_delayline[_delay_length + j + 1]); |
|
|
|
|
else |
|
|
|
|
y[j] = _delayline[ji_mod_idx]; |
|
|
|
|
y[c] = float(_delayline[ji_mod_idx]); |
|
|
|
|
c++; // ;-)
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
modulation_interpolate.valueI(mod_idx); |
|
|
|
@ -155,8 +157,12 @@ void AudioEffectModulatedDelay::update(void) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// transmit the block
|
|
|
|
|
if (block) |
|
|
|
|
{ |
|
|
|
|
transmit(block, 0); |
|
|
|
|
release(block); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (modulation) |
|
|
|
|
release(modulation); |
|
|
|
|
} |
|
|
|
|