annotate music2/wavfile.h @ 47:5f548e5957a8

* get rid of the "deprecated conversion from string constant to ‘char*’" warnings
author thib
date Wed, 15 Apr 2009 20:26:32 +0000
parents 3a6aaeab7b4e
children 15a18fbe6f21
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
223b71206888 Initial import
thib
parents:
diff changeset
1 /*
223b71206888 Initial import
thib
parents:
diff changeset
2 * wavfile.h WAV file´ØÏ¢
223b71206888 Initial import
thib
parents:
diff changeset
3 *
223b71206888 Initial import
thib
parents:
diff changeset
4 * Copyright: wavfile.c (c) Erik de Castro Lopo erikd@zip.com.au
223b71206888 Initial import
thib
parents:
diff changeset
5 *
223b71206888 Initial import
thib
parents:
diff changeset
6 * Modified : 1997-1998 Masaki Chikama (Wren) <chikama@kasumi.ipl.mech.nagoya-u.ac.jp>
223b71206888 Initial import
thib
parents:
diff changeset
7 * 1998- <masaki-c@is.aist-nara.ac.jp>
223b71206888 Initial import
thib
parents:
diff changeset
8 *
223b71206888 Initial import
thib
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
223b71206888 Initial import
thib
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
223b71206888 Initial import
thib
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
223b71206888 Initial import
thib
parents:
diff changeset
12 * (at your option) any later version.
223b71206888 Initial import
thib
parents:
diff changeset
13 *
223b71206888 Initial import
thib
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
223b71206888 Initial import
thib
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
223b71206888 Initial import
thib
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
223b71206888 Initial import
thib
parents:
diff changeset
17 * GNU General Public License for more details.
223b71206888 Initial import
thib
parents:
diff changeset
18 *
27
3a6aaeab7b4e * Fixed a typo in Jagarl's name
thib
parents: 0
diff changeset
19 * You should have received a copy of the GNU General Public License along
3a6aaeab7b4e * Fixed a typo in Jagarl's name
thib
parents: 0
diff changeset
20 * with this program; if not, write to the Free Software Foundation, Inc.,
3a6aaeab7b4e * Fixed a typo in Jagarl's name
thib
parents: 0
diff changeset
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
0
223b71206888 Initial import
thib
parents:
diff changeset
22 *
223b71206888 Initial import
thib
parents:
diff changeset
23 */
223b71206888 Initial import
thib
parents:
diff changeset
24 #ifndef __WAVEFILE__
223b71206888 Initial import
thib
parents:
diff changeset
25 #define __WAVEFILE__
223b71206888 Initial import
thib
parents:
diff changeset
26
223b71206888 Initial import
thib
parents:
diff changeset
27 #define WW_BADOUTPUTFILE 1
223b71206888 Initial import
thib
parents:
diff changeset
28 #define WW_BADWRITEHEADER 2
223b71206888 Initial import
thib
parents:
diff changeset
29
223b71206888 Initial import
thib
parents:
diff changeset
30 #define WR_BADALLOC 3
223b71206888 Initial import
thib
parents:
diff changeset
31 #define WR_BADSEEK 4
223b71206888 Initial import
thib
parents:
diff changeset
32 #define WR_BADRIFF 5
223b71206888 Initial import
thib
parents:
diff changeset
33 #define WR_BADWAVE 6
223b71206888 Initial import
thib
parents:
diff changeset
34 #define WR_BADFORMAT 7
223b71206888 Initial import
thib
parents:
diff changeset
35 #define WR_BADFORMATSIZE 8
223b71206888 Initial import
thib
parents:
diff changeset
36
223b71206888 Initial import
thib
parents:
diff changeset
37 #define WR_NOTPCMFORMAT 9
223b71206888 Initial import
thib
parents:
diff changeset
38 #define WR_NODATACHUNK 10
223b71206888 Initial import
thib
parents:
diff changeset
39 #define WR_BADFORMATDATA 11
223b71206888 Initial import
thib
parents:
diff changeset
40
223b71206888 Initial import
thib
parents:
diff changeset
41 /*
223b71206888 Initial import
thib
parents:
diff changeset
42 * These values represent values found in/or destined for a
223b71206888 Initial import
thib
parents:
diff changeset
43 * WAV file.
223b71206888 Initial import
thib
parents:
diff changeset
44 */
223b71206888 Initial import
thib
parents:
diff changeset
45 typedef struct {
223b71206888 Initial import
thib
parents:
diff changeset
46 unsigned int SamplingRate; /* Sampling rate in Hz */
223b71206888 Initial import
thib
parents:
diff changeset
47 int Channels; /* Mono or Stereo */
223b71206888 Initial import
thib
parents:
diff changeset
48 unsigned short DataBits; /* Sample bit size (8/12/16) */
223b71206888 Initial import
thib
parents:
diff changeset
49 } WAVINF;
223b71206888 Initial import
thib
parents:
diff changeset
50
223b71206888 Initial import
thib
parents:
diff changeset
51 struct WAVFILE{
223b71206888 Initial import
thib
parents:
diff changeset
52 WAVINF wavinfo; /* WAV file hdr info */
223b71206888 Initial import
thib
parents:
diff changeset
53 WAVFILE(void);
223b71206888 Initial import
thib
parents:
diff changeset
54 static int freq;
223b71206888 Initial import
thib
parents:
diff changeset
55 static int format;
223b71206888 Initial import
thib
parents:
diff changeset
56 static int channels;
223b71206888 Initial import
thib
parents:
diff changeset
57 virtual ~WAVFILE() {};
223b71206888 Initial import
thib
parents:
diff changeset
58 virtual int Read(char* buf, int blksize, int blklen) = 0;
223b71206888 Initial import
thib
parents:
diff changeset
59 virtual void Seek(int count) = 0;
223b71206888 Initial import
thib
parents:
diff changeset
60 static WAVFILE* MakeConverter(WAVFILE* new_reader);
223b71206888 Initial import
thib
parents:
diff changeset
61 };
223b71206888 Initial import
thib
parents:
diff changeset
62
223b71206888 Initial import
thib
parents:
diff changeset
63 struct WAVFILE_Converter : WAVFILE {
223b71206888 Initial import
thib
parents:
diff changeset
64 WAVFILE* original;
223b71206888 Initial import
thib
parents:
diff changeset
65 struct SDL_AudioCVT* cvt;
223b71206888 Initial import
thib
parents:
diff changeset
66 int datasize;
223b71206888 Initial import
thib
parents:
diff changeset
67 char* tmpbuf;
223b71206888 Initial import
thib
parents:
diff changeset
68 int Read(char* buf, int blksize, int blklen);
223b71206888 Initial import
thib
parents:
diff changeset
69 void Seek(int count) { original->Seek(count);}
223b71206888 Initial import
thib
parents:
diff changeset
70 WAVFILE_Converter(WAVFILE* orig, struct SDL_AudioCVT* cvt);
223b71206888 Initial import
thib
parents:
diff changeset
71 ~WAVFILE_Converter();
223b71206888 Initial import
thib
parents:
diff changeset
72 };
223b71206888 Initial import
thib
parents:
diff changeset
73
223b71206888 Initial import
thib
parents:
diff changeset
74 struct WAVFILE_Stream : WAVFILE{
223b71206888 Initial import
thib
parents:
diff changeset
75 char *data; /* real data */
223b71206888 Initial import
thib
parents:
diff changeset
76 char *data_orig;
223b71206888 Initial import
thib
parents:
diff changeset
77 int data_length;
223b71206888 Initial import
thib
parents:
diff changeset
78 FILE* stream;
223b71206888 Initial import
thib
parents:
diff changeset
79 int stream_length;
223b71206888 Initial import
thib
parents:
diff changeset
80 int stream_length_orig;
223b71206888 Initial import
thib
parents:
diff changeset
81 int stream_top;
223b71206888 Initial import
thib
parents:
diff changeset
82 int Read(char* buf, int blksize, int blklen);
223b71206888 Initial import
thib
parents:
diff changeset
83 void Seek(int count);
223b71206888 Initial import
thib
parents:
diff changeset
84 WAVFILE_Stream(FILE* stream, int length);
223b71206888 Initial import
thib
parents:
diff changeset
85 ~WAVFILE_Stream();
223b71206888 Initial import
thib
parents:
diff changeset
86 };
223b71206888 Initial import
thib
parents:
diff changeset
87
223b71206888 Initial import
thib
parents:
diff changeset
88 struct NWAFILE : WAVFILE {
223b71206888 Initial import
thib
parents:
diff changeset
89 int skip_count;
223b71206888 Initial import
thib
parents:
diff changeset
90 FILE* stream;
223b71206888 Initial import
thib
parents:
diff changeset
91 struct NWAData* nwa;
223b71206888 Initial import
thib
parents:
diff changeset
92 char* data;
223b71206888 Initial import
thib
parents:
diff changeset
93 int block_size;
223b71206888 Initial import
thib
parents:
diff changeset
94 int data_len;
223b71206888 Initial import
thib
parents:
diff changeset
95
223b71206888 Initial import
thib
parents:
diff changeset
96 NWAFILE(FILE* stream);
223b71206888 Initial import
thib
parents:
diff changeset
97 ~NWAFILE();
223b71206888 Initial import
thib
parents:
diff changeset
98 void Seek(int count);
223b71206888 Initial import
thib
parents:
diff changeset
99 int Read(char* buf, int blksize, int blklen);
223b71206888 Initial import
thib
parents:
diff changeset
100 static char* ReadAll(FILE* stream, int& size);
223b71206888 Initial import
thib
parents:
diff changeset
101 };
223b71206888 Initial import
thib
parents:
diff changeset
102
223b71206888 Initial import
thib
parents:
diff changeset
103 struct OggFILE : WAVFILE {
223b71206888 Initial import
thib
parents:
diff changeset
104 struct OggFILE_impl* pimpl;
223b71206888 Initial import
thib
parents:
diff changeset
105
223b71206888 Initial import
thib
parents:
diff changeset
106 OggFILE(FILE* stream, int size);
223b71206888 Initial import
thib
parents:
diff changeset
107 ~OggFILE();
223b71206888 Initial import
thib
parents:
diff changeset
108 void Seek(int count);
223b71206888 Initial import
thib
parents:
diff changeset
109 int Read(char* buf, int blksize, int blklen);
223b71206888 Initial import
thib
parents:
diff changeset
110 };
223b71206888 Initial import
thib
parents:
diff changeset
111
223b71206888 Initial import
thib
parents:
diff changeset
112 struct MP3FILE : WAVFILE {
223b71206888 Initial import
thib
parents:
diff changeset
113 struct MP3FILE_impl* pimpl;
223b71206888 Initial import
thib
parents:
diff changeset
114
223b71206888 Initial import
thib
parents:
diff changeset
115 MP3FILE(FILE* stream, int size);
223b71206888 Initial import
thib
parents:
diff changeset
116 ~MP3FILE();
223b71206888 Initial import
thib
parents:
diff changeset
117 void Seek(int count);
223b71206888 Initial import
thib
parents:
diff changeset
118 int Read(char* buf, int blksize, int blklen);
223b71206888 Initial import
thib
parents:
diff changeset
119 };
223b71206888 Initial import
thib
parents:
diff changeset
120
223b71206888 Initial import
thib
parents:
diff changeset
121 #endif /* !__WAVEFILE__ */