Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

# Moog.h

    00001 #ifndef STK_MOOG_H
    00002 #define STK_MOOG_H
    00003
    00004 #include "Sampler.h"
    00005 #include "FormSwep.h"
    00006
    00007 namespace stk {
    00008
    00009 /***************************************************/
    00027 /***************************************************/
    00028
    00029 class Moog : public Sampler
    00030 {
    00031  public:
    00033
    00036   Moog( void );
    00037
    00039   ~Moog( void );
    00040
    00042   void setFrequency( StkFloat frequency );
    00043
    00045   void noteOn( StkFloat frequency, StkFloat amplitude );
    00046
    00048   void setModulationSpeed( StkFloat mSpeed ) { loops_[1]->setFrequency( mSpeed ); };
    00049
    00051   void setModulationDepth( StkFloat mDepth ) { modDepth_ = mDepth * 0.5; };
    00052
    00054   void controlChange( int number, StkFloat value );
    00055
    00057   StkFloat tick( unsigned int channel = 0 );
    00058
    00059  protected:
    00060
    00061   FormSwep filters_[2];
    00062   StkFloat modDepth_;
    00063   StkFloat filterQ_;
    00064   StkFloat filterRate_;
    00065
    00066 };
    00067
    00068 inline StkFloat Moog :: tick( unsigned int )
    00069 {
    00070   StkFloat temp;
    00071
    00072   if ( modDepth_ != 0.0 ) {
    00073     temp = loops_[1]->tick() * modDepth_;
    00074     loops_[0]->setFrequency( baseFrequency_ * (1.0 + temp) );
    00075   }
    00076
    00077   temp = attackGain_ * attacks_[0]->tick();
    00078   temp += loopGain_ * loops_[0]->tick();
    00079   temp = filter_.tick( temp );
    00080   temp *= adsr_.tick();
    00081   temp = filters_[0].tick( temp );
    00082   lastFrame_[0] = filters_[1].tick( temp );
    00083   return lastFrame_[0] * 6.0;
    00084 }
    00085
    00086 } // stk namespace
    00087
    00088 #endif

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