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