Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

# FMVoices.h

    00001 #ifndef STK_FMVOICES_H
    00002 #define STK_FMVOICES_H
    00003
    00004 #include "FM.h"
    00005
    00006 namespace stk {
    00007
    00008 /***************************************************/
    00038 /***************************************************/
    00039
    00040 class FMVoices : public FM
    00041 {
    00042  public:
    00044
    00047   FMVoices( void );
    00048
    00050   ~FMVoices( void );
    00051
    00053   void setFrequency( StkFloat frequency );
    00054
    00056   void noteOn( StkFloat frequency, StkFloat amplitude );
    00057
    00059   void controlChange( int number, StkFloat value );
    00060
    00062   StkFloat tick( unsigned int channel = 0 );
    00063
    00064  protected:
    00065
    00066   int currentVowel_;
    00067   StkFloat tilt_[3];
    00068   StkFloat mods_[3];
    00069 };
    00070
    00071 inline StkFloat FMVoices :: tick( unsigned int )
    00072 {
    00073   register StkFloat temp, temp2;
    00074
    00075   temp = gains_[3] * adsr_[3]->tick() * waves_[3]->tick();
    00076   temp2 = vibrato_.tick() * modDepth_ * 0.1;
    00077
    00078   waves_[0]->setFrequency(baseFrequency_ * (1.0 + temp2) * ratios_[0]);
    00079   waves_[1]->setFrequency(baseFrequency_ * (1.0 + temp2) * ratios_[1]);
    00080   waves_[2]->setFrequency(baseFrequency_ * (1.0 + temp2) * ratios_[2]);
    00081   waves_[3]->setFrequency(baseFrequency_ * (1.0 + temp2) * ratios_[3]);
    00082
    00083   waves_[0]->addPhaseOffset(temp * mods_[0]);
    00084   waves_[1]->addPhaseOffset(temp * mods_[1]);
    00085   waves_[2]->addPhaseOffset(temp * mods_[2]);
    00086   waves_[3]->addPhaseOffset( twozero_.lastOut() );
    00087   twozero_.tick( temp );
    00088   temp =  gains_[0] * tilt_[0] * adsr_[0]->tick() * waves_[0]->tick();
    00089   temp += gains_[1] * tilt_[1] * adsr_[1]->tick() * waves_[1]->tick();
    00090   temp += gains_[2] * tilt_[2] * adsr_[2]->tick() * waves_[2]->tick();
    00091
    00092   lastFrame_[0] = temp * 0.33;
    00093   return lastFrame_[0];
    00094 }
    00095
    00096 } // stk namespace
    00097
    00098 #endif

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