@ -41,7 +41,7 @@ boolean AudioEffectModulatedDelay::begin(short *delayline, int d_length)
#if 0
#if 0
Serial . print ( F ( " AudioEffectModulatedDelay.begin(Chorus delay line length = " ) ) ;
Serial . print ( F ( " AudioEffectModulatedDelay.begin(Chorus delay line length = " ) ) ;
Serial . print ( d_length ) ;
Serial . print ( d_length ) ;
Serial . println ( F ( " ) " ) ;
Serial . println ( F ( " ) " ) ) ;
# endif
# endif
_delayline = NULL ;
_delayline = NULL ;
@ -60,6 +60,9 @@ boolean AudioEffectModulatedDelay::begin(short *delayline, int d_length)
_delay_length_half = _delay_length / 2 ;
_delay_length_half = _delay_length / 2 ;
memset ( _delayline , 0 , sizeof ( int16_t ) * _delay_length ) ;
memset ( _delayline , 0 , sizeof ( int16_t ) * _delay_length ) ;
# ifdef INTERPOLATE
modulation_interpolate = new interpolation ( ) ;
# endif
return ( true ) ;
return ( true ) ;
}
}
@ -76,10 +79,6 @@ void AudioEffectModulatedDelay::update(void)
if ( _delayline = = NULL )
if ( _delayline = = NULL )
return ;
return ;
# ifdef INTERPOLATE
interpolation modulation_interpolate ;
# endif
block = receiveWritable ( 0 ) ;
block = receiveWritable ( 0 ) ;
modulation = receiveReadOnly ( 1 ) ;
modulation = receiveReadOnly ( 1 ) ;
@ -87,9 +86,9 @@ void AudioEffectModulatedDelay::update(void)
int8_t j ;
int8_t j ;
float x [ INTERPOLATION_WINDOW_SIZE ] ;
float x [ INTERPOLATION_WINDOW_SIZE ] ;
float y [ INTERPOLATION_WINDOW_SIZE ] ;
float y [ INTERPOLATION_WINDOW_SIZE ] ;
modulation_interpolate . valuelenXY ( INTERPOLATION_WINDOW_SIZE ) ;
modulation_interpolate - > valuelenXY ( INTERPOLATION_WINDOW_SIZE ) ;
modulation_interpolate . valueX ( x ) ;
modulation_interpolate - > valueX ( x ) ;
modulation_interpolate . valueY ( y ) ;
modulation_interpolate - > valueY ( y ) ;
# endif
# endif
bp = block - > data ;
bp = block - > data ;
@ -122,23 +121,23 @@ void AudioEffectModulatedDelay::update(void)
c + + ; // because 42 is the answer! ;-)
c + + ; // because 42 is the answer! ;-)
}
}
modulation_interpolate . valueI ( mod_idx - int ( mod_idx + 0.5 ) ) ;
modulation_interpolate - > valueI ( mod_idx - int ( mod_idx + 0.5 ) ) ;
# if INTERPOLATE == LINEAR
# if INTERPOLATE == LINEAR
* bp = int ( modulation_interpolate . LinearInterpolate ( ) + 0.5 ) ;
* bp = int ( modulation_interpolate - > LinearInterpolate ( ) + 0.5 ) ;
# elif INTERPOLATE == QUDRATIC
# elif INTERPOLATE == QUDRATIC
* bp = int ( modulation_interpolate . QuadraticInterpolate ( ) + 0.5 ) ;
* bp = int ( modulation_interpolate - > QuadraticInterpolate ( ) + 0.5 ) ;
# elif INTERPOLATE == COSINE
# elif INTERPOLATE == COSINE
* bp = int ( modulation_interpolate . CosineInterpolate ( ) + 0.5 ) ;
* bp = int ( modulation_interpolate - > CosineInterpolate ( ) + 0.5 ) ;
# elif INTERPOLATE == CUBIC
# elif INTERPOLATE == CUBIC
* bp = int ( modulation_interpolate . CubicInterpolate ( ) + 0.5 ) ;
* bp = int ( modulation_interpolate - > CubicInterpolate ( ) + 0.5 ) ;
# elif INTERPOLATE == LAGRANGE
# elif INTERPOLATE == LAGRANGE
* bp = int ( modulation_interpolate . LagrangeInterpolate ( ) + 0.5 ) ;
* bp = int ( modulation_interpolate - > LagrangeInterpolate ( ) + 0.5 ) ;
# else
# else
// No interpolation - should sound really bad...
// No interpolation - should sound really bad...
int16_t c_mod_idx = ( int ( mod_idx + 0.5 ) + _circ_idx ) % _delay_length ;
int16_t c_mod_idx = ( int ( mod_idx + 0.5 ) + _circ_idx ) % _delay_length ;
if ( c_mod_idx < 0 )
if ( c_mod_idx < 0 )
* bp = _delayline [ _delay_length + c_mod_idx ] ;
* bp = _delayline [ _delay_length - 1 + c_mod_idx ] ;
else
else
* bp = _delayline [ c_mod_idx ] ;
* bp = _delayline [ c_mod_idx ] ;
# endif
# endif
@ -146,7 +145,7 @@ void AudioEffectModulatedDelay::update(void)
// No interpolation - should sound really bad...
// No interpolation - should sound really bad...
int16_t c_mod_idx = ( int ( mod_idx + 0.5 ) + _circ_idx ) % _delay_length ;
int16_t c_mod_idx = ( int ( mod_idx + 0.5 ) + _circ_idx ) % _delay_length ;
if ( c_mod_idx < 0 )
if ( c_mod_idx < 0 )
* bp = _delayline [ _delay_length + c_mod_idx ] ;
* bp = _delayline [ _delay_length - 1 + c_mod_idx ] ;
else
else
* bp = _delayline [ c_mod_idx ] ;
* bp = _delayline [ c_mod_idx ] ;
# endif
# endif