Structure of Mix_Chunk

Hi,

I would like to display a waveform of a wav but I don’t understand the
internals of Mix_Chunk:
/* The internal format for an audio chunk */
typedef struct {
int allocated;
Uint8 abuf;
Uint32 alen;
Uint8 volume; /
Per-sample volume, 0-128 */
} Mix_Chunk;

When I load my sound the alen is 178112 but the file length is 11354.
So I guess that without headers the Uint8 array in Mix_Chunk is 16 times
larger than the wav? Why? Mono vs. stereo, Uint8 vs. Uin32?
Where can find such info? How can I interpret these data in Mix_Chunk?

Thanks for any help–
Tomas Kouba

Tomas Kouba wrote:

Hi,

I would like to display a waveform of a wav but I don’t understand the
internals of Mix_Chunk:
/* The internal format for an audio chunk */
typedef struct {
int allocated;
Uint8 abuf;
Uint32 alen;
Uint8 volume; /
Per-sample volume, 0-128 */
} Mix_Chunk;

When I load my sound the alen is 178112 but the file length is 11354.
So I guess that without headers the Uint8 array in Mix_Chunk is 16 times
larger than the wav? Why? Mono vs. stereo, Uint8 vs. Uin32?
Where can find such info? How can I interpret these data in Mix_Chunk?

Thanks for any help

when you use SDL_mixer to load a Mix_Chunk, it also converts the sample to the current
output format of the opened audio device. That is the format of the abuf data at the
point you are at. So it’s not surprising to see a low frequency file or mono or
perhaps 8 bit samples, get resampled to a high frequency, stereo, 16bit one, which
may account for the 16X increase in size from the file. so all you have to know
is the audio output format, which you can get from a query function.

-LIM-