Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


BandedWG.h

00001 #ifndef STK_BANDEDWG_H
00002 #define STK_BANDEDWG_H
00003 
00004 #include "Instrmnt.h"
00005 #include "DelayL.h"
00006 #include "BowTable.h"
00007 #include "ADSR.h"
00008 #include "BiQuad.h"
00009 
00010 namespace stk {
00011 
00012 /***************************************************/
00041 /***************************************************/
00042 
00043 const int MAX_BANDED_MODES = 20;
00044 
00045 class BandedWG : public Instrmnt
00046 {
00047  public:
00049   BandedWG( void );
00050 
00052   ~BandedWG( void );
00053 
00055   void clear( void );
00056 
00058   void setStrikePosition( StkFloat position );
00059 
00061   void setPreset( int preset );
00062 
00064   void setFrequency( StkFloat frequency );
00065 
00067   void startBowing( StkFloat amplitude, StkFloat rate );
00068 
00070   void stopBowing( StkFloat rate );
00071 
00073   void pluck( StkFloat amp );
00074 
00076   void noteOn( StkFloat frequency, StkFloat amplitude );
00077 
00079   void noteOff( StkFloat amplitude );
00080 
00082   void controlChange( int number, StkFloat value );
00083 
00085   StkFloat tick( unsigned int channel = 0 );
00086 
00088 
00095   StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
00096 
00097  protected:
00098 
00099   bool doPluck_;
00100   bool trackVelocity_;
00101   int nModes_;
00102   int presetModes_;
00103   BowTable bowTable_;
00104   ADSR     adsr_;
00105   BiQuad   bandpass_[MAX_BANDED_MODES];
00106   DelayL   delay_[MAX_BANDED_MODES];
00107   StkFloat maxVelocity_;
00108   StkFloat modes_[MAX_BANDED_MODES];
00109   StkFloat frequency_;
00110   StkFloat baseGain_;
00111   StkFloat gains_[MAX_BANDED_MODES];
00112   StkFloat basegains_[MAX_BANDED_MODES];
00113   StkFloat excitation_[MAX_BANDED_MODES];
00114   StkFloat integrationConstant_;
00115   StkFloat velocityInput_;
00116   StkFloat bowVelocity_;
00117   StkFloat bowTarget_;
00118   StkFloat bowPosition_;
00119   StkFloat strikeAmp_;
00120   int strikePosition_;
00121 
00122 };
00123 
00124 inline StkFrames& BandedWG :: tick( StkFrames& frames, unsigned int channel )
00125 {
00126   unsigned int nChannels = lastFrame_.channels();
00127 #if defined(_STK_DEBUG_)
00128   if ( channel > frames.channels() - nChannels ) {
00129     oStream_ << "BandedWG::tick(): channel and StkFrames arguments are incompatible!";
00130     handleError( StkError::FUNCTION_ARGUMENT );
00131   }
00132 #endif
00133 
00134   StkFloat *samples = &frames[channel];
00135   unsigned int j, hop = frames.channels() - nChannels;
00136   if ( nChannels == 1 ) {
00137     for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
00138       *samples++ = tick();
00139   }
00140   else {
00141     for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) {
00142       *samples++ = tick();
00143       for ( j=1; j<nChannels; j++ )
00144         *samples++ = lastFrame_[j];
00145     }
00146   }
00147 
00148   return frames;
00149 }
00150 
00151 } // stk namespace
00152 
00153 #endif

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