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 #include <stdlib.h> 00006 00007 namespace stk { 00008 00009 /***************************************************/ 00019 /***************************************************/ 00020 00021 class Noise : public Generator 00022 { 00023 public: 00024 00026 00030 Noise( unsigned int seed = 0 ); 00031 00033 00037 void setSeed( unsigned int seed = 0 ); 00038 00040 StkFloat lastOut( void ) const { return lastFrame_[0]; }; 00041 00043 StkFloat tick( void ); 00044 00046 00053 StkFrames& tick( StkFrames& frames, unsigned int channel = 0 ); 00054 00055 protected: 00056 00057 }; 00058 00059 inline StkFloat Noise :: tick( void ) 00060 { 00061 return lastFrame_[0] = (StkFloat) ( 2.0 * rand() / (RAND_MAX + 1.0) - 1.0 ); 00062 } 00063 00064 inline StkFrames& Noise :: tick( StkFrames& frames, unsigned int channel ) 00065 { 00066 #if defined(_STK_DEBUG_) 00067 if ( channel >= frames.channels() ) { 00068 oStream_ << "Noise::tick(): channel and StkFrames arguments are incompatible!"; 00069 handleError( StkError::FUNCTION_ARGUMENT ); 00070 } 00071 #endif 00072 00073 StkFloat *samples = &frames[channel]; 00074 unsigned int hop = frames.channels(); 00075 for ( unsigned int i=0; i<frames.frames(); i++, samples += hop ) 00076 *samples = (StkFloat) ( 2.0 * rand() / (RAND_MAX + 1.0) - 1.0 ); 00077 00078 lastFrame_[0] = *(samples-hop); 00079 return frames; 00080 } 00081 00082 } // stk namespace 00083 00084 #endif
The Synthesis ToolKit in C++ (STK) |
©1995-2012 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |