Home Information Classes Download Usage Mail List Requirements Links Tutorial
00001 /***************************************************/ 00037 /***************************************************/ 00038 00039 #if !defined(__WVIN_H) 00040 #define __WVIN_H 00041 00042 // Files larger than CHUNK_THRESHOLD will be copied into memory 00043 // in CHUNK_SIZE increments, rather than completely loaded into 00044 // a buffer at once. 00045 00046 #define CHUNK_THRESHOLD 5000000 // 5 Mb 00047 #define CHUNK_SIZE 1024 // sample frames 00048 00049 #include "Stk.h" 00050 #include <stdio.h> 00051 00052 class WvIn : public Stk 00053 { 00054 public: 00056 WvIn(); 00057 00059 00063 WvIn( const char *fileName, bool raw = FALSE, bool doNormalize = TRUE ); 00064 00066 virtual ~WvIn(); 00067 00069 00073 void openFile( const char *fileName, bool raw = FALSE, bool doNormalize = TRUE ); 00074 00076 void closeFile(void); 00077 00079 void reset(void); 00080 00082 00088 void normalize(void); 00089 00091 00097 void normalize(MY_FLOAT peak); 00098 00100 unsigned long getSize(void) const; 00101 00103 unsigned int getChannels(void) const; 00104 00106 00111 MY_FLOAT getFileRate(void) const; 00112 00114 bool isFinished(void) const; 00115 00117 00120 void setRate(MY_FLOAT aRate); 00121 00123 virtual void addTime(MY_FLOAT aTime); 00124 00126 00132 void setInterpolate(bool doInterpolate); 00133 00135 virtual MY_FLOAT lastOut(void) const; 00136 00138 00141 virtual MY_FLOAT tick(void); 00142 00144 00147 virtual MY_FLOAT *tick(MY_FLOAT *vector, unsigned int vectorSize); 00148 00150 virtual const MY_FLOAT *lastFrame(void) const; 00151 00153 00156 virtual const MY_FLOAT *tickFrame(void); 00157 00159 00162 virtual MY_FLOAT *tickFrame(MY_FLOAT *frameVector, unsigned int frames); 00163 00164 protected: 00165 00166 // Initialize class variables. 00167 void init( void ); 00168 00169 // Read file data. 00170 virtual void readData(unsigned long index); 00171 00172 // Get STK RAW file information. 00173 bool getRawInfo( const char *fileName ); 00174 00175 // Get WAV file header information. 00176 bool getWavInfo( const char *fileName ); 00177 00178 // Get SND (AU) file header information. 00179 bool getSndInfo( const char *fileName ); 00180 00181 // Get AIFF file header information. 00182 bool getAifInfo( const char *fileName ); 00183 00184 // Get MAT-file header information. 00185 bool getMatInfo( const char *fileName ); 00186 00187 char msg[256]; 00188 FILE *fd; 00189 MY_FLOAT *data; 00190 MY_FLOAT *lastOutput; 00191 bool chunking; 00192 bool finished; 00193 bool interpolate; 00194 bool byteswap; 00195 unsigned long fileSize; 00196 unsigned long bufferSize; 00197 unsigned long dataOffset; 00198 unsigned int channels; 00199 long chunkPointer; 00200 STK_FORMAT dataType; 00201 MY_FLOAT fileRate; 00202 MY_FLOAT gain; 00203 MY_FLOAT time; 00204 MY_FLOAT rate; 00205 }; 00206 00207 #endif // defined(__WVIN_H)
The Synthesis ToolKit in C++ (STK) |
©1995-2004 Perry R. Cook and Gary P. Scavone. All Rights Reserved. |