Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial
00001 #ifndef STK_NOISE_H 00002 #define STK_NOISE_H 00003 00004 #include "Generator.h" 00005 00006 namespace stk { 00007 00008 /***************************************************/ 00018 /***************************************************/ 00019 00020 class Noise : public Generator 00021 { 00022 public: 00023 00025 00029 Noise( unsigned int seed = 0 ); 00030 00032 00036 void setSeed( unsigned int seed = 0 ); 00037 00039 StkFloat lastOut( void ) const { return lastFrame_[0]; }; 00040 00042 StkFloat tick( void ); 00043 00045 00052 StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ); 00053 00054 protected: 00055 00056 }; 00057 00058 inline StkFloat Noise :: tick( void ) 00059 { 00060 return lastFrame_[0] = (StkFloat) ( 2.0 * rand() / (RAND_MAX + 1.0) - 1.0 ); 00061 } 00062 00063 inline StkFrames& Noise :: tick( StkFrames& frames, unsigned int channel ) 00064 { 00065 #if defined(_STK_DEBUG_) 00066 if ( channel >= frames.channels() ) { 00067 errorString_ << "Noise::tick(): channel and StkFrames arguments are incompatible!"; 00068 handleError( StkError::FUNCTION_ARGUMENT ); 00069 } 00070 #endif 00071 00072 StkFloat *samples = &frames[channel]; 00073 unsigned int hop = frames.channels(); 00074 for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) 00075 *samples = (StkFloat) ( 2.0 * rand() / (RAND_MAX + 1.0) - 1.0 ); 00076 00077 lastFrame_[0] = *(samples-hop); 00078 return frames; 00079 } 00080 00081 } // stk namespace 00082 00083 #endif
The Synthesis ToolKit in C++ (STK) |
©1995-2010 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |