Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial
00001 #ifndef STK_JCREV_H 00002 #define STK_JCREV_H 00003 00004 #include "Effect.h" 00005 #include "Delay.h" 00006 00007 namespace stk { 00008 00009 /***************************************************/ 00022 /***************************************************/ 00023 00024 class JCRev : public Effect 00025 { 00026 public: 00028 JCRev( StkFloat T60 = 1.0 ); 00029 00031 void clear( void ); 00032 00034 void setT60( StkFloat T60 ); 00035 00037 00045 StkFloat lastOut( unsigned int channel = 0 ); 00046 00048 00055 StkFloat tick( StkFloat input, unsigned int channel = 0 ); 00056 00058 00067 StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ); 00068 00070 00079 StkFrames& tick( StkFrames& iFrames, StkFrames &oFrames, unsigned int iChannel = 0, unsigned int oChannel = 0 ); 00080 00081 protected: 00082 00083 Delay allpassDelays_[3]; 00084 Delay combDelays_[4]; 00085 Delay outLeftDelay_; 00086 Delay outRightDelay_; 00087 StkFloat allpassCoefficient_; 00088 StkFloat combCoefficient_[4]; 00089 00090 }; 00091 00092 inline StkFloat JCRev :: lastOut( unsigned int channel ) 00093 { 00094 #if defined(_STK_DEBUG_) 00095 if ( channel > 1 ) { 00096 errorString_ << "JCRev::lastOut(): channel argument must be less than 2!"; 00097 handleError( StkError::FUNCTION_ARGUMENT ); 00098 } 00099 #endif 00100 00101 return lastFrame_[channel]; 00102 } 00103 00104 inline StkFloat JCRev :: tick( StkFloat input, unsigned int channel ) 00105 { 00106 #if defined(_STK_DEBUG_) 00107 if ( channel > 1 ) { 00108 errorString_ << "JCRev::tick(): channel argument must be less than 2!"; 00109 handleError( StkError::FUNCTION_ARGUMENT ); 00110 } 00111 #endif 00112 00113 StkFloat temp, temp0, temp1, temp2, temp3, temp4, temp5, temp6; 00114 StkFloat filtout; 00115 00116 temp = allpassDelays_[0].lastOut(); 00117 temp0 = allpassCoefficient_ * temp; 00118 temp0 += input; 00119 allpassDelays_[0].tick(temp0); 00120 temp0 = -(allpassCoefficient_ * temp0) + temp; 00121 00122 temp = allpassDelays_[1].lastOut(); 00123 temp1 = allpassCoefficient_ * temp; 00124 temp1 += temp0; 00125 allpassDelays_[1].tick(temp1); 00126 temp1 = -(allpassCoefficient_ * temp1) + temp; 00127 00128 temp = allpassDelays_[2].lastOut(); 00129 temp2 = allpassCoefficient_ * temp; 00130 temp2 += temp1; 00131 allpassDelays_[2].tick(temp2); 00132 temp2 = -(allpassCoefficient_ * temp2) + temp; 00133 00134 temp3 = temp2 + (combCoefficient_[0] * combDelays_[0].lastOut()); 00135 temp4 = temp2 + (combCoefficient_[1] * combDelays_[1].lastOut()); 00136 temp5 = temp2 + (combCoefficient_[2] * combDelays_[2].lastOut()); 00137 temp6 = temp2 + (combCoefficient_[3] * combDelays_[3].lastOut()); 00138 00139 combDelays_[0].tick(temp3); 00140 combDelays_[1].tick(temp4); 00141 combDelays_[2].tick(temp5); 00142 combDelays_[3].tick(temp6); 00143 00144 filtout = temp3 + temp4 + temp5 + temp6; 00145 00146 lastFrame_[0] = effectMix_ * (outLeftDelay_.tick(filtout)); 00147 lastFrame_[1] = effectMix_ * (outRightDelay_.tick(filtout)); 00148 temp = (1.0 - effectMix_) * input; 00149 lastFrame_[0] += temp; 00150 lastFrame_[1] += temp; 00151 00152 return lastFrame_[channel]; 00153 } 00154 00155 } // stk namespace 00156 00157 #endif 00158
The Synthesis ToolKit in C++ (STK) |
©1995-2010 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |