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