Blame view

pur/wavdata.h 2.05 KB
6a961b68   rsimonin   modifications
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
  #ifndef WAVDATA_H
  #define WAVDATA_H
  
  #include <iostream>
  #include <fstream>
  
  class WavData
  {
  	unsigned int _audioFormat;
  	unsigned int _nbrChanel;
  	unsigned int _frequency;
  	unsigned int _bytePerBloc;
  	unsigned int _bytePerSec;
  	unsigned int _bitsPerSample;
  
  	char * _data;
  	unsigned int _datasize;
  public:
  	WavData();
  
  	int load(char* s);
  	int save(char* s);
  
  	unsigned int fromLittleEndian(char * content, int size);
  	char * toLittleEndian(unsigned int content, int size);
  	void toLittleEndian(char* result,unsigned int content, int size);
  
  	inline unsigned int audioFormat(){return _audioFormat;}
  	inline unsigned int nbrChanel(){return _nbrChanel;}
  	inline unsigned int frequency(){return _frequency;}
  	inline unsigned int bytePerBloc(){return _bytePerBloc;}
  	inline unsigned int bytePerSec(){return _bytePerSec;}
  	inline unsigned int bitsPerSample(){return _bitsPerSample;}
  	inline unsigned int datasize(){return _datasize;}
  	inline char * data(){return _data;}
  
  	inline void setAudioFormat(unsigned int a){_audioFormat=a;}
  	inline void setNbrChanel(unsigned int a){_nbrChanel=a;}
  	inline void setFrequency(unsigned int a){_frequency=a;}
  	inline void setBytePerBloc(unsigned int a){_bytePerBloc=a;}
  	inline void setBytePerSec(unsigned int a){_bytePerSec=a;}
  	inline void setBitsPerSample(unsigned int a){_bitsPerSample=a;}
  	inline void setData(char * a){_data=a;}
  	inline void clearData(){delete[] _data;_data=NULL;}
  	inline void setDatasize(unsigned int i){_datasize=i;}
  	
  private:
  	int error(int,int);
  	int openFormatBloc(std::ifstream* file);
  	int openDescriptionBloc(std::ifstream *file);
  	int openDataBloc(std::ifstream *file);
  
  	int saveFormatBloc(std::ofstream *file);
  	int saveDescriptionBloc(std::ofstream *file);
  	int saveDataBloc(std::ofstream *file);
  	
  	void write(std::ofstream *file,char* mess,unsigned int size);
  	char * read(std::ifstream* file,unsigned int size);
  	
  	bool comp(char* c1, char *c2, int size);
  	int testString(std::ifstream* file,char*compstr,int size,char *mess);
  	int testInt(std::ifstream* file,int size,char *mess,unsigned int *val=NULL);
  
  };
  
  #endif // WAVDATA_H