The Synthesis ToolKit in C++ (STK)

Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

# NRev.h

    00001 #ifndef STK_NREV_H
    00002 #define STK_NREV_H
    00003
    00004 #include "Effect.h"
    00005 #include "Delay.h"
    00006
    00007 namespace stk {
    00008
    00009 /***************************************************/
    00023 /***************************************************/
    00024
    00025 class NRev : public Effect
    00026 {
    00027  public:
    00029   NRev( StkFloat T60 = 1.0 );
    00030
    00032   void clear( void );
    00033
    00035   void setT60( StkFloat T60 );
    00036
    00038
    00046   StkFloat lastOut( unsigned int channel = 0 );
    00047
    00049
    00056   StkFloat tick( StkFloat input, unsigned int channel = 0 );
    00057
    00059
    00068   StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
    00069
    00071
    00080   StkFrames& tick( StkFrames& iFrames, StkFrames &oFrames, unsigned int iChannel = 0, unsigned int oChannel = 0 );
    00081
    00082  protected:
    00083
    00084   Delay allpassDelays_[8];
    00085   Delay combDelays_[6];
    00086   StkFloat allpassCoefficient_;
    00087   StkFloat combCoefficient_[6];
    00088          StkFloat lowpassState_;
    00089
    00090 };
    00091
    00092 inline StkFloat NRev :: lastOut( unsigned int channel )
    00093 {
    00094 #if defined(_STK_DEBUG_)
    00095   if ( channel > 1 ) {
    00096     oStream_ << "NRev::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 NRev :: tick( StkFloat input, unsigned int channel )
    00105 {
    00106 #if defined(_STK_DEBUG_)
    00107   if ( channel > 1 ) {
    00108     oStream_ << "NRev::tick(): channel argument must be less than 2!";
    00109     handleError( StkError::FUNCTION_ARGUMENT );
    00110   }
    00111 #endif
    00112
    00113   StkFloat temp, temp0, temp1, temp2, temp3;
    00114   int i;
    00115
    00116   temp0 = 0.0;
    00117   for ( i=0; i<6; i++ ) {
    00118     temp = input + (combCoefficient_[i] * combDelays_[i].lastOut());
    00119     temp0 += combDelays_[i].tick(temp);
    00120   }
    00121
    00122   for ( i=0; i<3; i++ )    {
    00123     temp = allpassDelays_[i].lastOut();
    00124     temp1 = allpassCoefficient_ * temp;
    00125     temp1 += temp0;
    00126     allpassDelays_[i].tick(temp1);
    00127     temp0 = -(allpassCoefficient_ * temp1) + temp;
    00128   }
    00129
    00130          // One-pole lowpass filter.
    00131   lowpassState_ = 0.7 * lowpassState_ + 0.3 * temp0;
    00132   temp = allpassDelays_[3].lastOut();
    00133   temp1 = allpassCoefficient_ * temp;
    00134   temp1 += lowpassState_;
    00135   allpassDelays_[3].tick( temp1 );
    00136   temp1 = -( allpassCoefficient_ * temp1 ) + temp;
    00137
    00138   temp = allpassDelays_[4].lastOut();
    00139   temp2 = allpassCoefficient_ * temp;
    00140   temp2 += temp1;
    00141   allpassDelays_[4].tick( temp2 );
    00142   lastFrame_[0] = effectMix_*( -( allpassCoefficient_ * temp2 ) + temp );
    00143
    00144   temp = allpassDelays_[5].lastOut();
    00145   temp3 = allpassCoefficient_ * temp;
    00146   temp3 += temp1;
    00147   allpassDelays_[5].tick( temp3 );
    00148   lastFrame_[1] = effectMix_*( - ( allpassCoefficient_ * temp3 ) + temp );
    00149
    00150   temp = ( 1.0 - effectMix_ ) * input;
    00151   lastFrame_[0] += temp;
    00152   lastFrame_[1] += temp;
    00153
    00154   return lastFrame_[channel];
    00155 }
    00156
    00157 } // stk namespace
    00158
    00159 #endif
    00160

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