Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


VoicForm.h

00001 #ifndef STK_VOICFORM_H
00002 #define STK_VOICFORM_H
00003 
00004 #include "Instrmnt.h"
00005 #include "Envelope.h"
00006 #include "Noise.h"
00007 #include "SingWave.h"
00008 #include "FormSwep.h"
00009 #include "OnePole.h"
00010 #include "OneZero.h"
00011 
00012 namespace stk {
00013 
00014 /***************************************************/
00039 /***************************************************/
00040 
00041 class VoicForm : public Instrmnt
00042 {
00043   public:
00045 
00048   VoicForm( void );
00049 
00051   ~VoicForm( void );
00052 
00054   void clear( void );
00055 
00057   void setFrequency( StkFloat frequency );
00058 
00060   bool setPhoneme( const char* phoneme );
00061 
00063   void setVoiced( StkFloat vGain ) { voiced_->setGainTarget(vGain); };
00064 
00066   void setUnVoiced( StkFloat nGain ) { noiseEnv_.setTarget(nGain); };
00067 
00069   void setFilterSweepRate( unsigned int whichOne, StkFloat rate );
00070 
00072   void setPitchSweepRate( StkFloat rate ) { voiced_->setSweepRate(rate); };
00073 
00075   void speak( void ) { voiced_->noteOn(); };
00076 
00078   void quiet( void );
00079 
00081   void noteOn( StkFloat frequency, StkFloat amplitude );
00082 
00084   void noteOff( StkFloat amplitude ) { this->quiet(); };
00085 
00087   void controlChange( int number, StkFloat value );
00088 
00090   StkFloat tick( unsigned int channel = 0 );
00091 
00092 protected:
00093 
00094   SingWave *voiced_;
00095   Noise    noise_;
00096   Envelope noiseEnv_;
00097   FormSwep filters_[4];
00098   OnePole  onepole_;
00099   OneZero  onezero_;
00100 
00101 };
00102 
00103 inline StkFloat VoicForm :: tick( unsigned int )
00104 {
00105   StkFloat temp;
00106   temp = onepole_.tick( onezero_.tick( voiced_->tick() ) );
00107   temp += noiseEnv_.tick() * noise_.tick();
00108   lastFrame_[0] = filters_[0].tick(temp);
00109   lastFrame_[0] += filters_[1].tick(temp);
00110   lastFrame_[0] += filters_[2].tick(temp);
00111   lastFrame_[0] += filters_[3].tick(temp);
00112   /*
00113     temp  += noiseEnv_.tick() * noise_.tick();
00114     lastFrame_[0]  = filters_[0].tick(temp);
00115     lastFrame_[0]  = filters_[1].tick(lastFrame_[0]);
00116     lastFrame_[0]  = filters_[2].tick(lastFrame_[0]);
00117     lastFrame_[0]  = filters_[3].tick(lastFrame_[0]);
00118   */
00119   return lastFrame_[0];
00120 }
00121 
00122 } // stk namespace
00123 
00124 #endif

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