Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

# BeeThree.h

    00001 #ifndef STK_BEETHREE_H
    00002 #define STK_BEETHREE_H
    00003
    00004 #include "FM.h"
    00005
    00006 namespace stk {
    00007
    00008 /***************************************************/
    00040 /***************************************************/
    00041
    00042 class BeeThree : public FM
    00043 {
    00044  public:
    00046
    00049   BeeThree( void );
    00050
    00052   ~BeeThree( void );
    00053
    00055   void noteOn( StkFloat frequency, StkFloat amplitude );
    00056
    00058   StkFloat tick( unsigned int channel = 0 );
    00059
    00061
    00068   StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
    00069
    00070  protected:
    00071
    00072 };
    00073
    00074 inline StkFloat BeeThree :: tick( unsigned int )
    00075 {
    00076   register StkFloat temp;
    00077
    00078   if ( modDepth_ > 0.0 )   {
    00079     temp = 1.0 + ( modDepth_ * vibrato_.tick() * 0.1 );
    00080     waves_[0]->setFrequency( baseFrequency_ * temp * ratios_[0] );
    00081     waves_[1]->setFrequency( baseFrequency_ * temp * ratios_[1] );
    00082     waves_[2]->setFrequency( baseFrequency_ * temp * ratios_[2] );
    00083     waves_[3]->setFrequency( baseFrequency_ * temp * ratios_[3] );
    00084   }
    00085
    00086   waves_[3]->addPhaseOffset( twozero_.lastOut() );
    00087   temp = control1_ * 2.0 * gains_[3] * adsr_[3]->tick() * waves_[3]->tick();
    00088   twozero_.tick( temp );
    00089
    00090   temp += control2_ * 2.0 * gains_[2] * adsr_[2]->tick() * waves_[2]->tick();
    00091   temp += gains_[1] * adsr_[1]->tick() * waves_[1]->tick();
    00092   temp += gains_[0] * adsr_[0]->tick() * waves_[0]->tick();
    00093
    00094   lastFrame_[0] = temp * 0.125;
    00095   return lastFrame_[0];
    00096 }
    00097
    00098 inline StkFrames& BeeThree :: tick( StkFrames& frames, unsigned int channel )
    00099 {
    00100   unsigned int nChannels = lastFrame_.channels();
    00101 #if defined(_STK_DEBUG_)
    00102   if ( channel > frames.channels() - nChannels ) {
    00103     oStream_ << "BeeThree::tick(): channel and StkFrames arguments are incompatible!";
    00104     handleError( StkError::FUNCTION_ARGUMENT );
    00105   }
    00106 #endif
    00107
    00108   StkFloat *samples = &frames[channel];
    00109   unsigned int j, hop = frames.channels() - nChannels;
    00110   if ( nChannels == 1 ) {
    00111     for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
    00112       *samples++ = tick();
    00113   }
    00114   else {
    00115     for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) {
    00116       *samples++ = tick();
    00117       for ( j=1; j<nChannels; j++ )
    00118         *samples++ = lastFrame_[j];
    00119     }
    00120   }
    00121
    00122   return frames;
    00123 }
    00124
    00125 } // stk namespace
    00126
    00127 #endif

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