00001 /* 00002 wavfile.h 00003 00004 (c) 2004 Paul Volkaerts 00005 00006 */ 00007 00008 00009 #ifndef WAVFILE_H_ 00010 #define WAVFILE_H_ 00011 00012 00013 00014 struct wavstruct 00015 { 00016 char ChunkId[4]; 00017 long ChunkSize; 00018 char Format[4]; 00019 00020 char subChunk1Id[4]; 00021 long subChunk1Size; 00022 short AudioFormat; 00023 short NumChannels; 00024 long SampleRate; 00025 long ByteRate; 00026 short BlockAlign; 00027 short BitsPerSample; 00028 00029 char subChunk2Id[4]; 00030 long subChunk2Size; 00031 }; 00032 00033 class wavfile 00034 { 00035 public: 00036 wavfile(); 00037 ~wavfile(); 00038 bool load(const char *Filename); 00039 void load(short *data, int samples, int bitsPerSample=16, int AudioFormat=1, int nChan=1, int SampleRate=8000); 00040 void print(); 00041 bool saveToFile(const char *Filename); 00042 short *getData() { return (short *)audio; }; 00043 int samples() { if (loaded) return (w.subChunk2Size / (w.BitsPerSample/8)); else return 0; } 00044 00045 private: 00046 void transcodeTo8K(); 00047 00048 bool loaded; 00049 wavstruct w; 00050 char *audio; 00051 }; 00052 00053 00054 #endif
1.5.5