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
    00058
    00065   StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
    00066
    00067  protected:
    00068
    00069 };
    00070
    00071 inline StkFloat PercFlut :: tick( unsigned int )
    00072 {
    00073   register StkFloat temp;
    00074
    00075   temp = vibrato_.tick() * modDepth_ * 0.2;
    00076   waves_[0]->setFrequency(baseFrequency_ * (1.0 + temp) * ratios_[0]);
    00077   waves_[1]->setFrequency(baseFrequency_ * (1.0 + temp) * ratios_[1]);
    00078   waves_[2]->setFrequency(baseFrequency_ * (1.0 + temp) * ratios_[2]);
    00079   waves_[3]->setFrequency(baseFrequency_ * (1.0 + temp) * ratios_[3]);
    00080
    00081   waves_[3]->addPhaseOffset( twozero_.lastOut() );
    00082   temp = gains_[3] * adsr_[3]->tick() * waves_[3]->tick();
    00083
    00084   twozero_.tick(temp);
    00085   waves_[2]->addPhaseOffset( temp );
    00086   temp = (1.0 - (control2_ * 0.5)) * gains_[2] * adsr_[2]->tick() * waves_[2]->tick();
    00087
    00088   temp += control2_ * 0.5 * gains_[1] * adsr_[1]->tick() * waves_[1]->tick();
    00089   temp = temp * control1_;
    00090
    00091   waves_[0]->addPhaseOffset(temp);
    00092   temp = gains_[0] * adsr_[0]->tick() * waves_[0]->tick();
    00093
    00094   lastFrame_[0] = temp * 0.5;
    00095   return lastFrame_[0];
    00096 }
    00097
    00098 inline StkFrames& PercFlut :: 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_ << "PercFlut::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.