#ifndef __WAV__ #define __WAV__ #include #include #include #include using namespace std; using std::string; using std::fstream; typedef struct WAV_HEADER{ char RIFF[4]; // RIFF Header Magic header unsigned int ChunkSize; // RIFF Chunk Size char format[4]; // Header char fmt[4]; // FMT header // char Subchunk1ID[4]; unsigned int Subchunk1Size; // Size of the fmt chunk unsigned short AudioFormat; // Audio format 1=PCM,6=mulaw,7=alaw, 257=IBM Mu-Law, 258=IBM A-Law, 259=ADPCM unsigned short NumOfChan; // Number of channels 1=Mono 2=Sterio int SamplesPerSec; // Sampling Frequency in Hz int bytesPerSec; // bytes per second unsigned short blockAlign; // 2=16-bit mono, 4=16-bit stereo unsigned short bitsPerSample; // Number of bits per sample char Subchunk2ID[4]; // "data" string unsigned int Subchunk2Size; // Sampled data length }wav_hdr; class WavReader { public: WavReader(); // constructor; initialize the list to be empty WavReader(const char* filePath); // Opens and reads the data of a wav file unsigned short getChannels(); int getDataLength(); void makeWav(string s, short*, int nos); //builds a wav file from the data that is contained in the WavHeader and data array. void printInfo(); //prints info from the header int getSample(); //gets sample from the wav file. ~WavReader(); private: wav_hdr wavHeader; FILE *wavFile; unsigned char getByte(); }; #endif