1 /*  SpiralSynth
2  *  Copyleft (C) 2000 David Griffiths <dave@pawfal.org>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18 
19 #include <string>
20 using namespace std;
21 
22 #ifndef WAVFILE
23 #define WAVFILE
24 
25 class WavFile
26 {
27 public:
WavFile()28 	WavFile() : m_Stream(NULL), m_TotalLength(0) {}
~WavFile()29 	~WavFile() {Close();}
30 
31 	enum Mode{READ,WRITE};
32 
33 	class HeaderInfo
34 	{
35 	public:
36 		HeaderInfo();
37 
38 		string RiffStr1;
39 		int  RiffSize;
40 		string RiffStr2;
41 
42 		string FrmtStr;
43 		char Length;
44 		char Unknown;
45 		char Channels;
46 		int  SampleRate;
47 		int  BytesPerSec;
48 		char BytesPerSample;
49 		char BitsPerSample;
50 
51 		string DataStr;
52 		int  DataLength;
53 		char Zero;
54 	};
55 
56 	int Open(string FileName, Mode mode);
57 	int Close();
58 	int Save(int Length, short *data);
59 	int Load(short *data);
60 	int GetSize();
61 
Recording()62 	bool Recording() {return (m_Stream!=NULL);}
63 
64 private:
65 
66 	FILE *m_Stream;
67 	int m_TotalLength;
68 	bool m_Stereo;
69 };
70 
71 #endif
72