Home   Information   Classes   Download   Usage   Mail List   Requirements   Links   FAQ   Tutorial


Shakers.h

00001 #ifndef STK_SHAKERS_H
00002 #define STK_SHAKERS_H
00003 
00004 #include "Instrmnt.h"
00005 
00006 namespace stk {
00007 
00008 /***************************************************/
00060 /***************************************************/
00061 
00062 const int MAX_FREQS = 8;
00063 const int NUM_INSTR = 24;
00064 
00065 class Shakers : public Instrmnt
00066 {
00067  public:
00069   Shakers( void );
00070 
00072   ~Shakers( void );
00073 
00075 
00079   void noteOn( StkFloat instrument, StkFloat amplitude );
00080 
00082   void noteOff( StkFloat amplitude );
00083 
00085   void controlChange( int number, StkFloat value );
00086 
00088   StkFloat tick( unsigned int channel = 0 );
00089 
00091 
00098   StkFrames& tick( StkFrames& frames, unsigned int channel = 0 );
00099 
00100  protected:
00101 
00102   int setupName( char* instr );
00103   int setupNum( int inst );
00104   int setFreqAndReson( int which, StkFloat freq, StkFloat reson );
00105   void setDecays( StkFloat sndDecay, StkFloat sysDecay );
00106   void setFinalZs( StkFloat z0, StkFloat z1, StkFloat z2 );
00107   StkFloat wuter_tick( void );
00108   StkFloat tbamb_tick( void );
00109   StkFloat ratchet_tick( void );
00110 
00111   int instType_;
00112   int ratchetPos_, lastRatchetPos_;
00113   StkFloat shakeEnergy_;
00114   StkFloat inputs_[MAX_FREQS];
00115   StkFloat outputs_[MAX_FREQS][2];
00116   StkFloat coeffs_[MAX_FREQS][2];
00117   StkFloat sndLevel_;
00118   StkFloat baseGain_;
00119   StkFloat gains_[MAX_FREQS];
00120   int nFreqs_;
00121   StkFloat t_center_freqs_[MAX_FREQS];
00122   StkFloat center_freqs_[MAX_FREQS];
00123   StkFloat resons_[MAX_FREQS];
00124   StkFloat freq_rand_[MAX_FREQS];
00125   int freqalloc_[MAX_FREQS];
00126   StkFloat soundDecay_;
00127   StkFloat systemDecay_;
00128   StkFloat nObjects_;
00129   StkFloat totalEnergy_;
00130   StkFloat ratchet_, ratchetDelta_;
00131   StkFloat finalZ_[3];
00132   StkFloat finalZCoeffs_[3];
00133   StkFloat defObjs_[NUM_INSTR];
00134   StkFloat defDecays_[NUM_INSTR];
00135   StkFloat decayScale_[NUM_INSTR];
00136 
00137 };
00138 
00139 inline StkFrames& Shakers :: tick( StkFrames& frames, unsigned int channel )
00140 {
00141   unsigned int nChannels = lastFrame_.channels();
00142 #if defined(_STK_DEBUG_)
00143   if ( channel > frames.channels() - nChannels ) {
00144     oStream_ << "Shakers::tick(): channel and StkFrames arguments are incompatible!";
00145     handleError( StkError::FUNCTION_ARGUMENT );
00146   }
00147 #endif
00148 
00149   StkFloat *samples = &frames[channel];
00150   unsigned int j, hop = frames.channels() - nChannels;
00151   if ( nChannels == 1 ) {
00152     for ( unsigned int i=0; i<frames.frames(); i++, samples += hop )
00153       *samples++ = tick();
00154   }
00155   else {
00156     for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) {
00157       *samples++ = tick();
00158       for ( j=1; j<nChannels; j++ )
00159         *samples++ = lastFrame_[j];
00160     }
00161   }
00162 
00163   return frames;
00164 }
00165 
00166 } // stk namespace
00167 
00168 #endif

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