SDL Mixer PDF
SDL Mixer PDF
13 November 2009
Jonathan Atkins
Table of Contents
1
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1
2.2
Includes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Compiling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Conflicts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4.1
General. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.1.1 Mix Linked Version . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.1.2 Mix Init . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.1.3 Mix Quit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.1.4 Mix OpenAudio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.1.5 Mix CloseAudio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.1.6 Mix SetError . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.1.7 Mix GetError . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.1.8 Mix QuerySpec . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.2 Samples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
4.2.1 Mix GetNumChunkDecoders . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.2.2 Mix GetChunkDecoder. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.2.3 Mix LoadWAV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4.2.4 Mix LoadWAV RW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.2.5 Mix QuickLoad WAV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.2.6 Mix QuickLoad RAW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.2.7 Mix VolumeChunk. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.2.8 Mix FreeChunk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.3 Channels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.3.1 Mix AllocateChannels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.3.2 Mix Volume . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.3.3 Mix PlayChannel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4.3.4 Mix PlayChannelTimed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.3.5 Mix FadeInChannel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.3.6 Mix FadeInChannelTimed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.3.7 Mix Pause . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.3.8 Mix Resume . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.3.9 Mix HaltChannel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.3.10 Mix ExpireChannel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4.3.11 Mix FadeOutChannel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.3.12 Mix ChannelFinished . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
4.3.13 Mix Playing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.3.14 Mix Paused . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
ii
4.3.15 Mix FadingChannel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.3.16 Mix GetChunk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4 Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4.1 Mix ReserveChannels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4.2 Mix GroupChannel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4.3 Mix GroupChannels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4.4 Mix GroupCount . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4.5 Mix GroupAvailable . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4.6 Mix GroupOldest . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4.7 Mix GroupNewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4.8 Mix FadeOutGroup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.4.9 Mix HaltGroup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5 Music . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.1 Mix GetNumMusicDecoders . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.2 Mix GetMusicDecoder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.3 Mix LoadMUS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.4 Mix FreeMusic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.5 Mix PlayMusic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.6 Mix FadeInMusic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.7 Mix FadeInMusicPos. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.8 Mix HookMusic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.9 Mix VolumeMusic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.10 Mix PauseMusic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.11 Mix ResumeMusic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.12 Mix RewindMusic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.13 Mix SetMusicPosition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.14 Mix SetMusicCMD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.15 Mix HaltMusic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.16 Mix FadeOutMusic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.17 Mix HookMusicFinished . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.18 Mix GetMusicType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.19 Mix PlayingMusic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.20 Mix PausedMusic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.21 Mix FadingMusic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.5.22 Mix GetMusicHookData . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.6 Effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.6.1 Mix RegisterEffect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.6.2 Mix UnregisterEffect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.6.3 Mix UnregisterAllEffects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.6.4 Mix SetPostMix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.6.5 Mix SetPanning . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.6.6 Mix SetDistance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.6.7 Mix SetPosition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
4.6.8 Mix SetReverseStereo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
iii
Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
5.1
5.2
5.3
5.4
5.5
5.6
Mix
Mix
Mix
Mix
Mix
Mix
Chunk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Music . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
MusicType . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Fading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
EffectFunc t. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
EffectDone t . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
87
88
89
90
91
92
Defines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Chapter 1: Overview
1 Overview
A Little Bit About Me
I am currently, as I write this document, a programmer for Raytheon. There I do all sorts
of communications, network, GUI, and other general programming tasks in C/C++ on the
Solaris and sometimes Linux Operating Systems. I have been programming sound code in
my free time for only a little while now. Sound is an integral part to any game. The human
senses are mostly starved during video game play. theres only some tactile feedback on
some controlers, and of course the eyes are in use but only for about 30% of their viewing
area. So to add more we do need sound to help the game player feel more in the action,
and to set certain moods as the game progresses. Sound ends up accounting for perhaps
50% or more of a gamers experience. Music and sound effects are all integral parts of the
gaming experience. While this document doesnt explain how to get music and samples to
use, it will explain how to use them with SDL mixer.
Feel free to contact me: [email protected]
I am also usually on IRC at irc.freenode.net in the #SDL channel as LIM
Chapter 1: Overview
2 Getting Started
This assumes you have gotten SDL mixer and installed it on your system. SDL mixer has
an INSTALL document in the source distribution to help you get it compiled and installed.
Generally, installation consists of:
./configure
make
make install
SDL mixer supports playing music and sound samples from the following formats:
- WAVE/RIFF (.wav)
- AIFF (.aiff)
- VOC (.voc)
- MOD (.mod .xm .s3m .669 .it .med and more) requiring libmikmod on system
- MIDI (.mid) using timidity or native midi hardware
- OggVorbis (.ogg) requiring ogg/vorbis libraries on system
- MP3 (.mp3) requiring SMPEG or MAD library on system
- FLAC (.flac) requiring the FLAC library on system - also any command-line player, which
is not mixed by SDL mixer...
You may also want to look at some demonstration code which may be downloaded from:
http://www.jonatkins.org/SDL_mixer/
2.1 Includes
To use SDL mixer functions in a C/C++ source code file, you must use the SDL mixer.h
include file:
#include "SDL_mixer.h"
2.2 Compiling
To link with SDL mixer you should use sdl-config to get the required SDL compilation
options. After that, compiling with SDL mixer is quite easy.
Note: Some systems may not have the SDL mixer library and include file in the same place
as the SDL library and includes are located, in that case you will need to add more -I and
-L paths to these command lines.
Chapter 3: Conflicts
3 Conflicts
When using SDL mixer functions you need to avoid the following functions from SDL:
SDL_OpenAudio
Use Mix_OpenAudio instead.
SDL_CloseAudio
Use Mix_CloseAudio instead.
SDL_PauseAudio
Use Mix_Pause(-1) and Mix_PauseMusic instead, to pause.
Use Mix_Resume(-1) and Mix_ResumeMusic instead, to unpause.
SDL_LockAudio
This is just not needed since SDL mixer handles this for you.
Using it may cause problems as well.
SDL_UnlockAudio
This is just not needed since SDL mixer handles this for you.
Using it may cause problems as well.
You may call the following functions freely:
SDL_AudioDriverName
This will still work as usual.
SDL_GetAudioStatus
This will still work, though it will likely return SDL AUDIO PLAYING even
though SDL mixer is just playing silence.
It is also a BAD idea to call SDL mixer and SDL audio functions from a callback.
Callbacks include Effects functions and other SDL mixer audio hooks.
Chapter 4: Functions
4 Functions
These are the functions in the SDL mixer API.
Chapter 4: Functions
4.1 General
These functions are useful, as they are the only/best ways to work with SDL mixer.
Chapter 4: Functions
SDL_version compile_version;
const SDL_version *link_version=Mix_Linked_Version();
SDL_MIXER_VERSION(&compile_version);
printf("compiled with SDL_mixer version: %d.%d.%d\n",
compile_version.major,
compile_version.minor,
compile_version.patch);
printf("running with SDL_mixer version: %d.%d.%d\n",
link_version->major,
link_version->minor,
link_version->patch);
See Also:
Section 4.1.4 [Mix OpenAudio], page 12, Section 4.1.8 [Mix QuerySpec], page 17
Chapter 4: Functions
10
Initialize by loading support as indicated by the flags, or at least return success if support
is already loaded. You may call this multiple times, which will actually require you to call
Mix_Quit just once to clean up. You may call this function with a 0 to retrieve whether
support was built-in or not loaded yet.
Note: you can call Mix_Init with the right MIX INIT * flags ORd together before you
program gets busy, to prevent a later hiccup while it loads and unloads the library, and to
check that you do have the support that you need before you try and use it.
Note: this function does not always set the error string, so do not depend on Mix_GetError
being meaningful all the time.
Returns: a bitmask of all the currently initted sample/music loaders.
See Also:
Section 4.1.3 [Mix Quit], page 11
Chapter 4: Functions
11
NOTE: Since each call to Mix_Init may set different flags, there is no way, currently, to
request how many times each one was initted. In other words, the only way to quit for sure
is to do a loop like so:
// force a quit
while(Mix_Init(0))
Mix_Quit();
See Also:
Section 4.1.2 [Mix Init], page 10
Chapter 4: Functions
12
format
channels
chunksize
Chapter 4: Functions
13
AUDIO U16
same as AUDIO U16LSB (for backwards compatability probably)
AUDIO S16
same as AUDIO S16LSB (for backwards compatability probably)
AUDIO U16SYS
Unsigned 16-bit samples, in system byte order
AUDIO S16SYS
Signed 16-bit samples, in system byte order
See Also:
Section 4.1.5 [Mix CloseAudio], page 14, Section 4.1.8 [Mix QuerySpec], page 17, Section 4.3.1 [Mix AllocateChannels], page 28
Chapter 4: Functions
14
Mix_CloseAudio();
// you could SDL_Quit(); here...or not.
See Also:
Section 4.1.4 [Mix OpenAudio], page 12, Section 4.1.8 [Mix QuerySpec], page 17
Chapter 4: Functions
15
int mymixfunc(int i) {
Mix_SetError("mymixfunc is not implemented! %d was passed in.",i);
return(-1);
}
See Also:
Section 4.1.7 [Mix GetError], page 16
Chapter 4: Functions
16
See Also:
Section 4.1.6 [Mix SetError], page 15
Chapter 4: Functions
17
A pointer to an int where the frequency actually used by the opened audio
device will be stored.
format
A pointer to a Uint16 where the output format actually being used by the audio
device will be stored.
channels
Get the actual audio format in use by the opened audio device. This may or may not match
the parameters you passed to Mix OpenAudio.
Returns: 0 on error. If the device was open the number of times it was opened will be
returned. The values of the arguments variables are not set on an error.
See Also:
Section 4.1.4 [Mix OpenAudio], page 12
Chapter 4: Functions
4.2 Samples
These functions work with Mix_Chunk samples.
18
Chapter 4: Functions
19
See Also:
Section 4.5.1 [Mix GetNumMusicDecoders], page 55, Section 4.2.2 [Mix GetChunkDecoder],
page 20, Section 4.2.3 [Mix LoadWAV], page 21
Chapter 4: Functions
20
Get the name of the indexed sample chunk decoder. You need to get the number of sample
chunk decoders available using the Mix_GetNumChunkDecoders function.
Returns: The name of the indexed sample chunk decoder. This string is owned by the
SDL mixer library, do not modify or free it. It is valid until you call Mix_CloseAudio the
final time.
See Also:
Section 4.2.1 [Mix GetNumChunkDecoders], page 19, Section 4.5.2 [Mix GetMusicDecoder],
page 56, Section 4.2.3 [Mix LoadWAV], page 21
Chapter 4: Functions
21
See Also:
Section 4.2.4 [Mix LoadWAV RW], page 22, Section 4.2.5 [Mix QuickLoad WAV], page 23,
Section 4.2.8 [Mix FreeChunk], page 26
Chapter 4: Functions
22
The source SDL RWops as a pointer. The sample is loaded from this.
freesrc
A non-zero value mean is will automatically close/free the src for you.
Load src for use as a sample. This can load WAVE, AIFF, RIFF, OGG, and VOC formats.
Using SDL_RWops is not covered here, but they enable you to load from almost any source.
Note: You must call SDL OpenAudio before this. It must know the output characteristics
so it can convert the sample for playback, it does this conversion at load time.
Returns: a pointer to the sample as a Mix_Chunk. NULL is returned on errors.
See Also:
Section 4.2.3 [Mix LoadWAV], page 21, Section 4.2.5 [Mix QuickLoad WAV], page 23, Section 4.2.8 [Mix FreeChunk], page 26
Chapter 4: Functions
23
Load mem as a WAVE/RIFF file into a new sample. The WAVE in mem must be already
in the output format. It would be better to use Mix_LoadWAV_RW if you arent sure.
Note: This function does very little checking. If the format mismatches the output format,
or if the buffer is not a WAVE, it will not return an error. This is probably a dangerous
function to use.
Returns: a pointer to the sample as a Mix_Chunk. NULL is returned on errors.
See Also:
Section 4.2.3 [Mix LoadWAV], page 21, Section 4.2.6 [Mix QuickLoad RAW], page 24,
Section 4.2.8 [Mix FreeChunk], page 26
Chapter 4: Functions
24
Load mem as a raw sample. The data in mem must be already in the output format. If
you arent sure what you are doing, this is not a good function for you!
Note: This function does very little checking. If the format mismatches the output format
it will not return an error. This is probably a dangerous function to use.
Returns: a pointer to the sample as a Mix_Chunk. NULL is returned on errors, such as
when out of memory.
See Also:
Section 4.2.3 [Mix LoadWAV], page 21, Section 4.2.5 [Mix QuickLoad WAV], page 23, Section 4.2.8 [Mix FreeChunk], page 26
Chapter 4: Functions
25
volume
See Also:
Section 5.1 [Mix Chunk], page 87
Chapter 4: Functions
26
Free the memory used in chunk, and free chunk itself as well. Do not use chunk after this
without loading a new sample to it. Note: Its a bad idea to free a chunk that is still being
played...
See Also:
Section 4.2.3 [Mix LoadWAV], page 21, Section 4.2.4 [Mix LoadWAV RW], page 22, Section 4.2.5 [Mix QuickLoad WAV], page 23,
Chapter 4: Functions
27
4.3 Channels
These functions work with sound effect mixer channels. Music is not affected by these
functions.
Chapter 4: Functions
28
See Also:
Section 4.1.4 [Mix OpenAudio], page 12
Chapter 4: Functions
29
volume
Set the volume for any allocated channel. If channel is -1 then all channels at are set at
once. The volume is applied during the final mix, along with the sample volume. So setting
this volume to 64 will halve the output of all samples played on the specified channel. All
channels default to a volume of 128, which is the max. Newly allocated channels will have
the max volume set, so setting all channels volumes does not affect subsequent channel
allocations.
Returns: current volume of the channel. If channel is -1, the average volume is returned.
See Also:
Section 4.2.7 [Mix VolumeChunk], page 25, Section 4.5.9 [Mix VolumeMusic], page 63
Chapter 4: Functions
30
chunk
Sample to play.
loops
Play chunk on channel, or if channel is -1, pick the first free unreserved channel. The sample
will play for loops+1 number of times, unless stopped by halt, or fade out, or setting a new
expiration time of less time than it would have originally taken to play the loops, or closing
the mixer.
Note: this just calls Mix_PlayChannelTimed() with ticks set to -1.
Returns: the channel the sample is played on. On any errors, -1 is returned.
See Also:
Section 4.3.4 [Mix PlayChannelTimed], page 31, Section 4.3.5 [Mix FadeInChannel],
page 32, Section 4.3.9 [Mix HaltChannel], page 36, Section 4.3.10 [Mix ExpireChannel],
page 37, Section 4.4.1 [Mix ReserveChannels], page 45
Chapter 4: Functions
31
chunk
Sample to play.
loops
ticks
If the sample is long enough and has enough loops then the sample will stop after ticks milliseconds. Otherwise this function is the same as Section 4.3.3 [Mix PlayChannel], page 30.
Returns: the channel the sample is played on. On any errors, -1 is returned.
See Also:
Section 4.3.3 [Mix PlayChannel], page 30, Section 4.3.6 [Mix FadeInChannelTimed],
page 33,
Section 4.3.11 [Mix FadeOutChannel],
page 38,
Section 4.4.1
[Mix ReserveChannels], page 45
Chapter 4: Functions
32
chunk
Sample to play.
loops
ms
Milliseconds of time that the fade-in effect should take to go from silence to full
volume.
Play chunk on channel, or if channel is -1, pick the first free unreserved channel.
The channel volume starts at 0 and fades up to full volume over ms milliseconds of time.
The sample may end before the fade-in is complete if it is too short or doesnt have enough
loops. The sample will play for loops+1 number of times, unless stopped by halt, or fade
out, or setting a new expiration time of less time than it would have originally taken to
play the loops, or closing the mixer.
Note: this just calls Mix_FadeInChannelTimed() with ticks set to -1.
Returns: the channel the sample is played on. On any errors, -1 is returned.
See Also:
Section 4.3.3 [Mix PlayChannel], page 30, Section 4.3.6 [Mix FadeInChannelTimed],
page 33, Section 4.3.15 [Mix FadingChannel], page 42, Section 4.3.11 [Mix FadeOutChannel],
page 38, Section 4.4.1 [Mix ReserveChannels], page 45
Chapter 4: Functions
33
chunk
Sample to play.
loops
ms
Milliseconds of time that the fade-in effect should take to go from silence to full
volume.
ticks
If the sample is long enough and has enough loops then the sample will stop after ticks
milliseconds. Otherwise this function is the same as Section 4.3.5 [Mix FadeInChannel],
page 32.
Returns: the channel the sample is played on. On any errors, -1 is returned.
See Also:
Section 4.3.4 [Mix PlayChannelTimed], page 31, Section 4.3.5 [Mix FadeInChannel],
page 32, Section 4.3.15 [Mix FadingChannel], page 42, Section 4.3.9 [Mix HaltChannel],
page 36, Section 4.3.10 [Mix ExpireChannel], page 37, Section 4.4.1 [Mix ReserveChannels],
page 45
Chapter 4: Functions
34
Pause channel, or all playing channels if -1 is passed in. You may still halt a paused channel.
Note: Only channels which are actively playing will be paused.
See Also:
Section 4.3.8 [Mix Resume], page 35, Section 4.3.14 [Mix Paused], page 41, Section 4.3.9
[Mix HaltChannel], page 36
Chapter 4: Functions
35
See Also:
Section 4.3.7 [Mix Pause], page 34, Section 4.3.14 [Mix Paused], page 41
Chapter 4: Functions
36
See Also:
Section 4.3.10 [Mix ExpireChannel], page 37, Section 4.3.11 [Mix FadeOutChannel],
page 38, Section 4.3.12 [Mix ChannelFinished], page 39
Chapter 4: Functions
37
ticks
Halt channel playback, or all channels if -1 is passed in, after ticks milliseconds. Any
callback set by Mix_ChannelFinished will be called when the channel expires.
Returns: Number of channels set to expire. Whether or not they are active.
See Also:
Section 4.3.9 [Mix HaltChannel], page 36, Section 4.3.11 [Mix FadeOutChannel], page 38,
Section 4.3.12 [Mix ChannelFinished], page 39
Chapter 4: Functions
38
ms
Milliseconds of time that the fade-out effect should take to go to silence, starting
now.
Gradually fade out which channel over ms milliseconds starting from now. The channel will
be halted after the fade out is completed. Only channels that are playing are set to fade
out, including paused channels. Any callback set by Mix_ChannelFinished will be called
when the channel finishes fading out.
Returns: The number of channels set to fade out.
See Also:
Section 4.3.5 [Mix FadeInChannel], page 32, Section 4.3.6 [Mix FadeInChannelTimed],
page 33, Section 4.3.15 [Mix FadingChannel], page 42, Section 4.3.12 [Mix ChannelFinished],
page 39
Chapter 4: Functions
39
See Also:
Section 4.3.9 [Mix HaltChannel], page 36, Section 4.3.10 [Mix ExpireChannel], page 37
Chapter 4: Functions
40
See Also:
Section 4.3.14 [Mix Paused], page 41, Section 5.4 [Mix Fading], page 90, Section 4.3.3
[Mix PlayChannel], page 30, Section 4.3.7 [Mix Pause], page 34,
Chapter 4: Functions
41
See Also:
Section 4.3.13 [Mix Playing], page 40, Section 4.3.7 [Mix Pause], page 34, Section 4.3.8
[Mix Resume], page 35
Chapter 4: Functions
42
Tells you if which channel is fading in, out, or not. Does not tell you if the channel is playing
anything, or paused, so youd need to test that separately.
Returns: the fading status. Never returns an error.
See Also:
Section 5.4 [Mix Fading], page 90, Section 4.3.13 [Mix Playing], page 40, Section 4.3.14
[Mix Paused], page 41, Section 4.3.5 [Mix FadeInChannel], page 32, Section 4.3.6
[Mix FadeInChannelTimed], page 33, Section 4.3.11 [Mix FadeOutChannel], page 38
Chapter 4: Functions
43
Get the most recent sample chunk pointer played on channel. This pointer may be currently
playing, or just the last used.
Note: The actual chunk may have been freed, so this pointer may not be valid anymore.
Returns: Pointer to the Mix Chunk. NULL is returned if the channel is not allocated, or
if the channel has not played any samples yet.
See Also:
Section 5.1 [Mix Chunk], page 87, Section 4.3.13 [Mix Playing], page 40
Chapter 4: Functions
4.4 Groups
These functions work with groupings of mixer channels.
The default group tag number of -1, which refers to ALL channels.
44
Chapter 4: Functions
45
Reserve num channels from being used when playing samples when passing in -1 as a channel
number to playback functions. The channels are reserved starting from channel 0 to num1. Passing in zero will unreserve all channels. Normally SDL mixer starts without any
channels reserved.
The following functions are affected by this setting:
Section 4.3.3 [Mix PlayChannel], page 30
Section 4.3.4 [Mix PlayChannelTimed], page 31
Section 4.3.5 [Mix FadeInChannel], page 32
Section 4.3.6 [Mix FadeInChannelTimed], page 33
Returns: The number of channels reserved. Never fails, but may return less channels than
you ask for, depending on the number of channels previously allocated.
See Also:
Section 4.3.1 [Mix AllocateChannels], page 28
Chapter 4: Functions
46
tag
Add which channel to group tag, or reset its group to the default group tag (-1).
Returns: True(1) on success. False(0) is returned when the channel specified is invalid.
See Also:
Section 4.4.3 [Mix GroupChannels], page 47, Section 4.3.1 [Mix AllocateChannels], page 28
Chapter 4: Functions
47
First Channel number of channels to assign tag to. Must be less or equal to to.
to
Last Channel number of channels to assign tag to. Must be greater or equal to
from.
tag
Add channels starting at from up through to to group tag, or reset its group to the default
group tag (-1).
Returns: The number of tagged channels on success. If that number is less than to-from+1
then some channels were no tagged because they didnt exist.
See Also:
Section 4.4.2 [Mix GroupChannel], page 46, Section 4.3.1 [Mix AllocateChannels], page 28
Chapter 4: Functions
48
See Also:
Section 4.4.2 [Mix GroupChannel], page 46, Section 4.4.3 [Mix GroupChannels], page 47
Chapter 4: Functions
49
See Also:
Section 4.4.6 [Mix GroupOldest], page 50, Section 4.4.7 [Mix GroupNewer], page 51, Section 4.4.2 [Mix GroupChannel], page 46, Section 4.4.3 [Mix GroupChannels], page 47
Chapter 4: Functions
50
See Also:
Section 4.4.7 [Mix GroupNewer], page 51, Section 4.4.5 [Mix GroupAvailable], page 49,
Section 4.4.2 [Mix GroupChannel], page 46, Section 4.4.3 [Mix GroupChannels], page 47
Chapter 4: Functions
51
Find the newest, most recently started, actively playing channel in group tag.
Returns: The channel found on success. -1 is returned when no channels in the group are
playing or the group is empty.
See Also:
Section 4.4.6 [Mix GroupOldest], page 50, Section 4.4.5 [Mix GroupAvailable], page 49,
Section 4.4.2 [Mix GroupChannel], page 46, Section 4.4.3 [Mix GroupChannels], page 47
Chapter 4: Functions
52
ms
Milliseconds of time that the fade-out effect should take to go to silence, starting
now.
Gradually fade out channels in group tag over ms milliseconds starting from now. The
channels will be halted after the fade out is completed. Only channels that are playing are
set to fade out, including paused channels. Any callback set by Mix_ChannelFinished will
be called when each channel finishes fading out.
Returns: The number of channels set to fade out.
See Also:
Section 4.4.9 [Mix HaltGroup], page 53, Section 4.3.11 [Mix FadeOutChannel], page 38,
Section 4.3.15 [Mix FadingChannel], page 42, Section 4.3.12 [Mix ChannelFinished],
page 39
Chapter 4: Functions
53
See Also:
Section 4.4.8 [Mix FadeOutGroup], page 52, Section 4.3.9 [Mix HaltChannel], page 36,
Section 4.3.12 [Mix ChannelFinished], page 39
Chapter 4: Functions
54
4.5 Music
These functions work with music. Music is not played on a normal mixer channel. Music
is therefore manipulated separately, except in post-processing hooks.
Chapter 4: Functions
55
See Also:
Section 4.2.1 [Mix GetNumChunkDecoders], page 19, Section 4.5.2 [Mix GetMusicDecoder],
page 56, Section 4.5.3 [Mix LoadMUS], page 57
Chapter 4: Functions
56
Get the name of the indexed music decoder. You need to get the number of music decoders
available using the Mix_GetNumMusicDecoders function.
Returns: The name of the indexed music decoder. This string is owned by the SDL mixer
library, do not modify or free it. It is valid until you call Mix_CloseAudio the final time.
See Also:
Section 4.5.1 [Mix GetNumMusicDecoders], page 55, Section 4.2.2 [Mix GetChunkDecoder],
page 20, Section 4.2.3 [Mix LoadWAV], page 21
Chapter 4: Functions
57
Load music file to use. This can load WAVE, MOD, MIDI, OGG, MP3, FLAC, and any
file that you use a command to play with.
If you are using an external command to play the music, you must call Mix_SetMusicCMD
before this, otherwise the internal players will be used. Alternatively, if you have set an
external command up and dont want to use it, you must call Mix_SetMusicCMD(NULL) to
use the built-in players again.
Returns: A pointer to a Mix Music. NULL is returned on errors.
See Also:
Section 5.2 [Mix Music], page 88, Section 4.5.14 [Mix SetMusicCMD], page 68,
Section 4.5.5 [Mix PlayMusic], page 59, Section 4.5.6 [Mix FadeInMusic], page 60,
Section 4.5.7 [Mix FadeInMusicPos], page 61
Chapter 4: Functions
58
Free the loaded music. If music is playing it will be halted. If music is fading out, then this
function will wait (blocking) until the fade out is complete.
// free music
Mix_Music *music;
Mix_FreeMusic(music);
music=NULL; // so we know we freed it...
See Also:
Section 4.5.3 [Mix LoadMUS], page 57
Chapter 4: Functions
59
loops
Play the loaded music loop times through from start to finish. The previous music will be
halted, or if fading out it waits (blocking) for that to finish.
Returns: 0 on success, or -1 on errors.
See Also:
Section 4.5.6 [Mix FadeInMusic], page 60
Chapter 4: Functions
60
loops
ms
Fade in over ms milliseconds of time, the loaded music, playing it loop times through from
start to finish.
The fade in effect only applies to the first loop.
Any previous music will be halted, or if it is fading out it will wait (blocking) for the fade
to complete.
This function is the same as Mix_FadeInMusicPos(music, loops, ms, 0).
Returns: 0 on success, or -1 on errors.
See Also:
Section 4.5.5 [Mix PlayMusic], page 59, Section 4.5.7 [Mix FadeInMusicPos], page 61
Chapter 4: Functions
61
loops
ms
position
Fade in over ms milliseconds of time, the loaded music, playing it loop times through from
start to finish.
The fade in effect only applies to the first loop.
The first time the music is played, it posistion will be set to posistion, which means different
things for different types of music files, see Mix_SetMusicPosition for more info on that.
Any previous music will be halted, or if it is fading out it will wait (blocking) for the fade
to complete.
Returns: 0 on success, or -1 on errors.
See Also:
Section 4.5.5 [Mix PlayMusic], page 59, Section 4.5.6 [Mix FadeInMusic], page 60, Section 4.5.13 [Mix SetMusicPosition], page 67
Chapter 4: Functions
62
arg
This sets up a custom music player function. The function will be called with arg passed
into the udata parameter when the mix func is called. The stream parameter passes in
the audio stream buffer to be filled with len bytes of music. The music player will then
be called automatically when the mixer needs it. Music playing will start as soon as this
is called. All the music playing and stopping functions have no effect on music after this.
Pause and resume will work. Using a custom music player and the internal music player is
not possible, the custom music player takes priority. To stop the custom music player call
Mix_HookMusic(NULL, NULL).
NOTE: NEVER call SDL Mixer functions, nor SDL_LockAudio, from a callback function.
See Also:
Section 4.5.14 [Mix SetMusicCMD], page 68, Section 4.5.22 [Mix GetMusicHookData],
page 76
Chapter 4: Functions
63
Set the volume to volume, if it is 0 or greater, and return the previous volume setting.
Setting the volume during a fade will not work, the faders use this function to perform their
effect! Setting volume while using an external music player set by Mix_SetMusicCMD will
have no effect, and Mix_GetError will show the reason why not.
Returns: The previous volume setting.
See Also:
Section 4.5.6 [Mix FadeInMusic], page 60, Section 4.5.16 [Mix FadeOutMusic], page 70,
Section 4.5.14 [Mix SetMusicCMD], page 68
Chapter 4: Functions
64
See Also:
Section 4.5.11 [Mix ResumeMusic], page 65, Section 4.5.20 [Mix PausedMusic], page 74,
Section 4.5.15 [Mix HaltMusic], page 69
Chapter 4: Functions
65
See Also:
Section 4.5.10 [Mix PauseMusic], page 64, Section 4.5.20 [Mix PausedMusic], page 74
Chapter 4: Functions
66
See Also:
Section 4.5.5 [Mix PlayMusic], page 59
Chapter 4: Functions
67
Set the position of the currently playing music. The position takes different meanings for
different music sources. It only works on the music sources listed below.
MOD
The double is cast to Uint16 and used for a pattern number in the module.
Passing zero is similar to rewinding the song.
OGG
MP3
See Also:
Section 4.5.7 [Mix FadeInMusicPos], page 61
Chapter 4: Functions
68
Setup a command line music player to use to play music. Any music playing will be halted.
The music file to play is set by calling Mix_LoadMUS(filename), and the filename is appended as the last argument on the commandline. This allows you to reuse the music
command to play multiple files. The command will be sent signals SIGTERM to halt,
SIGSTOP to pause, and SIGCONT to resume. The command program should react correctly to those signals for it to function properly with SDL Mixer. Mix_VolumeMusic has
no effect when using an external music player, and Mix_GetError will have an error code
set. You should set the music volume in the music players command if the music player
supports that. Looping music works, by calling the command again when the previous
music player process has ended. Playing music through a command uses a forked process
to execute the music command.
To use the internal music players set the command to NULL.
NOTE: External music is not mixed by SDL mixer, so no post-processing hooks will be for
music.
NOTE: Playing music through an external command may not work if the sound driver does
not support multiple openings of the audio device, since SDL Mixer already has the audio
device open for playing samples through channels.
NOTE: Commands are not totally portable, so be careful.
Returns: 0 on success, or -1 on any errors, such as running out of memory.
See Also:
Section 4.5.5 [Mix PlayMusic], page 59, Section 4.5.9 [Mix VolumeMusic], page 63
Chapter 4: Functions
69
See Also:
Section 4.5.16 [Mix FadeOutMusic], page 70, Section 4.5.17 [Mix HookMusicFinished],
page 71
Chapter 4: Functions
70
Milliseconds of time that the fade-out effect should take to go to silence, starting
now.
Gradually fade out the music over ms milliseconds starting from now. The music will be
halted after the fade out is completed. Only when music is playing and not fading already
are set to fade out, including paused channels. Any callback set by Mix_HookMusicFinished
will be called when the music finishes fading out.
Returns: 1 on success, 0 on failure.
See Also:
Section 4.5.15 [Mix HaltMusic], page 69, Section 4.5.21 [Mix FadingMusic], page 75, Section 4.5.19 [Mix PlayingMusic], page 73, Section 4.5.17 [Mix HookMusicFinished], page 71
Chapter 4: Functions
71
See Also:
Section 4.5.15 [Mix HaltMusic], page 69, Section 4.5.16 [Mix FadeOutMusic], page 70
Chapter 4: Functions
72
Tells you the file format encoding of the music. This may be handy when used with Mix_
SetMusicPosition, and other music functions that vary based on the type of music being
played. If you want to know the type of music currently being played, pass in NULL to
music.
Returns: The type of music or if music is NULL then the currently playing music type,
otherwise MUS NONE if no music is playing.
See Also:
Section 5.3 [Mix MusicType], page 89, Section 4.6.7 [Mix SetPosition], page 84
Chapter 4: Functions
73
See Also:
Section 4.5.20 [Mix PausedMusic], page 74, Section 4.5.21 [Mix FadingMusic], page 75,
Section 4.5.5 [Mix PlayMusic], page 59
Chapter 4: Functions
74
See Also:
Section 4.5.19 [Mix PlayingMusic], page 73, Section 4.5.10 [Mix PauseMusic], page 64,
Section 4.5.11 [Mix ResumeMusic], page 65
Chapter 4: Functions
75
See Also:
Section 5.4 [Mix Fading], page 90, Section 4.5.20 [Mix PausedMusic], page 74,
Section 4.5.19 [Mix PlayingMusic], page 73, Section 4.5.7 [Mix FadeInMusicPos], page 61,
Section 4.5.16 [Mix FadeOutMusic], page 70
Chapter 4: Functions
76
See Also:
Section 4.5.8 [Mix HookMusic], page 62
Chapter 4: Functions
77
4.6 Effects
These functions are for special effects processing. Not all effects are all that special. All
effects are post processing routines that are either built-in to SDL mixer or created by you.
Effects can be applied to individual channels, or to the final mixed stream which contains
all the channels including music.
The built-in processors: Mix_SetPanning, Mix_SetPosition, Mix_SetDistance, and
Mix_SetReverseStereo, all look for an environment variable, MIX EFFECTSMAXSPEED
to be defined. If the environment variable is defined these processors may use more memory
or reduce the quality of the effects, all for better speed.
Chapter 4: Functions
78
The function pointer for any cleanup routine to be called when the channel is
done playing a sample.
This may be NULL for any processors that dont need to clean up any memory
or other dynamic data.
arg
Hook a processor function f into a channel for post processing effects. You may just be
reading the data and displaying it, or you may be altering the stream to add an echo. Most
processors also have state data that they allocate as they are in use, this would be stored
in the arg pointer data space. When a processor is finished being used, any function passed
into d will be called, which is when your processor should clean up the data in the arg data
space.
The effects are put into a linked list, and always appended to the end, meaning they always
work on previously registered effects output. Effects may be added multiple times in a row.
Effects are cumulative this way.
Returns: Zero on errors, such as a nonexisting channel.
See Also:
Section 4.6.2 [Mix UnregisterEffect], page 79, Section 4.6.3 [Mix UnregisterAllEffects],
page 80
Chapter 4: Functions
79
Remove the oldest (first found) registered effect function f from the effect list for channel.
This only removes the first found occurance of that function, so it may need to be called
multiple times if you added the same function multiple times, just stop removing when
Mix_UnregisterEffect returns an error, to remove all occurances of f from a channel.
If the channel is active the registered effect will have its Mix_EffectDone_t function called,
if it was specified in Mix_RegisterEffect.
Returns: Zero on errors, such as invalid channel, or effect function not registered on channel.
See Also:
Section 4.6.3 [Mix UnregisterAllEffects], page 80, Section 4.6.1 [Mix RegisterEffect],
page 78
Chapter 4: Functions
80
This removes all effects registered to channel. If the channel is active all the registered
effects will have their Mix_EffectDone_t functions called, if they were specified in Mix_
RegisterEffect.
Returns: Zero on errors, such as channel not existing.
See Also:
Section 4.6.2 [Mix UnregisterEffect], page 79, Section 4.6.1 [Mix RegisterEffect], page 78
Chapter 4: Functions
81
arg
A pointer to data to pass into the mix funcs udata parameter. It is a good
place to keep the state data for the processor, especially if the processor is made
to handle multiple channels at the same time.
This may be NULL, depending on the processor.
Hook a processor function mix func to the postmix stream for post processing effects. You
may just be reading the data and displaying it, or you may be altering the stream to add
an echo. Most processors also have state data that they allocate as they are in use, this
would be stored in the arg pointer data space. This processor is never really finished, until
the audio device is closed, or you pass NULL as the mix func.
There can only be one postmix function used at a time through this method. Use
Mix_RegisterEffect(MIX_CHANNEL_POST, mix_func, NULL, arg) to use multiple
postmix processors.
This postmix processor is run AFTER all the registered postmixers set up by
Mix_RegisterEffect.
See Also:
Section 4.6.1 [Mix RegisterEffect], page 78
Chapter 4: Functions
82
left
right
This effect will only work on stereo audio. Meaning you called Mix_OpenAudio with 2
channels (MIX DEFAULT CHANNELS). The easiest way to do true panning is to call
Mix_SetPanning(channel, left, 254 - left); so that the total volume is correct, if you
consider the maximum volume to be 127 per channel for center, or 254 max for left, this
works, but about halves the effective volume.
This Function registers the effect for you, so dont try to Mix_RegisterEffect it yourself.
NOTE: Setting both left and right to 255 will unregister the effect from channel. You cannot
unregister it any other way, unless you use Mix_UnregisterAllEffects on the channel.
NOTE: Using this function on a mono audio device will not register the effect, nor will it
return an error status.
Returns: Zero on errors, such as bad channel, or if Mix_RegisterEffect failed.
See Also:
Section 4.6.7 [Mix SetPosition], page 84, Section 4.6.3 [Mix UnregisterAllEffects], page 80
Chapter 4: Functions
83
distance
This effect simulates a simple attenuation of volume due to distance. The volume never
quite reaches silence, even at max distance.
NOTE: Using a distance of 0 will cause the effect to unregister itself from channel. You
cannot unregister it any other way, unless you use Mix_UnregisterAllEffects on the
channel.
Returns: Zero on errors, such as an invalid channel, or if Mix_RegisterEffect failed.
See Also:
Section 4.6.7 [Mix SetPosition], page 84, Section 4.6.3 [Mix UnregisterAllEffects], page 80
Chapter 4: Functions
84
angle
distance
This effect emulates a simple 3D audio effect. Its not all that realistic, but it can help
improve some level of realism. By giving it the angle and distance from the cameras point
of view, the effect pans and attenuates volumes. If you are looking for better positional
audio, using OpenAL is suggested.
NOTE: Using angle and distance of 0, will cause the effect to unregister itself from channel.
You cannot unregister it any other way, unless you use Mix_UnregisterAllEffects on the
channel.
Returns: Zero on errors, such as an invalid channel, or if Mix_RegisterEffect failed.
See Also:
Section 4.6.5 [Mix SetPanning], page 82, Section 4.6.6 [Mix SetDistance], page 83, Section 4.6.3 [Mix UnregisterAllEffects], page 80
Chapter 4: Functions
85
flip
See Also:
Section 4.6.3 [Mix UnregisterAllEffects], page 80
Chapter 5: Types
5 Types
These types are defined and used by the SDL mixer API.
86
Chapter 5: Types
87
allocated
abuf
Pointer to the sample data, which is in the output format and sample rate.
alen
volume
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.
See Also:
Section 4.2.7 [Mix VolumeChunk], page 25, Section 4.3.16 [Mix GetChunk], page 43, Section 4.2.3 [Mix LoadWAV], page 21, Section 4.2.4 [Mix LoadWAV RW], page 22, Section 4.2.8 [Mix FreeChunk], page 26, Section 5.2 [Mix Music], page 88
Chapter 5: Types
88
This is an opaque data type used for Music data. This should always be used as a
pointer. Who knows why it isnt a pointer in this typedef...
See Also:
Section 4.5.3 [Mix LoadMUS], page 57, Section 4.5.4 [Mix FreeMusic], page 58, Section 5.1
[Mix Chunk], page 87
Chapter 5: Types
89
typedef enum {
MUS_NONE,
MUS_CMD,
MUS_WAV,
MUS_MOD,
MUS_MID,
MUS_OGG,
MUS_MP3, /* using SMPEG */
MUS_MP3_MAD,
MUS_FLAC
} Mix_MusicType;
Chapter 5: Types
90
typedef enum {
MIX_NO_FADING,
MIX_FADING_OUT,
MIX_FADING_IN
} Mix_Fading;
Chapter 5: Types
91
chan
stream
len
udata
This is the prototype for effect processing functions. These functions are used to apply
effects processing on a sample chunk. As a channel plays a sample, the registered effect
functions are called. Each effect would then read and perhaps alter the len bytes of stream.
It may also be advantageous to keep the effect state in the udata, with would be setup when
registering the effect function on a channel.
See Also:
Section 4.6.1 [Mix RegisterEffect], page 78 Section 4.6.2 [Mix UnregisterEffect], page 79
Chapter 5: Types
92
chan
udata
This is the prototype for effect processing functions. This is called when a channel has
finished playing, or halted, or is deallocated. This is also called when a processor is unregistered while processing is active. At that time the effects processing function may want to
reset some internal variables or free some memory. It should free memory at least, because
the processor could be freed after this call.
See Also:
Section 4.6.1 [Mix RegisterEffect], page 78 Section 4.6.2 [Mix UnregisterEffect], page 79
Chapter 6: Defines
93
6 Defines
SDL MIXER MAJOR VERSION
1
SDL mixer library major number at compilation time
SDL MIXER MINOR VERSION
2
SDL mixer library minor number at compilation time
SDL MIXER PATCHLEVEL
9
SDL mixer library patch level at compilation time
MIX CHANNELS
8
The default mixer has this many simultaneous mixing channels after the first
call to Mix_OpenAudio.
MIX DEFAULT FREQUENCY
22050
Good default sample rate in Hz (samples per second) for PC sound cards.
MIX DEFAULT FORMAT
AUDIO_S16SYS
The suggested default is signed 16bit samples in host byte order.
MIX DEFAULT CHANNELS
2
Stereo sound is a good default.
MIX MAX VOLUME
128
Maximum value for any volume setting.
This is currently the same as SDL MIX MAXVOLUME.
MIX CHANNEL POST
-2
This is the channel number used for post processing effects.
MIX EFFECTSMAXSPEED
"MIX_EFFECTSMAXSPEED"
A convience definition for the string name of the environment variable to define
when you desire the internal effects to sacrifice quality and/or RAM for speed.
The environment variable must be set (else nonexisting) before Mix_OpenAudio
is called for the setting to take effect.
Chapter 7: Glossary
94
7 Glossary
Byte Order
Also known as Big-Endian. Which means the most significant byte comes first in storage.
Sparc and Motorola 68k based chips are MSB ordered.
(SDL defines this as SDL BYTEORDER==SDL BIG ENDIAN)
Little-Endian(LSB) is stored in the opposite order, with the least significant byte first in
memory. Intel and AMD are two LSB machines.
(SDL defines this as SDL BYTEORDER==SDL LIL ENDIAN)
Index
Index
(Index is nonexistent)
95