@ -39,29 +39,29 @@
boolean AudioEffectModulatedDelay : : begin ( short * delayline , int d_length )
boolean AudioEffectModulatedDelay : : begin ( short * delayline , int d_length )
{
{
#if 0
#if 0
Serial . print ( " 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 ( " ) " ) ;
Serial . println ( F ( " ) " ) ;
# endif
# endif
_delayline = NULL ;
_delayline = NULL ;
_delay_length = 0 ;
_delay_length = 0 ;
_circ_idx = 0 ;
_circ_idx = 0 ;
if ( delayline = = NULL ) {
if ( delayline = = NULL ) {
return ( false ) ;
return ( false ) ;
}
}
if ( d_length < 10 ) {
if ( d_length < 10 ) {
return ( false ) ;
return ( false ) ;
}
}
_delayline = delayline ;
_delayline = delayline ;
_delay_length = _max_delay_length = d_length ;
_delay_length = _max_delay_length = 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 ) ;
return ( true ) ;
return ( true ) ;
}
}
void AudioEffectModulatedDelay : : update ( void )
void AudioEffectModulatedDelay : : update ( void )
@ -136,7 +136,7 @@ void AudioEffectModulatedDelay::update(void)
* 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 ;
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 + c_mod_idx ] ;
else
else
@ -144,7 +144,7 @@ void AudioEffectModulatedDelay::update(void)
# endif
# endif
# 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 ;
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 + c_mod_idx ] ;
else
else
@ -167,13 +167,8 @@ void AudioEffectModulatedDelay::update(void)
release ( modulation ) ;
release ( modulation ) ;
}
}
void AudioEffectModulatedDelay : : setDelayLength ( float milliseconds )
void AudioEffectModulatedDelay : : setDelay ( float milliseconds )
{
{
_delay_length = min ( AUDIO_SAMPLE_RATE / milliseconds , _max_delay_length ) ;
_delay_length = min ( AUDIO_SAMPLE_RATE * milliseconds / 500 , _max_delay_length ) ;
_delay_length_half = _delay_length / 2 ;
_delay_length_half = _delay_length / 2 ;
}
}
float AudioEffectModulatedDelay : : getMaxDelayLength ( void )
{
return ( AUDIO_SAMPLE_RATE / _max_delay_length ) ;
}