Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial
00001 #ifndef STK_FILEWVIN_H 00002 #define STK_FILEWVIN_H 00003 00004 #include "WvIn.h" 00005 #include "FileRead.h" 00006 00007 namespace stk { 00008 00009 /***************************************************/ 00040 /***************************************************/ 00041 00042 class FileWvIn : public WvIn 00043 { 00044 public: 00046 FileWvIn( unsigned long chunkThreshold = 1000000, unsigned long chunkSize = 1024 ); 00047 00049 00053 FileWvIn( std::string fileName, bool raw = false, bool doNormalize = true, 00054 unsigned long chunkThreshold = 1000000, unsigned long chunkSize = 1024 ); 00055 00057 ~FileWvIn( void ); 00058 00060 00069 virtual void openFile( std::string fileName, bool raw = false, bool doNormalize = true ); 00070 00072 virtual void closeFile( void ); 00073 00075 virtual void reset( void ); 00076 00078 00082 virtual void normalize( void ); 00083 00085 00089 virtual void normalize( StkFloat peak ); 00090 00092 virtual unsigned long getSize( void ) const { return data_.frames(); }; 00093 00095 00100 virtual StkFloat getFileRate( void ) const { return data_.dataRate(); }; 00101 00103 bool isFinished( void ) const { return finished_; }; 00104 00106 00109 virtual void setRate( StkFloat rate ); 00110 00112 00115 virtual void addTime( StkFloat time ); 00116 00118 00124 void setInterpolate( bool doInterpolate ) { interpolate_ = doInterpolate; }; 00125 00127 00136 StkFloat lastOut( unsigned int channel = 0 ); 00137 00139 00148 virtual StkFloat tick( unsigned int channel = 0 ); 00149 00151 00159 virtual StkFrames& tick( StkFrames& frames ); 00160 00161 protected: 00162 00163 void sampleRateChanged( StkFloat newRate, StkFloat oldRate ); 00164 00165 FileRead file_; 00166 bool finished_; 00167 bool interpolate_; 00168 bool normalizing_; 00169 bool chunking_; 00170 StkFloat time_; 00171 StkFloat rate_; 00172 unsigned long chunkThreshold_; 00173 unsigned long chunkSize_; 00174 long chunkPointer_; 00175 00176 }; 00177 00178 inline StkFloat FileWvIn :: lastOut( unsigned int channel ) 00179 { 00180 #if defined(_STK_DEBUG_) 00181 if ( channel >= data_.channels() ) { 00182 errorString_ << "FileWvIn::lastOut(): channel argument and soundfile data are incompatible!"; 00183 handleError( StkError::FUNCTION_ARGUMENT ); 00184 } 00185 #endif 00186 00187 if ( finished_ ) return 0.0; 00188 return lastFrame_[channel]; 00189 } 00190 00191 } // stk namespace 00192 00193 #endif
The Synthesis ToolKit in C++ (STK) |
©1995-2010 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |