Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial
00001 #ifndef STK_WVOUT_H 00002 #define STK_WVOUT_H 00003 00004 #include "Stk.h" 00005 00006 namespace stk { 00007 00008 /***************************************************/ 00020 /***************************************************/ 00021 00022 class WvOut : public Stk 00023 { 00024 public: 00025 00027 WvOut( void ) : frameCounter_(0), clipping_(false) {}; 00028 00030 unsigned long getFrameCount( void ) const { return frameCounter_; }; 00031 00033 StkFloat getTime( void ) const { return (StkFloat) frameCounter_ / Stk::sampleRate(); }; 00034 00036 bool clipStatus( void ) { return clipping_; }; 00037 00039 void resetClipStatus( void ) { clipping_ = false; }; 00040 00042 00045 virtual void tick( const StkFloat sample ) = 0; 00046 00048 virtual void tick( const StkFrames& frames ) = 0; 00049 00050 protected: 00051 00052 // Check for sample clipping and clamp. 00053 StkFloat& clipTest( StkFloat& sample ); 00054 00055 StkFrames data_; 00056 unsigned long frameCounter_; 00057 bool clipping_; 00058 00059 }; 00060 00061 inline StkFloat& WvOut :: clipTest( StkFloat& sample ) 00062 { 00063 bool clip = false; 00064 if ( sample > 1.0 ) { 00065 sample = 1.0; 00066 clip = true; 00067 } 00068 else if ( sample < -1.0 ) { 00069 sample = -1.0; 00070 clip = true; 00071 } 00072 00073 if ( clip == true && clipping_ == false ) { 00074 // First occurrence of clipping since instantiation or reset. 00075 clipping_ = true; 00076 errorString_ << "WvOut: data value(s) outside +-1.0 detected ... clamping at outer bound!"; 00077 handleError( StkError::WARNING ); 00078 } 00079 00080 return sample; 00081 } 00082 00083 } // stk namespace 00084 00085 #endif
The Synthesis ToolKit in C++ (STK) |
©1995-2010 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |