1 /***************************************************/
2 /*! \class Echo
3     \brief STK echo effect class.
4 
5     This class implements an echo effect.
6 
7     by Perry R. Cook and Gary P. Scavone, 1995--2021.
8 */
9 /***************************************************/
10 
11 #include "Echo.h"
12 #include <iostream>
13 
14 namespace stk {
15 
Echo(unsigned long maximumDelay)16 Echo :: Echo( unsigned long maximumDelay ) : Effect()
17 {
18   this->setMaximumDelay( maximumDelay );
19   delayLine_.setDelay( length_ >> 1 );
20   effectMix_ = 0.5;
21   this->clear();
22 }
23 
clear(void)24 void Echo :: clear( void )
25 {
26   delayLine_.clear();
27   lastFrame_[0] = 0.0;
28 }
29 
setMaximumDelay(unsigned long delay)30 void Echo :: setMaximumDelay( unsigned long delay )
31 {
32   if ( delay == 0 ) {
33     oStream_ << "Echo::setMaximumDelay: parameter cannot be zero!";
34     handleError( StkError::WARNING ); return;
35   }
36 
37   length_ = delay;
38   delayLine_.setMaximumDelay( delay );
39 }
40 
setDelay(unsigned long delay)41 void Echo :: setDelay( unsigned long delay )
42 {
43   if ( delay > length_ ) {
44     oStream_ << "Echo::setDelay: parameter is greater than maximum delay length!";
45     handleError( StkError::WARNING ); return;
46   }
47 
48   delayLine_.setDelay( delay );
49 }
50 
51 } // stk namespace
52