Mix Chunk (class)
Jump to navigation
Jump to search
Mix_Chunk - is an SDL Mixer's internal format of an audio chunk.
typedef struct Mix_Chunk {
int allocated;
Uint8 *abuf;
Uint32 alen;
Uint8 volume; /* Per-sample volume, 0-128 */
} Mix_Chunk;
The internal format for an audio chunk. This stores the sample data, the length in bytes of that data, and the volume to use when mixing the sample.
To construct this class use the Audio.newMix_Chunk() function to construct a global variable in your code (with null pointer). And use the Audio.SfxOpen(string fileName) function which loads the sound file into buffer and returns pointer to loaded chunk.
| Mix_Chunk class | |||
|---|---|---|---|
| Type | Function/Field | Return values/Value type | Description |
| Field | Mix_Chunk:allocated | int | a boolean indicating whether to free abuf when the chunk is freed. 0 if the memory was not allocated and thus not owned by this chunk. |
| Field | Mix_Chunk:abuf | int | Pointer to the sample data, which is in the output format and sample rate. |
| Field | Mix_Chunk:alen | int | Length of abuf in bytes. Carefully modify this value, if you changed it, you should return initial value back on exiting from level or from world to avoid memory leak! |
| Field | Mix_Chunk:volume | int | 0 = silent, 128 = max volume. This takes effect when mixing. |