Home Information Classes Download Usage Mail List Requirements Links Tutorial
00001 /***************************************************/ 00043 /***************************************************/ 00044 00045 #ifndef STK_WVIN_H 00046 #define STK_WVIN_H 00047 00048 // Files larger than CHUNK_THRESHOLD will be copied into memory 00049 // in CHUNK_SIZE increments, rather than completely loaded into 00050 // a buffer at once. 00051 00052 const unsigned long CHUNK_THRESHOLD = 5000000; // 5 Mb 00053 const long CHUNK_SIZE = 1024; // sample frames 00054 00055 #include "Stk.h" 00056 00057 class WvIn : public Stk 00058 { 00059 public: 00061 WvIn(); 00062 00064 00068 WvIn( std::string fileName, bool raw = false, bool doNormalize = true ); 00069 00071 virtual ~WvIn(); 00072 00074 00078 void openFile( std::string fileName, bool raw = false, bool doNormalize = true ); 00079 00081 void closeFile(void); 00082 00084 void reset(void); 00085 00087 00093 void normalize(void); 00094 00096 00102 void normalize(StkFloat peak); 00103 00105 unsigned long getSize(void) const; 00106 00108 unsigned int getChannels(void) const; 00109 00111 00116 StkFloat getFileRate(void) const; 00117 00119 bool isFinished(void) const; 00120 00122 00125 void setRate(StkFloat aRate); 00126 00128 virtual void addTime(StkFloat aTime); 00129 00131 00137 void setInterpolate(bool doInterpolate); 00138 00140 virtual StkFloat lastOut(void) const; 00141 00143 00146 virtual StkFloat tick(void); 00147 00149 00152 virtual StkFloat *tick(StkFloat *vector, unsigned int vectorSize); 00153 00155 00162 virtual StkFrames& tick( StkFrames& frames, unsigned int channel = 1 ); 00163 00165 virtual const StkFloat *lastFrame(void) const; 00166 00168 00171 virtual const StkFloat *tickFrame(void); 00172 00174 00177 virtual StkFloat *tickFrame(StkFloat *frameVector, unsigned int frames); 00178 00180 00186 virtual StkFrames& tickFrame( StkFrames& frames ); 00187 00188 protected: 00189 00190 // Initialize class variables. 00191 void init( void ); 00192 00193 // Read file data. 00194 virtual void readData(unsigned long index); 00195 00196 // Get STK RAW file information. 00197 bool getRawInfo( const char *fileName ); 00198 00199 // Get WAV file header information. 00200 bool getWavInfo( const char *fileName ); 00201 00202 // Get SND (AU) file header information. 00203 bool getSndInfo( const char *fileName ); 00204 00205 // Get AIFF file header information. 00206 bool getAifInfo( const char *fileName ); 00207 00208 // Get MAT-file header information. 00209 bool getMatInfo( const char *fileName ); 00210 00211 FILE *fd_; 00212 StkFloat *data_; 00213 StkFloat *lastOutputs_; 00214 bool chunking_; 00215 bool finished_; 00216 bool interpolate_; 00217 bool byteswap_; 00218 unsigned long fileSize_; 00219 unsigned long bufferSize_; 00220 unsigned long dataOffset_; 00221 unsigned int channels_; 00222 long chunkPointer_; 00223 StkFormat dataType_; 00224 StkFloat fileRate_; 00225 StkFloat gain_; 00226 StkFloat time_; 00227 StkFloat rate_; 00228 }; 00229 00230 #endif
The Synthesis ToolKit in C++ (STK) |
©1995-2004 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |