
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 00047 protected: 00048 00049 // Check for sample clipping and clamp. 00050 StkFloat& clipTest( StkFloat& sample ); 00051 00052 StkFrames data_; 00053 unsigned long frameCounter_; 00054 bool clipping_; 00055 00056 }; 00057 00058 inline StkFloat& WvOut :: clipTest( StkFloat& sample ) 00059 { 00060 bool clip = false; 00061 if ( sample > 1.0 ) { 00062 sample = 1.0; 00063 clip = true; 00064 } 00065 else if ( sample < -1.0 ) { 00066 sample = -1.0; 00067 clip = true; 00068 } 00069 00070 if ( clip == true && clipping_ == false ) { 00071 // First occurrence of clipping since instantiation or reset. 00072 clipping_ = true; 00073 errorString_ << "WvOut: data value(s) outside +-1.0 detected ... clamping at outer bound!"; 00074 handleError( StkError::WARNING ); 00075 } 00076 00077 return sample; 00078 } 00079 00080 } // stk namespace 00081 00082 #endif
| The Synthesis ToolKit in C++ (STK) |
| ©1995-2009 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |