5 typedef struct wavefile_s
7 // file this is reading from
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;
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;
26 // how many samples in the wave file
29 // how large the data chunk is
30 unsigned int datalength;
31 // beginning of data in data chunk
32 unsigned int dataposition;
34 // current position in stream (in samples)
35 unsigned int position;
37 // these are private to the wave file functions, just used for processing
39 unsigned int bufferlength;
40 // buffer is reallocated if caller asks for more than fits
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);
50 void waveclose(wavefile_t *f);
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);
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);