Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


JCRev.h

00001 #ifndef STK_JCREV_H
00002 #define STK_JCREV_H
00003 
00004 #include "Effect.h"
00005 #include "Delay.h"
00006 #include "OnePole.h"
00007 
00008 namespace stk {
00009 
00010 /***************************************************/
00029 /***************************************************/
00030 
00031 class JCRev : public Effect
00032 {
00033  public:
00035   JCRev( StkFloat T60 = 1.0 );
00036 
00038   void clear( void );
00039 
00041   void setT60( StkFloat T60 );
00042 
00044 
00052   StkFloat lastOut( unsigned int channel = 0 );
00053 
00055 
00062   StkFloat tick( StkFloat input, unsigned int channel = 0 );
00063 
00065 
00074   StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
00075 
00077 
00086   StkFrames& tick( StkFrames& iFrames, StkFrames &oFrames, unsigned int iChannel = 0, unsigned int oChannel = 0 );
00087 
00088  protected:
00089 
00090   Delay allpassDelays_[3];
00091   Delay combDelays_[4];
00092   OnePole combFilters_[4];
00093   Delay outLeftDelay_;
00094   Delay outRightDelay_;
00095   StkFloat allpassCoefficient_;
00096   StkFloat combCoefficient_[4];
00097 
00098 };
00099 
00100 inline StkFloat JCRev :: lastOut( unsigned int channel )
00101 {
00102 #if defined(_STK_DEBUG_)
00103   if ( channel > 1 ) {
00104     oStream_ << "JCRev::lastOut(): channel argument must be less than 2!";
00105     handleError( StkError::FUNCTION_ARGUMENT );
00106   }
00107 #endif
00108 
00109   return lastFrame_[channel];
00110 }
00111 
00112 inline StkFloat JCRev :: tick( StkFloat input, unsigned int channel )
00113 {
00114 #if defined(_STK_DEBUG_)
00115   if ( channel > 1 ) {
00116     oStream_ << "JCRev::tick(): channel argument must be less than 2!";
00117     handleError( StkError::FUNCTION_ARGUMENT );
00118   }
00119 #endif
00120 
00121   StkFloat temp, temp0, temp1, temp2, temp3, temp4, temp5, temp6;
00122   StkFloat filtout;
00123 
00124   temp = allpassDelays_[0].lastOut();
00125   temp0 = allpassCoefficient_ * temp;
00126   temp0 += input;
00127   allpassDelays_[0].tick(temp0);
00128   temp0 = -(allpassCoefficient_ * temp0) + temp;
00129     
00130   temp = allpassDelays_[1].lastOut();
00131   temp1 = allpassCoefficient_ * temp;
00132   temp1 += temp0;
00133   allpassDelays_[1].tick(temp1);
00134   temp1 = -(allpassCoefficient_ * temp1) + temp;
00135     
00136   temp = allpassDelays_[2].lastOut();
00137   temp2 = allpassCoefficient_ * temp;
00138   temp2 += temp1;
00139   allpassDelays_[2].tick(temp2);
00140   temp2 = -(allpassCoefficient_ * temp2) + temp;
00141     
00142   temp3 = temp2 + ( combFilters_[0].tick( combCoefficient_[0] * combDelays_[0].lastOut() ) );
00143   temp4 = temp2 + ( combFilters_[1].tick( combCoefficient_[1] * combDelays_[1].lastOut() ) );
00144   temp5 = temp2 + ( combFilters_[2].tick( combCoefficient_[2] * combDelays_[2].lastOut() ) );
00145   temp6 = temp2 + ( combFilters_[3].tick( combCoefficient_[3] * combDelays_[3].lastOut() ) );
00146 
00147   combDelays_[0].tick(temp3);
00148   combDelays_[1].tick(temp4);
00149   combDelays_[2].tick(temp5);
00150   combDelays_[3].tick(temp6);
00151 
00152   filtout = temp3 + temp4 + temp5 + temp6;
00153 
00154   lastFrame_[0] = effectMix_ * (outLeftDelay_.tick(filtout));
00155   lastFrame_[1] = effectMix_ * (outRightDelay_.tick(filtout));
00156   temp = (1.0 - effectMix_) * input;
00157   lastFrame_[0] += temp;
00158   lastFrame_[1] += temp;
00159     
00160   return 0.7 * lastFrame_[channel];
00161 }
00162 
00163 } // stk namespace
00164 
00165 #endif
00166 

The Synthesis ToolKit in C++ (STK)
©1995-2012 Perry R. Cook and Gary P. Scavone. All Rights Reserved.