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