]> icculus.org git repositories - divverent/darkplaces.git/blob - wavefile.h
I guess those glLoadIdentity calls were more important than expected
[divverent/darkplaces.git] / wavefile.h
1
2 #ifndef WAVEFILE_H
3 #define WAVEFILE_H
4
5 typedef struct wavefile_s
6 {
7         // file this is reading from
8         FILE *file;
9
10         // these settings are read directly from the wave format
11         // 1 is uncompressed PCM
12         unsigned int info_format;
13         // how many samples per second
14         unsigned int info_rate;
15         // how many channels (1 = mono, 2 = stereo, 6 = 5.1 audio?)
16         unsigned int info_channels;
17         // how many bits per channel (8 or 16)
18         unsigned int info_bits;
19
20         // these settings are generated from the wave format
21         // how many bytes in a sample (which may be one or two channels, thus 1 or 2 or 2 or 4, depending on info_bytesperchannel)
22         unsigned int info_bytespersample;
23         // how many bytes in channel (1 for 8bit, or 2 for 16bit)
24         unsigned int info_bytesperchannel;
25
26         // how many samples in the wave file
27         unsigned int length;
28
29         // how large the data chunk is
30         unsigned int datalength;
31         // beginning of data in data chunk
32         unsigned int dataposition;
33
34         // current position in stream (in samples)
35         unsigned int position;
36
37         // these are private to the wave file functions, just used for processing
38         // size of *buffer
39         unsigned int bufferlength;
40         // buffer is reallocated if caller asks for more than fits
41         void *buffer;
42
43 }
44 wavefile_t;
45
46 // opens a wave file, if an error occurs and errorstring is not NULL,
47 // *errorstring will be set to a message describing the error
48 wavefile_t *waveopen(char *filename, char **errorstring);
49 // closes a wave file
50 void waveclose(wavefile_t *f);
51
52 // reads some data from the file as 16bit stereo (converting if necessary)
53 // returns number of samples read (may be less than requested)
54 // if not all samples could be read, the remaining buffer will be unmodified
55 unsigned int waveread16stereo(wavefile_t *f, short *soundbuffer, unsigned int samples);
56
57 // seeks to a desired position in the wave
58 // returns 0 if successful, 1 if not successful
59 unsigned int waveseek(wavefile_t *f, unsigned int samples);
60
61 #endif