Home Information Classes Download Usage Mail List Requirements Links FAQ Tutorial

# FileWvIn.h

    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 file_.fileSize(); };
    00093
    00095
    00100   virtual StkFloat getFileRate( void ) const { return data_.dataRate(); };
    00101
    00103   bool isOpen( void ) { return file_.isOpen(); };
    00104
    00106   bool isFinished( void ) const { return finished_; };
    00107
    00109
    00112   virtual void setRate( StkFloat rate );
    00113
    00115
    00118   virtual void addTime( StkFloat time );
    00119
    00121
    00127   void setInterpolate( bool doInterpolate ) { interpolate_ = doInterpolate; };
    00128
    00130
    00139   StkFloat lastOut( unsigned int channel = 0 );
    00140
    00142
    00151   virtual StkFloat tick( unsigned int channel = 0 );
    00152
    00154
    00162   virtual StkFrames& tick( StkFrames& frames );
    00163
    00164 protected:
    00165
    00166   void sampleRateChanged( StkFloat newRate, StkFloat oldRate );
    00167
    00168   FileRead file_;
    00169   bool finished_;
    00170   bool interpolate_;
    00171   bool normalizing_;
    00172   bool chunking_;
    00173   StkFloat time_;
    00174   StkFloat rate_;
    00175   unsigned long chunkThreshold_;
    00176   unsigned long chunkSize_;
    00177   long chunkPointer_;
    00178
    00179 };
    00180
    00181 inline StkFloat FileWvIn :: lastOut( unsigned int channel )
    00182 {
    00183 #if defined(_STK_DEBUG_)
    00184   if ( channel >= data_.channels() ) {
    00185     oStream_ << "FileWvIn::lastOut(): channel argument and soundfile data are incompatible!";
    00186     handleError( StkError::FUNCTION_ARGUMENT );
    00187   }
    00188 #endif
    00189
    00190   if ( finished_ ) return 0.0;
    00191   return lastFrame_[channel];
    00192 }
    00193
    00194 } // stk namespace
    00195
    00196 #endif

The Synthesis ToolKit in C++ (STK)
©1995-2012 Perry R. Cook and Gary P. Scavone. All Rights Reserved.