Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial
00001 #ifndef STK_WHISTLE_H 00002 #define STK_WHISTLE_H 00003 00004 #include "Instrmnt.h" 00005 #include "Sphere.h" 00006 #include "Vector3D.h" 00007 #include "Noise.h" 00008 #include "SineWave.h" 00009 #include "OnePole.h" 00010 #include "Envelope.h" 00011 00012 namespace stk { 00013 00014 /***************************************************/ 00030 /***************************************************/ 00031 00032 class Whistle : public Instrmnt 00033 { 00034 public: 00036 00039 Whistle( void ); 00040 00042 ~Whistle( void ); 00043 00045 void clear( void ); 00046 00048 void setFrequency( StkFloat frequency ); 00049 00051 void startBlowing( StkFloat amplitude, StkFloat rate ); 00052 00054 void stopBlowing( StkFloat rate ); 00055 00057 void noteOn( StkFloat frequency, StkFloat amplitude ); 00058 00060 void noteOff( StkFloat amplitude ); 00061 00063 void controlChange( int number, StkFloat value ); 00064 00066 StkFloat tick( unsigned int channel = 0 ); 00067 00069 00076 StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ); 00077 00078 protected: 00079 00080 Vector3D *tempVectorP_; 00081 Vector3D tempVector_; 00082 OnePole onepole_; 00083 Noise noise_; 00084 Envelope envelope_; 00085 Sphere can_; // Declare a Spherical "can". 00086 Sphere pea_, bumper_; // One spherical "pea", and a spherical "bumper". 00087 00088 SineWave sine_; 00089 00090 StkFloat baseFrequency_; 00091 StkFloat noiseGain_; 00092 StkFloat fippleFreqMod_; 00093 StkFloat fippleGainMod_; 00094 StkFloat blowFreqMod_; 00095 StkFloat tickSize_; 00096 StkFloat canLoss_; 00097 int subSample_, subSampCount_; 00098 }; 00099 00100 inline StkFrames& Whistle :: tick( StkFrames& frames, unsigned int channel ) 00101 { 00102 unsigned int nChannels = lastFrame_.channels(); 00103 #if defined(_STK_DEBUG_) 00104 if ( channel > frames.channels() - nChannels ) { 00105 oStream_ << "Whistle::tick(): channel and StkFrames arguments are incompatible!"; 00106 handleError( StkError::FUNCTION_ARGUMENT ); 00107 } 00108 #endif 00109 00110 StkFloat *samples = &frames[channel]; 00111 unsigned int j, hop = frames.channels() - nChannels; 00112 if ( nChannels == 1 ) { 00113 for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) 00114 *samples++ = tick(); 00115 } 00116 else { 00117 for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) { 00118 *samples++ = tick(); 00119 for ( j=1; j<nChannels; j++ ) 00120 *samples++ = lastFrame_[j]; 00121 } 00122 } 00123 00124 return frames; 00125 } 00126 00127 } // stk namespace 00128 #endif
The Synthesis ToolKit in C++ (STK) |
©1995-2012 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |