Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


PercFlut.h

00001 #ifndef STK_PERCFLUT_H
00002 #define STK_PERCFLUT_H
00003 
00004 #include "FM.h"
00005 
00006 namespace stk {
00007 
00008 /***************************************************/
00034 /***************************************************/
00035 
00036 class PercFlut : public FM
00037 {
00038  public:
00040 
00043   PercFlut( void );
00044 
00046   ~PercFlut( void );
00047 
00049   void setFrequency( StkFloat frequency );
00050 
00052   void noteOn( StkFloat frequency, StkFloat amplitude );
00053 
00055   StkFloat tick( unsigned int channel = 0 );
00056 
00057  protected:
00058 
00059 };
00060 
00061 inline StkFloat PercFlut :: tick( unsigned int )
00062 {
00063   register StkFloat temp;
00064 
00065   temp = vibrato_.tick() * modDepth_ * 0.2;    
00066   waves_[0]->setFrequency(baseFrequency_ * (1.0 + temp) * ratios_[0]);
00067   waves_[1]->setFrequency(baseFrequency_ * (1.0 + temp) * ratios_[1]);
00068   waves_[2]->setFrequency(baseFrequency_ * (1.0 + temp) * ratios_[2]);
00069   waves_[3]->setFrequency(baseFrequency_ * (1.0 + temp) * ratios_[3]);
00070     
00071   waves_[3]->addPhaseOffset( twozero_.lastOut() );
00072   temp = gains_[3] * adsr_[3]->tick() * waves_[3]->tick();
00073 
00074   twozero_.tick(temp);
00075   waves_[2]->addPhaseOffset( temp );
00076   temp = (1.0 - (control2_ * 0.5)) * gains_[2] * adsr_[2]->tick() * waves_[2]->tick();
00077 
00078   temp += control2_ * 0.5 * gains_[1] * adsr_[1]->tick() * waves_[1]->tick();
00079   temp = temp * control1_;
00080 
00081   waves_[0]->addPhaseOffset(temp);
00082   temp = gains_[0] * adsr_[0]->tick() * waves_[0]->tick();
00083     
00084   lastFrame_[0] = temp * 0.5;
00085   return lastFrame_[0];
00086 }
00087 
00088 } // stk namespace
00089 
00090 #endif

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