Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


StifKarp.h

00001 #ifndef STK_STIFKARP_H
00002 #define STK_STIFKARP_H
00003 
00004 #include "Instrmnt.h"
00005 #include "DelayL.h"
00006 #include "DelayA.h"
00007 #include "OneZero.h"
00008 #include "Noise.h"
00009 #include "BiQuad.h"
00010 
00011 namespace stk {
00012 
00013 /***************************************************/
00034 /***************************************************/
00035 
00036 class StifKarp : public Instrmnt
00037 {
00038  public:
00040   StifKarp( StkFloat lowestFrequency );
00041 
00043   ~StifKarp( void );
00044 
00046   void clear( void );
00047 
00049   void setFrequency( StkFloat frequency );
00050 
00052   void setStretch( StkFloat stretch );
00053 
00055   void setPickupPosition( StkFloat position );
00056 
00058 
00063   void setBaseLoopGain( StkFloat aGain );
00064 
00066   void pluck( StkFloat amplitude );
00067 
00069   void noteOn( StkFloat frequency, StkFloat amplitude );
00070 
00072   void noteOff( StkFloat amplitude );
00073 
00075   void controlChange( int number, StkFloat value );
00076 
00078   StkFloat tick( unsigned int channel = 0 );
00079 
00080  protected:
00081 
00082   DelayA  delayLine_;
00083   DelayL  combDelay_;
00084   OneZero filter_;
00085   Noise   noise_;
00086   BiQuad  biquad_[4];
00087 
00088   unsigned long length_;
00089   StkFloat loopGain_;
00090   StkFloat baseLoopGain_;
00091   StkFloat lastFrequency_;
00092   StkFloat lastLength_;
00093   StkFloat stretching_;
00094   StkFloat pluckAmplitude_;
00095   StkFloat pickupPosition_;
00096 
00097 };
00098 
00099 inline StkFloat StifKarp :: tick( unsigned int )
00100 {
00101   StkFloat temp = delayLine_.lastOut() * loopGain_;
00102 
00103   // Calculate allpass stretching.
00104   for (int i=0; i<4; i++)
00105     temp = biquad_[i].tick(temp);
00106 
00107   // Moving average filter.
00108   temp = filter_.tick(temp);
00109 
00110   lastFrame_[0] = delayLine_.tick(temp);
00111   lastFrame_[0] = lastFrame_[0] - combDelay_.tick( lastFrame_[0] );
00112   return lastFrame_[0];
00113 }
00114 
00115 } // stk namespace
00116 
00117 #endif

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