[Top] | [Contents] | [Index] | [ ? ] |
1. Overview The README from the SDL_mixer distribution
2. Getting Started Using SDL_mixer
3. Conflicts Conflicts with SDL Audio functions
4. Functions Functions supported by the SDL_mixer API 5. Types Types used with the SDL_mixer API 6. Defines Defined values/macros in the SDL_mixer API
7. Glossary Terms used in this document
Index Index of selected words
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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. there's 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 doesn't explain how to get music and samples to use, it will explain how to use them with SDL_mixer.
Feel free to contact me: jcatki@jcatki.no-ip.org
I am also usually on IRC at irc.freenode.net in the #SDL channel as LIM
This is the README in the SDL_mixer source archive.
SDL_mixer 1.2
The latest version of this library is available from: Due to popular demand, here is a simple multi-channel audio mixer. It supports 8 channels of 16 bit stereo audio, plus a single channel of music, mixed by the popular MikMod MOD, Timidity MIDI and SMPEG MP3 libraries. See the header file SDL_mixer.h and the examples playwave.c and playmus.c for documentation on this mixer library. The mixer can currently load Microsoft WAVE files and Creative Labs VOC files as audio samples, and can load MIDI files via Timidity and the following music formats via MikMod: .MOD .S3M .IT .XM. It can load Ogg Vorbis streams as music if built with the Ogg Vorbis libraries, and finally it can load MP3 music using the SMPEG library. The process of mixing MIDI files to wave output is very CPU intensive, so if playing regular WAVE files sound great, but playing MIDI files sound choppy, try using 8-bit audio, mono audio, or lower frequencies. To play MIDI files, you'll need to get a complete set of GUS patches from: Timidity GUS Patches and unpack them in /usr/local/lib under UNIX, and C:\ under Win32. This library is available under the GNU Library General Public License, see the file "COPYING" for details. |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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:
|
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) using included mikmod
- MIDI (.mid) using timidity or native midi hardware
- OggVorbis (.ogg) requiring ogg/vorbis libraries on system
- MP3 (.mp3) requiring SMPEG 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://jcatki.no-ip.org/SDL_mixer/
2.1 Includes The include files to use for SDL_mixer 2.2 Compiling Using the SDL_mixer library and header file.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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"
|
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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.
Simple Example for compiling an object file:
Simple Example for compiling an object file:
|
Now myprogram
is ready to run.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
When using SDL_mixer functions you need to avoid the following functions from SDL:
SDL_OpenAudio
Mix_OpenAudio
instead.
SDL_CloseAudio
Mix_CloseAudio
instead.
SDL_PauseAudio
Mix_Pause(-1)
and Mix_PauseMusic
instead, to pause.Mix_Resume(-1)
and Mix_ResumeMusic
instead, to unpause.
SDL_LockAudio
SDL_UnlockAudio
You may call the following functions freely:
SDL_AudioDriverName
SDL_GetAudioStatus
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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These are the functions in the SDL_mixer API.
4.1 General API activation 4.2 Samples Loading sounds from files or memory 4.3 Channels Sound effect channels 4.4 Groups Sound effect channel grouping 4.5 Music Music playing 4.6 Effects Special effects processing
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These functions are useful, as they are the only/best ways to work with SDL_mixer.
Info
Activation
4.1.1 Mix_Linked_Version Get version number
Errors
4.1.2 Mix_OpenAudio Open sound mixer 4.1.3 Mix_CloseAudio Close sound mixer
Settings
4.1.4 Mix_SetError Set the current error string 4.1.5 Mix_GetError Get the current error string
4.1.6 Mix_QuerySpec Get output format
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
const SDL_version *Mix_Linked_Version()
void MIX_VERSION(SDL_version *compile_version)
This works similar to SDL_Linked_Version
and SDL_VERSION.
Using these you can compare the runtime version to the version that you compiled with.
|
See Also:
4.1.2 Mix_OpenAudio,
4.1.6 Mix_QuerySpec
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize)
Initialize the mixer API.
This must be called before using other functions in this library.
SDL must be initialized with SDL_INIT_AUDIO before this call.
frequency would be 44100 for 44.1KHz, which is CD audio rate. Most games use 22050, because 44100 requires too much CPU power on older computers.
chunksize is the size of each mixed sample. The smaller this is the more your hooks will be called. If make this too small on a slow system, sound may skip. If made to large, sound effects will lag behind the action more. You want a happy medium for your target computer. You also may make this 4096, or larger, if you are just playing music.
MIX_CHANNELS(8) mixing channels will be allocated by default.
You may call this function multiple times, however you will have to call Mix_CloseAudio just as many times for the device to actually close. The format will not changed on subsequent calls. So you will have to close all the way before trying to open with different format parameters.
format is based on SDL audio support, see SDL_audio.h.
Here are the values listed there:
Returns: 0 on success, -1 on errors
|
See Also:
4.1.3 Mix_CloseAudio,
4.1.6 Mix_QuerySpec,
4.3.1 Mix_AllocateChannels
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
void Mix_CloseAudio()
Shutdown and cleanup the mixer API.
After calling this all audio is stopped, the device is closed,
and the SDL_mixer functions should not be used.
You may, of course, use Mix_OpenAudio to start the functionality again.
Note: This function doesn't do anything until you have called it the same
number of times that you called Mix_OpenAudio.
You may use Mix_QuerySpec
to find out how many times Mix_CloseAudio
needs to be called before the device is actually closed.
|
See Also:
4.1.2 Mix_OpenAudio,
4.1.6 Mix_QuerySpec
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
void Mix_SetError(const char *fmt, ...)
This is the same as SDL_SetError, which sets the error string which may be fetched with Mix_GetError (or SDL_GetError).
This functions acts like printf, except that it is limited to SDL_ERRBUFIZE(1024) chars in length. It only accepts the following format types: %s, %d, %f, %p
. No variations are supported, like %.2f
would not work. For any more specifics read the SDL docs.
|
See Also:
4.1.5 Mix_GetError
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
char *Mix_GetError()
This is the same as SDL_GetError, which returns the last error set as a string which you may use to tell the user what happened when an error status has been returned from an SDL_mixer function call.
Returns: a char pointer (string) containing a humam readble version or the reason for the last error that occured.
|
See Also:
4.1.4 Mix_SetError
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_QuerySpec(int *frequency, Uint16 *format, int *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:
4.1.2 Mix_OpenAudio
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These functions work with Mix_Chunk samples.
Loading
Settings
4.2.1 Mix_LoadWAV From a file 4.2.2 Mix_LoadWAV_RW Using RWops 4.2.3 Mix_QuickLoad_WAV From memory, in output format already 4.2.4 Mix_QuickLoad_RAW From memory, in output format already
Freeing
4.2.5 Mix_VolumeChunk Set mix volume
4.2.6 Mix_FreeChunk Free sample
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Mix_Chunk *Mix_LoadWAV(char *file)
Load file for use as a sample. This is actually Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1)
. This can load WAVE, AIFF, RIFF, OGG, and VOC files.
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:
4.2.2 Mix_LoadWAV_RW,
4.2.3 Mix_QuickLoad_WAV,
4.2.6 Mix_FreeChunk
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc)
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:
4.2.1 Mix_LoadWAV,
4.2.3 Mix_QuickLoad_WAV,
4.2.6 Mix_FreeChunk
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Mix_Chunk *Mix_QuickLoad_WAV(Uint8 *mem)
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 aren't 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:
4.2.1 Mix_LoadWAV,
4.2.4 Mix_QuickLoad_RAW,
4.2.6 Mix_FreeChunk
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Mix_Chunk *Mix_QuickLoad_RAW(Uint8 *mem)
Load mem as a raw sample. The data in mem must be already in the output format. If you aren't 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:
4.2.1 Mix_LoadWAV,
4.2.3 Mix_QuickLoad_WAV,
4.2.6 Mix_FreeChunk
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_VolumeChunk(Mix_Chunk *chunk, int volume)
Set chunk->volume to volume.
The volume setting will take effect when the chunk is used on a channel, being mixed into the output.
Returns: previous chunk->volume setting. if you passed a negative value for volume then this volume is still the current volume for the chunk.
|
See Also:
5.1 Mix_Chunk
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
void Mix_FreeChunk(Mix_Chunk *chunk)
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: It's a bad idea to free a chunk that is still being played...
|
See Also:
4.2.1 Mix_LoadWAV,
4.2.2 Mix_LoadWAV_RW,
4.2.3 Mix_QuickLoad_WAV,
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These functions work with sound effect mixer channels. Music is not affected by these functions.
Setup
Playing
4.3.1 Mix_AllocateChannels Set the number of channels to mix 4.3.2 Mix_Volume Set the mix volume of a channel
Pausing
4.3.3 Mix_PlayChannel Play loop 4.3.4 Mix_PlayChannelTimed Play loop and limit by time 4.3.5 Mix_FadeInChannel Play loop with fade in 4.3.6 Mix_FadeInChannelTimed Play loop with fade in and limit by time
Stopping
4.3.7 Mix_Pause Pause a channel 4.3.8 Mix_Resume Resume a paused channel
Info
4.3.9 Mix_HaltChannel Stop playing on a channel 4.3.10 Mix_ExpireChannel Change the timed stoppage of a channel 4.3.11 Mix_FadeOutChannel Stop playing channel after timed fade out 4.3.12 Mix_ChannelFinished Set callback for when channel finishes playing
4.3.13 Mix_Playing Get the active playing status of a channel 4.3.14 Mix_Paused Get the pause status of a channel 4.3.15 Mix_FadingChannel Get the fade status of a channel 4.3.16 Mix_GetChunk Get the sample playing on a channel
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_AllocateChannels(int numchans)
Set the number of channels being mixed. This can be called multiple times, even with sounds playing. If numchans is less than the current number of channels, then the higher channels will be stopped, freed, and therefore not mixed any longer. It's probably not a good idea to change the size 1000 times a second though.
If any channels are deallocated, any callback set by Mix_ChannelFinished
will be called when each channel is halted to be freed.
Note: passing in zero WILL free all mixing channels, however music will still play.
Returns: The number of channels allocated. Never fails...but a high number of channels can segfault if you run out of memory. We're talking REALLY high!
|
See Also:
4.1.2 Mix_OpenAudio
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_Volume(int channel, int volume)
-1
will set the volume for all allocated channels.
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:
4.2.5 Mix_VolumeChunk,
4.5.7 Mix_VolumeMusic
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_PlayChannel(int channel, Mix_Chunk *chunk, int 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:
4.3.4 Mix_PlayChannelTimed,
4.3.5 Mix_FadeInChannel,
4.3.9 Mix_HaltChannel,
4.3.10 Mix_ExpireChannel,
4.4.1 Mix_ReserveChannels
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_PlayChannelTimed(int channel, Mix_Chunk *chunk,
int loops, int 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 4.3.3 Mix_PlayChannel.
Returns: the channel the sample is played on. On any errors, -1 is returned.
|
See Also:
4.3.3 Mix_PlayChannel,
4.3.6 Mix_FadeInChannelTimed,
4.3.11 Mix_FadeOutChannel,
4.4.1 Mix_ReserveChannels
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_FadeInChannel(int channel, Mix_Chunk *chunk,
int loops, int ms)
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 doesn't 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:
4.3.3 Mix_PlayChannel,
4.3.6 Mix_FadeInChannelTimed,
4.3.15 Mix_FadingChannel,
4.3.11 Mix_FadeOutChannel,
4.4.1 Mix_ReserveChannels
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_FadeInChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ms, int 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 4.3.5 Mix_FadeInChannel.
Returns: the channel the sample is played on. On any errors, -1 is returned.
|
See Also:
4.3.4 Mix_PlayChannelTimed,
4.3.5 Mix_FadeInChannel,
4.3.15 Mix_FadingChannel,
4.3.9 Mix_HaltChannel,
4.3.10 Mix_ExpireChannel,
4.4.1 Mix_ReserveChannels
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
void Mix_Pause(int channel)
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:
4.3.8 Mix_Resume,
4.3.14 Mix_Paused,
4.3.9 Mix_HaltChannel
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
void Mix_Resume(int channel)
Unpause channel, or all playing and paused channels if -1 is passed in.
|
See Also:
4.3.7 Mix_Pause,
4.3.14 Mix_Paused
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_HaltChannel(int channel)
Halt channel playback, or all channels if -1 is passed in.
Any callback set by Mix_ChannelFinished
will be called.
Returns: always returns zero. (kinda silly)
|
See Also:
4.3.10 Mix_ExpireChannel,
4.3.11 Mix_FadeOutChannel,
4.3.12 Mix_ChannelFinished
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_ExpireChannel(int channel, int 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:
4.3.9 Mix_HaltChannel,
4.3.11 Mix_FadeOutChannel,
4.3.12 Mix_ChannelFinished
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_FadeOutChannel(int channel, int ms)
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:
4.3.5 Mix_FadeInChannel,
4.3.6 Mix_FadeInChannelTimed,
4.3.15 Mix_FadingChannel,
4.3.12 Mix_ChannelFinished
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
void Mix_ChannelFinished(void (*channel_finished)(int channel))
When channel playback is halted, then the specified channel_finished function is called. The channel
parameter will contain the channel number that has finished.
NOTE: NEVER call SDL_Mixer functions, nor SDL_LockAudio
, from a callback function.
|
|
See Also:
4.3.9 Mix_HaltChannel,
4.3.10 Mix_ExpireChannel
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_Playing(int channel)
Tells you if channel is playing, or not.
Note: Does not check if the channel has been paused.
Returns: Zero if the channel is not playing. Otherwise if you passed in -1, the number of channels playing is returned. If you passed in a specific channel, then 1 is returned if it is playing.
|
See Also:
4.3.14 Mix_Paused,
5.4 Mix_Fading,
4.3.3 Mix_PlayChannel,
4.3.7 Mix_Pause,
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_Paused(int channel)
Tells you if channel is paused, or not.
Note: Does not check if the channel has been halted after it was paused, which may seem a little weird.
Returns: Zero if the channel is not paused. Otherwise if you passed in -1, the number of paused channels is returned. If you passed in a specific channel, then 1 is returned if it is paused.
|
See Also:
4.3.13 Mix_Playing,
4.3.7 Mix_Pause,
4.3.8 Mix_Resume
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Mix_Fading Mix_FadingChannel(int which)
Tells you if which channel is fading in, out, or not. Does not tell you if the channel is playing anything, or paused, so you'd need to test that separately.
Returns: the fading status. Never returns an error.
|
See Also:
5.4 Mix_Fading,
4.3.13 Mix_Playing,
4.3.14 Mix_Paused,
4.3.5 Mix_FadeInChannel,
4.3.6 Mix_FadeInChannelTimed,
4.3.11 Mix_FadeOutChannel
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Mix_Chunk *Mix_GetChunk(int channel)
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:
5.1 Mix_Chunk,
4.3.13 Mix_Playing
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These functions work with groupings of mixer channels.
The default group tag number of -1, which refers to ALL channels.
Setup
TODO
4.4.1 Mix_ReserveChannels Prevent channels from being used in default group
Info
4.4.2 Mix_GroupChannel Add/remove channel to/from group 4.4.3 Mix_GroupChannels Add/remove segment of channels to/from group
Stopping
4.4.4 Mix_GroupCount Get number of channels in group 4.4.5 Mix_GroupAvailable Get first inactive channel in group 4.4.6 Mix_GroupOldest Get oldest busy channel in group 4.4.7 Mix_GroupNewer Get youngest busy channel in group
4.4.8 Mix_FadeOutGroup Fade out a group over time 4.4.9 Mix_HaltGroup Stop a group
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_ReserveChannels(int num)
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 num-1. Passing in zero will unreserve all channels. Normally SDL_mixer starts without any channels reserved.
The following functions are affected by this setting:
4.3.3 Mix_PlayChannel
4.3.4 Mix_PlayChannelTimed
4.3.5 Mix_FadeInChannel
4.3.6 Mix_FadeInChannelTimed
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:
4.3.1 Mix_AllocateChannels
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_GroupChannel(int which, int tag)
Add which channel to group tag, or reset it's group to the default group tag (-1).
Returns: True(1) on success. False(0) is returned when the channel specified is invalid.
|
See Also:
4.4.3 Mix_GroupChannels,
4.3.1 Mix_AllocateChannels
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_GroupChannels(int from, int to, int tag)
Add channels starting at from up through to to group tag, or reset it's 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 didn't exist.
|
See Also:
4.4.2 Mix_GroupChannel,
4.3.1 Mix_AllocateChannels
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_GroupCount(int tag)
Count the number of channels in group tag.
Returns: The number of channels found in the group. This function never fails.
|
See Also:
4.4.2 Mix_GroupChannel,
4.4.3 Mix_GroupChannels
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_GroupAvailable(int tag)
Find the first available (not playing) channel in group tag.
Returns: The channel found on success. -1 is returned when no channels in the group are available.
|
See Also:
4.4.6 Mix_GroupOldest,
4.4.7 Mix_GroupNewer,
4.4.2 Mix_GroupChannel,
4.4.3 Mix_GroupChannels
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_GroupOldest(int tag)
Find the oldest 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:
4.4.7 Mix_GroupNewer,
4.4.5 Mix_GroupAvailable,
4.4.2 Mix_GroupChannel,
4.4.3 Mix_GroupChannels
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_GroupNewer(int tag)
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:
4.4.6 Mix_GroupOldest,
4.4.5 Mix_GroupAvailable,
4.4.2 Mix_GroupChannel,
4.4.3 Mix_GroupChannels
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_FadeOutGroup(int tag, int ms)
Mix_FadeOutChannel(-1)
for that instead.
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:
4.4.9 Mix_HaltGroup,
4.3.11 Mix_FadeOutChannel,
4.3.15 Mix_FadingChannel,
4.3.12 Mix_ChannelFinished
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_HaltGroup(int tag)
Mix_HaltChannel(-1)
for that instead.
Halt playback on all channels in group tag.
Any callback set by Mix_ChannelFinished
will be called once for each channel that stops.
Returns: always returns zero. (more silly than Mix_HaltChannel)
|
See Also:
4.4.8 Mix_FadeOutGroup,
4.3.9 Mix_HaltChannel,
4.3.12 Mix_ChannelFinished
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These functions work with music. Music is not played on a normal mixer channel. Music is therefore manipulated separately, except in post-processing hooks.
Load
Free
4.5.1 Mix_LoadMUS Load a music file into a Mix_Music
Playing
4.5.2 Mix_FreeMusic Free a Mix_Music
Settings
4.5.3 Mix_PlayMusic Play music, with looping 4.5.4 Mix_FadeInMusic Play music, with looping, and fade in 4.5.5 Mix_FadeInMusicPos Play music from a start point, with looping, and fade in 4.5.6 Mix_HookMusic Hook for a custom music player
Stopping
4.5.7 Mix_VolumeMusic Set music volume 4.5.8 Mix_PauseMusic Pause music 4.5.9 Mix_ResumeMusic Resume paused music 4.5.10 Mix_RewindMusic Rewind music to beginning 4.5.11 Mix_SetMusicPosition Set position of playback in stream 4.5.12 Mix_SetMusicCMD Use external program for music playback
Info
4.5.13 Mix_HaltMusic Stop music playback 4.5.14 Mix_FadeOutMusic Stop music, with fade out 4.5.15 Mix_HookMusicFinished Set a callback for when music stops
4.5.16 Mix_GetMusicType Get the music encoding type 4.5.17 Mix_PlayingMusic Test whether music is playing 4.5.18 Mix_PausedMusic Test whether music is paused 4.5.19 Mix_FadingMusic Get status of current music fade activity 4.5.20 Mix_GetMusicHookData Retrieve the Mix_HookMusic arg
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Mix_Music *Mix_LoadMUS(const char *file)
Load music file to use. This can load WAVE, MOD, MIDI, OGG, MP3, 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 don't 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:
5.2 Mix_Music,
4.5.12 Mix_SetMusicCMD,
4.5.3 Mix_PlayMusic,
4.5.4 Mix_FadeInMusic,
4.5.5 Mix_FadeInMusicPos
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
void Mix_FreeMusic(Mix_Music *music)
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.
|
See Also:
4.5.1 Mix_LoadMUS
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_PlayMusic(Mix_Music *music, int 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:
4.5.4 Mix_FadeInMusic
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_FadeInMusic(Mix_Music *music, int loops, int 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:
4.5.3 Mix_PlayMusic,
4.5.5 Mix_FadeInMusicPos
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position)
Mix_SetMusicPosition
for meaning.
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:
4.5.3 Mix_PlayMusic,
4.5.4 Mix_FadeInMusic,
4.5.11 Mix_SetMusicPosition
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
void Mix_HookMusic(void (*mix_func)(void *udata, Uint8 *stream, int len), void *arg) |
udata
parameter when it is called.
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:
4.5.12 Mix_SetMusicCMD,
4.5.20 Mix_GetMusicHookData
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_VolumeMusic(int volume)
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:
4.5.4 Mix_FadeInMusic,
4.5.14 Mix_FadeOutMusic,
4.5.12 Mix_SetMusicCMD
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
void Mix_PauseMusic()
Pause the music playback. You may halt paused music.
Note: Music can only be paused if it is actively playing.
|
See Also:
4.5.9 Mix_ResumeMusic,
4.5.18 Mix_PausedMusic,
4.5.13 Mix_HaltMusic
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
void Mix_ResumeMusic()
Unpause the music. This is safe to use on halted, paused, and already playing music.
|
See Also:
4.5.8 Mix_PauseMusic,
4.5.18 Mix_PausedMusic
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
void Mix_RewindMusic()
Rewind the music to the start. This is safe to use on halted, paused, and already playing music. It is not useful to rewind the music immediately after starting playback, because it starts at the beginning by default.
This function only works for these streams: MOD, OGG, MP3, Native MIDI.
|
See Also:
4.5.3 Mix_PlayMusic
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_SetMusicPosition(double position)
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.
Mix_RewindMusic
before this.Returns: 0 on success, or -1 if the codec doesn't support this function.
|
See Also:
4.5.5 Mix_FadeInMusicPos
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_SetMusicCMD(const char *command)
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 player's 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:
4.5.3 Mix_PlayMusic,
4.5.7 Mix_VolumeMusic
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_HaltMusic()
Halt playback of music. This interrupts music fader effects.
Any callback set by Mix_HookMusicFinished
will be called when the music stops.
Returns: always returns zero. (even more silly than Mix_HaltGroup)
|
See Also:
4.5.14 Mix_FadeOutMusic,
4.5.15 Mix_HookMusicFinished
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_FadeOutMusic(int ms)
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:
4.5.13 Mix_HaltMusic,
4.5.19 Mix_FadingMusic,
4.5.17 Mix_PlayingMusic,
4.5.15 Mix_HookMusicFinished
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
void Mix_HookMusicFinished(void (*music_finished)())
void function()
.
This sets up a function to be called when music playback is halted. Any time music stops, the music_finished function will be called. Call with NULL to remove the callback.
NOTE: NEVER call SDL_Mixer functions, nor SDL_LockAudio
, from a callback function.
|
See Also:
4.5.13 Mix_HaltMusic,
4.5.14 Mix_FadeOutMusic
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Mix_MusicType Mix_GetMusicType(const Mix_Music *music)
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:
5.3 Mix_MusicType,
4.6.7 Mix_SetPosition
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_PlayingMusic()
Tells you if music is actively playing, or not.
Note: Does not check if the channel has been paused.
Returns: Zero if the music is not playing, or 1 if it is playing.
|
See Also:
4.5.18 Mix_PausedMusic,
4.5.19 Mix_FadingMusic,
4.5.3 Mix_PlayMusic
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_PausedMusic()
Tells you if music is paused, or not.
Note: Does not check if the music was been halted after it was paused, which may seem a little weird.
Returns: Zero if music is not paused. 1 if it is paused.
|
See Also:
4.5.17 Mix_PlayingMusic,
4.5.8 Mix_PauseMusic,
4.5.9 Mix_ResumeMusic
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Mix_Fading Mix_FadingMusic()
Tells you if music is fading in, out, or not at all. Does not tell you if the channel is playing anything, or paused, so you'd need to test that separately.
Returns: the fading status. Never returns an error.
|
See Also:
5.4 Mix_Fading,
4.5.18 Mix_PausedMusic,
4.5.17 Mix_PlayingMusic,
4.5.5 Mix_FadeInMusicPos,
4.5.14 Mix_FadeOutMusic
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
void *Mix_GetMusicHookData()
Get the arg passed into Mix_HookMusic
.
Returns: the arg pointer.
|
See Also:
4.5.6 Mix_HookMusic
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
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.
Registration
Built-in Processors
4.6.1 Mix_RegisterEffect Hook a processor to a channel 4.6.2 Mix_UnregisterEffect Unhook a processor from a channel 4.6.3 Mix_UnregisterAllEffects Unhook all processors from a channel 4.6.4 Mix_SetPostMix Hook in a postmix processor
4.6.5 Mix_SetPanning Stereo panning 4.6.6 Mix_SetDistance Distance attenuation (volume) 4.6.7 Mix_SetPosition Panning(angular) and distance 4.6.8 Mix_SetReverseStereo Swap stereo left and right
The built-in processors: Mix_SetPanning, Mix_SetPosition, Mix_SetDistance, and
, 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.
Mix_SetReverseStereo
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_RegisterEffect(int chan, Mix_EffectFunc_t f, Mix_EffectDone_t d, void *arg) |
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.
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:
4.6.2 Mix_UnregisterEffect,
4.6.3 Mix_UnregisterAllEffects
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f)
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:
4.6.3 Mix_UnregisterAllEffects,
4.6.1 Mix_RegisterEffect
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_UnregisterAllEffects(int channel)
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:
4.6.2 Mix_UnregisterEffect,
4.6.1 Mix_RegisterEffect
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
void Mix_SetPostMix(void (*mix_func)(void *udata, Uint8 *stream, int len), void *arg) |
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.
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:
4.6.1 Mix_RegisterEffect
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_SetPanning(int channel, Uint8 left, Uint8 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 don't 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:
4.6.7 Mix_SetPosition,
4.6.3 Mix_UnregisterAllEffects
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_SetDistance(int channel, Uint8 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:
4.6.7 Mix_SetPosition,
4.6.3 Mix_UnregisterAllEffects
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_SetPosition(int channel, Sint16 angle, Uint8 distance)
angles % 360
.Mix_SetPanning
.
Mix_SetDistance
effect.
This effect emulates a simple 3D audio effect. It's not all that realistic, but it can help improve some level of realism. By giving it the angle and distance from the camera's 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:
4.6.5 Mix_SetPanning,
4.6.6 Mix_SetDistance,
4.6.3 Mix_UnregisterAllEffects
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
int Mix_SetReverseStereo(int channel, int flip)
Simple reverse stereo, swaps left and right channel sound.
NOTE: Using a flip 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:
4.6.3 Mix_UnregisterAllEffects
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
These types are defined and used by the SDL_mixer API.
5.1 Mix_Chunk The internal format for an audio chunk 5.2 Mix_Music The internal format for a music chunk 5.3 Mix_MusicType Music type enumerations 5.4 Mix_Fading Fader effect type enumerations 5.5 Mix_EffectFunc_t Special effect callback function pointer 5.6 Mix_EffectDone_t Special effect done callback function pointer
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
|
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:
4.2.5 Mix_VolumeChunk,
4.3.16 Mix_GetChunk,
4.2.1 Mix_LoadWAV,
4.2.2 Mix_LoadWAV_RW,
4.2.6 Mix_FreeChunk,
5.2 Mix_Music
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
|
This is an opaque data type used for Music data. This should always be used as a pointer. Who knows why it isn't a pointer in this typedef...
See Also:
4.5.1 Mix_LoadMUS,
4.5.2 Mix_FreeMusic,
5.1 Mix_Chunk
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
|
Return values from Mix_GetMusicType
are of these enumerated values.
If no music is playing then MUS_NONE is returned.
If music is playing via an external command then MUS_CMD is returned.
Otherwise they are self explanatory.
See Also:
4.5.16 Mix_GetMusicType
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
|
Return values from Mix_FadingMusic
and Mix_FadingChannel
are of these enumerated values.
If no fading is taking place on the queried channel or music, then MIX_NO_FADING is returned.
Otherwise they are self explanatory.
See Also:
4.3.15 Mix_FadingChannel,
4.5.19 Mix_FadingMusic
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
|
Mix_RegisterEffect
when registering this
effect processor function.
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:
4.6.1 Mix_RegisterEffect
4.6.2 Mix_UnregisterEffect
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
|
Mix_RegisterEffect
when registering this
effect processor function.
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:
4.6.1 Mix_RegisterEffect
4.6.2 Mix_UnregisterEffect
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
1
2
4
8
Mix_OpenAudio
.
22050
AUDIO_S16SYS
2
128
-2
"MIX_EFFECTSMAXSPEED"
Mix_OpenAudio
is called for the setting to take effect.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Jump to: | B L M R S |
---|
Jump to: | B L M R S |
---|
[Top] | [Contents] | [Index] | [ ? ] |
[Top] | [Contents] | [Index] | [ ? ] |
1. Overview
2. Getting Started
3. Conflicts
4. Functions
5. Types
6. Defines
7. Glossary
Index
[Top] | [Contents] | [Index] | [ ? ] |
Button | Name | Go to | From 1.2.3 go to |
---|---|---|---|
[ < ] | Back | previous section in reading order | 1.2.2 |
[ > ] | Forward | next section in reading order | 1.2.4 |
[ << ] | FastBack | previous or up-and-previous section | 1.1 |
[ Up ] | Up | up section | 1.2 |
[ >> ] | FastForward | next or up-and-next section | 1.3 |
[Top] | Top | cover (top) of document | |
[Contents] | Contents | table of contents | |
[Index] | Index | concept index | |
[ ? ] | About | this page |