Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. /*
  2.   SDL_mixer:  An audio mixer library based on the SDL library
  3.   Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
  4.  
  5.   This software is provided 'as-is', without any express or implied
  6.   warranty.  In no event will the authors be held liable for any damages
  7.   arising from the use of this software.
  8.  
  9.   Permission is granted to anyone to use this software for any purpose,
  10.   including commercial applications, and to alter it and redistribute it
  11.   freely, subject to the following restrictions:
  12.  
  13.   1. The origin of this software must not be misrepresented; you must not
  14.      claim that you wrote the original software. If you use this software
  15.      in a product, an acknowledgment in the product documentation would be
  16.      appreciated but is not required.
  17.   2. Altered source versions must be plainly marked as such, and must not be
  18.      misrepresented as being the original software.
  19.   3. This notice may not be removed or altered from any source distribution.
  20. */
  21.  
  22. /* $Id$ */
  23.  
  24. #ifndef _SDL_MIXER_H
  25. #define _SDL_MIXER_H
  26.  
  27. #include "SDL_types.h"
  28. #include "SDL_rwops.h"
  29. #include "SDL_audio.h"
  30. #include "SDL_endian.h"
  31. #include "SDL_version.h"
  32. #include "begin_code.h"
  33.  
  34. #define SDLCALL
  35. #define RW_SEEK_SET SEEK_SET
  36. #define SDL_free free
  37. #define SDL_malloc malloc
  38. #define SDL_realloc realloc
  39. #define SDL_calloc calloc
  40. #define SDL_abs abs
  41.  
  42. /* Set up for C function definitions, even when using C++ */
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46.  
  47. /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
  48. */
  49. #define SDL_MIXER_MAJOR_VERSION 1
  50. #define SDL_MIXER_MINOR_VERSION 2
  51. #define SDL_MIXER_PATCHLEVEL    12
  52.  
  53. /* This macro can be used to fill a version structure with the compile-time
  54.  * version of the SDL_mixer library.
  55.  */
  56. #define SDL_MIXER_VERSION(X)                                            \
  57. {                                                                       \
  58.         (X)->major = SDL_MIXER_MAJOR_VERSION;                           \
  59.         (X)->minor = SDL_MIXER_MINOR_VERSION;                           \
  60.         (X)->patch = SDL_MIXER_PATCHLEVEL;                              \
  61. }
  62.  
  63. /* Backwards compatibility */
  64. #define MIX_MAJOR_VERSION       SDL_MIXER_MAJOR_VERSION
  65. #define MIX_MINOR_VERSION       SDL_MIXER_MINOR_VERSION
  66. #define MIX_PATCHLEVEL          SDL_MIXER_PATCHLEVEL
  67. #define MIX_VERSION(X)          SDL_MIXER_VERSION(X)
  68.  
  69. /* This function gets the version of the dynamically linked SDL_mixer library.
  70.    it should NOT be used to fill a version structure, instead you should
  71.    use the SDL_MIXER_VERSION() macro.
  72.  */
  73. extern DECLSPEC const SDL_version * SDLCALL Mix_Linked_Version(void);
  74.  
  75. typedef enum
  76. {
  77.     MIX_INIT_FLAC        = 0x00000001,
  78.     MIX_INIT_MOD         = 0x00000002,
  79.     MIX_INIT_MP3         = 0x00000004,
  80.     MIX_INIT_OGG         = 0x00000008,
  81.     MIX_INIT_FLUIDSYNTH  = 0x00000010
  82. } MIX_InitFlags;
  83.  
  84. /* Loads dynamic libraries and prepares them for use.  Flags should be
  85.    one or more flags from MIX_InitFlags OR'd together.
  86.    It returns the flags successfully initialized, or 0 on failure.
  87.  */
  88. extern DECLSPEC int SDLCALL Mix_Init(int flags);
  89.  
  90. /* Unloads libraries loaded with Mix_Init */
  91. extern DECLSPEC void SDLCALL Mix_Quit(void);
  92.  
  93.  
  94. /* The default mixer has 8 simultaneous mixing channels */
  95. #ifndef MIX_CHANNELS
  96. #define MIX_CHANNELS    8
  97. #endif
  98.  
  99. /* Good default values for a PC soundcard */
  100. #define MIX_DEFAULT_FREQUENCY   22050
  101. #if SDL_BYTEORDER == SDL_LIL_ENDIAN
  102. #define MIX_DEFAULT_FORMAT      AUDIO_S16LSB
  103. #else
  104. #define MIX_DEFAULT_FORMAT      AUDIO_S16MSB
  105. #endif
  106. #define MIX_DEFAULT_CHANNELS    2
  107. #define MIX_MAX_VOLUME          128     /* Volume of a chunk */
  108.  
  109. /* The internal format for an audio chunk */
  110. typedef struct Mix_Chunk {
  111.         int allocated;
  112.         Uint8 *abuf;
  113.         Uint32 alen;
  114.         Uint8 volume;           /* Per-sample volume, 0-128 */
  115. } Mix_Chunk;
  116.  
  117. /* The different fading types supported */
  118. typedef enum {
  119.         MIX_NO_FADING,
  120.         MIX_FADING_OUT,
  121.         MIX_FADING_IN
  122. } Mix_Fading;
  123.  
  124. typedef enum {
  125.         MUS_NONE,
  126.         MUS_CMD,
  127.         MUS_WAV,
  128.         MUS_MOD,
  129.         MUS_MID,
  130.         MUS_OGG,
  131.         MUS_MP3,
  132.         MUS_MP3_MAD,
  133.         MUS_FLAC,
  134.         MUS_MODPLUG
  135. } Mix_MusicType;
  136.  
  137. /* The internal format for a music chunk interpreted via mikmod */
  138. typedef struct _Mix_Music Mix_Music;
  139.  
  140. /* Open the mixer with a certain audio format */
  141. extern DECLSPEC int SDLCALL Mix_OpenAudio(int frequency, Uint16 format, int channels,
  142.                                                         int chunksize);
  143.  
  144. /* Dynamically change the number of channels managed by the mixer.
  145.    If decreasing the number of channels, the upper channels are
  146.    stopped.
  147.    This function returns the new number of allocated channels.
  148.  */
  149. extern DECLSPEC int SDLCALL Mix_AllocateChannels(int numchans);
  150.  
  151. /* Find out what the actual audio device parameters are.
  152.    This function returns 1 if the audio has been opened, 0 otherwise.
  153.  */
  154. extern DECLSPEC int SDLCALL Mix_QuerySpec(int *frequency,Uint16 *format,int *channels);
  155.  
  156. /* Load a wave file or a music (.mod .s3m .it .xm) file */
  157. extern DECLSPEC Mix_Chunk * SDLCALL Mix_LoadWAV_RW(SDL_RWops *src, int freesrc);
  158. #define Mix_LoadWAV(file)       Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1)
  159. extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS(const char *file);
  160.  
  161. /* Load a music file from an SDL_RWop object (Ogg and MikMod specific currently)
  162.    Matt Campbell (matt@campbellhome.dhs.org) April 2000 */
  163. extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_RW(SDL_RWops *rw);
  164.  
  165. /* Load a music file from an SDL_RWop object assuming a specific format */
  166. extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUSType_RW(SDL_RWops *rw, Mix_MusicType type, int freesrc);
  167.  
  168. /* Load a wave file of the mixer format from a memory buffer */
  169. extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_WAV(Uint8 *mem);
  170.  
  171. /* Load raw audio data of the mixer format from a memory buffer */
  172. extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len);
  173.  
  174. /* Free an audio chunk previously loaded */
  175. extern DECLSPEC void SDLCALL Mix_FreeChunk(Mix_Chunk *chunk);
  176. extern DECLSPEC void SDLCALL Mix_FreeMusic(Mix_Music *music);
  177.  
  178. /* Get a list of chunk/music decoders that this build of SDL_mixer provides.
  179.    This list can change between builds AND runs of the program, if external
  180.    libraries that add functionality become available.
  181.    You must successfully call Mix_OpenAudio() before calling these functions.
  182.    This API is only available in SDL_mixer 1.2.9 and later.
  183.  
  184.    // usage...
  185.    int i;
  186.    const int total = Mix_GetNumChunkDecoders();
  187.    for (i = 0; i < total; i++)
  188.        printf("Supported chunk decoder: [%s]\n", Mix_GetChunkDecoder(i));
  189.  
  190.    Appearing in this list doesn't promise your specific audio file will
  191.    decode...but it's handy to know if you have, say, a functioning Timidity
  192.    install.
  193.  
  194.    These return values are static, read-only data; do not modify or free it.
  195.    The pointers remain valid until you call Mix_CloseAudio().
  196. */
  197. extern DECLSPEC int SDLCALL Mix_GetNumChunkDecoders(void);
  198. extern DECLSPEC const char * SDLCALL Mix_GetChunkDecoder(int index);
  199. extern DECLSPEC int SDLCALL Mix_GetNumMusicDecoders(void);
  200. extern DECLSPEC const char * SDLCALL Mix_GetMusicDecoder(int index);
  201.  
  202. /* Find out the music format of a mixer music, or the currently playing
  203.    music, if 'music' is NULL.
  204. */
  205. extern DECLSPEC Mix_MusicType SDLCALL Mix_GetMusicType(const Mix_Music *music);
  206.  
  207. /* Set a function that is called after all mixing is performed.
  208.    This can be used to provide real-time visual display of the audio stream
  209.    or add a custom mixer filter for the stream data.
  210. */
  211. extern DECLSPEC void SDLCALL Mix_SetPostMix(void (*mix_func)
  212.                              (void *udata, Uint8 *stream, int len), void *arg);
  213.  
  214. /* Add your own music player or additional mixer function.
  215.    If 'mix_func' is NULL, the default music player is re-enabled.
  216.  */
  217. extern DECLSPEC void SDLCALL Mix_HookMusic(void (*mix_func)
  218.                           (void *udata, Uint8 *stream, int len), void *arg);
  219.  
  220. /* Add your own callback when the music has finished playing.
  221.    This callback is only called if the music finishes naturally.
  222.  */
  223. extern DECLSPEC void SDLCALL Mix_HookMusicFinished(void (*music_finished)(void));
  224.  
  225. /* Get a pointer to the user data for the current music hook */
  226. extern DECLSPEC void * SDLCALL Mix_GetMusicHookData(void);
  227.  
  228. /*
  229.  * Add your own callback when a channel has finished playing. NULL
  230.  *  to disable callback. The callback may be called from the mixer's audio
  231.  *  callback or it could be called as a result of Mix_HaltChannel(), etc.
  232.  *  do not call SDL_LockAudio() from this callback; you will either be
  233.  *  inside the audio callback, or SDL_mixer will explicitly lock the audio
  234.  *  before calling your callback.
  235.  */
  236. extern DECLSPEC void SDLCALL Mix_ChannelFinished(void (*channel_finished)(int channel));
  237.  
  238.  
  239. /* Special Effects API by ryan c. gordon. (icculus@icculus.org) */
  240.  
  241. #define MIX_CHANNEL_POST  -2
  242.  
  243. /* This is the format of a special effect callback:
  244.  *
  245.  *   myeffect(int chan, void *stream, int len, void *udata);
  246.  *
  247.  * (chan) is the channel number that your effect is affecting. (stream) is
  248.  *  the buffer of data to work upon. (len) is the size of (stream), and
  249.  *  (udata) is a user-defined bit of data, which you pass as the last arg of
  250.  *  Mix_RegisterEffect(), and is passed back unmolested to your callback.
  251.  *  Your effect changes the contents of (stream) based on whatever parameters
  252.  *  are significant, or just leaves it be, if you prefer. You can do whatever
  253.  *  you like to the buffer, though, and it will continue in its changed state
  254.  *  down the mixing pipeline, through any other effect functions, then finally
  255.  *  to be mixed with the rest of the channels and music for the final output
  256.  *  stream.
  257.  *
  258.  * DO NOT EVER call SDL_LockAudio() from your callback function!
  259.  */
  260. typedef void (*Mix_EffectFunc_t)(int chan, void *stream, int len, void *udata);
  261.  
  262. /*
  263.  * This is a callback that signifies that a channel has finished all its
  264.  *  loops and has completed playback. This gets called if the buffer
  265.  *  plays out normally, or if you call Mix_HaltChannel(), implicitly stop
  266.  *  a channel via Mix_AllocateChannels(), or unregister a callback while
  267.  *  it's still playing.
  268.  *
  269.  * DO NOT EVER call SDL_LockAudio() from your callback function!
  270.  */
  271. typedef void (*Mix_EffectDone_t)(int chan, void *udata);
  272.  
  273.  
  274. /* Register a special effect function. At mixing time, the channel data is
  275.  *  copied into a buffer and passed through each registered effect function.
  276.  *  After it passes through all the functions, it is mixed into the final
  277.  *  output stream. The copy to buffer is performed once, then each effect
  278.  *  function performs on the output of the previous effect. Understand that
  279.  *  this extra copy to a buffer is not performed if there are no effects
  280.  *  registered for a given chunk, which saves CPU cycles, and any given
  281.  *  effect will be extra cycles, too, so it is crucial that your code run
  282.  *  fast. Also note that the data that your function is given is in the
  283.  *  format of the sound device, and not the format you gave to Mix_OpenAudio(),
  284.  *  although they may in reality be the same. This is an unfortunate but
  285.  *  necessary speed concern. Use Mix_QuerySpec() to determine if you can
  286.  *  handle the data before you register your effect, and take appropriate
  287.  *  actions.
  288.  * You may also specify a callback (Mix_EffectDone_t) that is called when
  289.  *  the channel finishes playing. This gives you a more fine-grained control
  290.  *  than Mix_ChannelFinished(), in case you need to free effect-specific
  291.  *  resources, etc. If you don't need this, you can specify NULL.
  292.  * You may set the callbacks before or after calling Mix_PlayChannel().
  293.  * Things like Mix_SetPanning() are just internal special effect functions,
  294.  *  so if you are using that, you've already incurred the overhead of a copy
  295.  *  to a separate buffer, and that these effects will be in the queue with
  296.  *  any functions you've registered. The list of registered effects for a
  297.  *  channel is reset when a chunk finishes playing, so you need to explicitly
  298.  *  set them with each call to Mix_PlayChannel*().
  299.  * You may also register a special effect function that is to be run after
  300.  *  final mixing occurs. The rules for these callbacks are identical to those
  301.  *  in Mix_RegisterEffect, but they are run after all the channels and the
  302.  *  music have been mixed into a single stream, whereas channel-specific
  303.  *  effects run on a given channel before any other mixing occurs. These
  304.  *  global effect callbacks are call "posteffects". Posteffects only have
  305.  *  their Mix_EffectDone_t function called when they are unregistered (since
  306.  *  the main output stream is never "done" in the same sense as a channel).
  307.  *  You must unregister them manually when you've had enough. Your callback
  308.  *  will be told that the channel being mixed is (MIX_CHANNEL_POST) if the
  309.  *  processing is considered a posteffect.
  310.  *
  311.  * After all these effects have finished processing, the callback registered
  312.  *  through Mix_SetPostMix() runs, and then the stream goes to the audio
  313.  *  device.
  314.  *
  315.  * DO NOT EVER call SDL_LockAudio() from your callback function!
  316.  *
  317.  * returns zero if error (no such channel), nonzero if added.
  318.  *  Error messages can be retrieved from Mix_GetError().
  319.  */
  320. extern DECLSPEC int SDLCALL Mix_RegisterEffect(int chan, Mix_EffectFunc_t f,
  321.                                         Mix_EffectDone_t d, void *arg);
  322.  
  323.  
  324. /* You may not need to call this explicitly, unless you need to stop an
  325.  *  effect from processing in the middle of a chunk's playback.
  326.  * Posteffects are never implicitly unregistered as they are for channels,
  327.  *  but they may be explicitly unregistered through this function by
  328.  *  specifying MIX_CHANNEL_POST for a channel.
  329.  * returns zero if error (no such channel or effect), nonzero if removed.
  330.  *  Error messages can be retrieved from Mix_GetError().
  331.  */
  332. extern DECLSPEC int SDLCALL Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f);
  333.  
  334.  
  335. /* You may not need to call this explicitly, unless you need to stop all
  336.  *  effects from processing in the middle of a chunk's playback. Note that
  337.  *  this will also shut off some internal effect processing, since
  338.  *  Mix_SetPanning() and others may use this API under the hood. This is
  339.  *  called internally when a channel completes playback.
  340.  * Posteffects are never implicitly unregistered as they are for channels,
  341.  *  but they may be explicitly unregistered through this function by
  342.  *  specifying MIX_CHANNEL_POST for a channel.
  343.  * returns zero if error (no such channel), nonzero if all effects removed.
  344.  *  Error messages can be retrieved from Mix_GetError().
  345.  */
  346. extern DECLSPEC int SDLCALL Mix_UnregisterAllEffects(int channel);
  347.  
  348.  
  349. #define MIX_EFFECTSMAXSPEED  "MIX_EFFECTSMAXSPEED"
  350.  
  351. /*
  352.  * These are the internally-defined mixing effects. They use the same API that
  353.  *  effects defined in the application use, but are provided here as a
  354.  *  convenience. Some effects can reduce their quality or use more memory in
  355.  *  the name of speed; to enable this, make sure the environment variable
  356.  *  MIX_EFFECTSMAXSPEED (see above) is defined before you call
  357.  *  Mix_OpenAudio().
  358.  */
  359.  
  360.  
  361. /* Set the panning of a channel. The left and right channels are specified
  362.  *  as integers between 0 and 255, quietest to loudest, respectively.
  363.  *
  364.  * Technically, this is just individual volume control for a sample with
  365.  *  two (stereo) channels, so it can be used for more than just panning.
  366.  *  If you want real panning, call it like this:
  367.  *
  368.  *   Mix_SetPanning(channel, left, 255 - left);
  369.  *
  370.  * ...which isn't so hard.
  371.  *
  372.  * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
  373.  *  the panning will be done to the final mixed stream before passing it on
  374.  *  to the audio device.
  375.  *
  376.  * This uses the Mix_RegisterEffect() API internally, and returns without
  377.  *  registering the effect function if the audio device is not configured
  378.  *  for stereo output. Setting both (left) and (right) to 255 causes this
  379.  *  effect to be unregistered, since that is the data's normal state.
  380.  *
  381.  * returns zero if error (no such channel or Mix_RegisterEffect() fails),
  382.  *  nonzero if panning effect enabled. Note that an audio device in mono
  383.  *  mode is a no-op, but this call will return successful in that case.
  384.  *  Error messages can be retrieved from Mix_GetError().
  385.  */
  386. extern DECLSPEC int SDLCALL Mix_SetPanning(int channel, Uint8 left, Uint8 right);
  387.  
  388.  
  389. /* Set the position of a channel. (angle) is an integer from 0 to 360, that
  390.  *  specifies the location of the sound in relation to the listener. (angle)
  391.  *  will be reduced as neccesary (540 becomes 180 degrees, -100 becomes 260).
  392.  *  Angle 0 is due north, and rotates clockwise as the value increases.
  393.  *  For efficiency, the precision of this effect may be limited (angles 1
  394.  *  through 7 might all produce the same effect, 8 through 15 are equal, etc).
  395.  *  (distance) is an integer between 0 and 255 that specifies the space
  396.  *  between the sound and the listener. The larger the number, the further
  397.  *  away the sound is. Using 255 does not guarantee that the channel will be
  398.  *  culled from the mixing process or be completely silent. For efficiency,
  399.  *  the precision of this effect may be limited (distance 0 through 5 might
  400.  *  all produce the same effect, 6 through 10 are equal, etc). Setting (angle)
  401.  *  and (distance) to 0 unregisters this effect, since the data would be
  402.  *  unchanged.
  403.  *
  404.  * If you need more precise positional audio, consider using OpenAL for
  405.  *  spatialized effects instead of SDL_mixer. This is only meant to be a
  406.  *  basic effect for simple "3D" games.
  407.  *
  408.  * If the audio device is configured for mono output, then you won't get
  409.  *  any effectiveness from the angle; however, distance attenuation on the
  410.  *  channel will still occur. While this effect will function with stereo
  411.  *  voices, it makes more sense to use voices with only one channel of sound,
  412.  *  so when they are mixed through this effect, the positioning will sound
  413.  *  correct. You can convert them to mono through SDL before giving them to
  414.  *  the mixer in the first place if you like.
  415.  *
  416.  * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
  417.  *  the positioning will be done to the final mixed stream before passing it
  418.  *  on to the audio device.
  419.  *
  420.  * This is a convenience wrapper over Mix_SetDistance() and Mix_SetPanning().
  421.  *
  422.  * returns zero if error (no such channel or Mix_RegisterEffect() fails),
  423.  *  nonzero if position effect is enabled.
  424.  *  Error messages can be retrieved from Mix_GetError().
  425.  */
  426. extern DECLSPEC int SDLCALL Mix_SetPosition(int channel, Sint16 angle, Uint8 distance);
  427.  
  428.  
  429. /* Set the "distance" of a channel. (distance) is an integer from 0 to 255
  430.  *  that specifies the location of the sound in relation to the listener.
  431.  *  Distance 0 is overlapping the listener, and 255 is as far away as possible
  432.  *  A distance of 255 does not guarantee silence; in such a case, you might
  433.  *  want to try changing the chunk's volume, or just cull the sample from the
  434.  *  mixing process with Mix_HaltChannel().
  435.  * For efficiency, the precision of this effect may be limited (distances 1
  436.  *  through 7 might all produce the same effect, 8 through 15 are equal, etc).
  437.  *  (distance) is an integer between 0 and 255 that specifies the space
  438.  *  between the sound and the listener. The larger the number, the further
  439.  *  away the sound is.
  440.  * Setting (distance) to 0 unregisters this effect, since the data would be
  441.  *  unchanged.
  442.  * If you need more precise positional audio, consider using OpenAL for
  443.  *  spatialized effects instead of SDL_mixer. This is only meant to be a
  444.  *  basic effect for simple "3D" games.
  445.  *
  446.  * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
  447.  *  the distance attenuation will be done to the final mixed stream before
  448.  *  passing it on to the audio device.
  449.  *
  450.  * This uses the Mix_RegisterEffect() API internally.
  451.  *
  452.  * returns zero if error (no such channel or Mix_RegisterEffect() fails),
  453.  *  nonzero if position effect is enabled.
  454.  *  Error messages can be retrieved from Mix_GetError().
  455.  */
  456. extern DECLSPEC int SDLCALL Mix_SetDistance(int channel, Uint8 distance);
  457.  
  458.  
  459. /*
  460.  * !!! FIXME : Haven't implemented, since the effect goes past the
  461.  *              end of the sound buffer. Will have to think about this.
  462.  *               --ryan.
  463.  */
  464. #if 0
  465. /* Causes an echo effect to be mixed into a sound. (echo) is the amount
  466.  *  of echo to mix. 0 is no echo, 255 is infinite (and probably not
  467.  *  what you want).
  468.  *
  469.  * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
  470.  *  the reverbing will be done to the final mixed stream before passing it on
  471.  *  to the audio device.
  472.  *
  473.  * This uses the Mix_RegisterEffect() API internally. If you specify an echo
  474.  *  of zero, the effect is unregistered, as the data is already in that state.
  475.  *
  476.  * returns zero if error (no such channel or Mix_RegisterEffect() fails),
  477.  *  nonzero if reversing effect is enabled.
  478.  *  Error messages can be retrieved from Mix_GetError().
  479.  */
  480. extern no_parse_DECLSPEC int SDLCALL Mix_SetReverb(int channel, Uint8 echo);
  481. #endif
  482.  
  483. /* Causes a channel to reverse its stereo. This is handy if the user has his
  484.  *  speakers hooked up backwards, or you would like to have a minor bit of
  485.  *  psychedelia in your sound code.  :)  Calling this function with (flip)
  486.  *  set to non-zero reverses the chunks's usual channels. If (flip) is zero,
  487.  *  the effect is unregistered.
  488.  *
  489.  * This uses the Mix_RegisterEffect() API internally, and thus is probably
  490.  *  more CPU intensive than having the user just plug in his speakers
  491.  *  correctly. Mix_SetReverseStereo() returns without registering the effect
  492.  *  function if the audio device is not configured for stereo output.
  493.  *
  494.  * If you specify MIX_CHANNEL_POST for (channel), then this the effect is used
  495.  *  on the final mixed stream before sending it on to the audio device (a
  496.  *  posteffect).
  497.  *
  498.  * returns zero if error (no such channel or Mix_RegisterEffect() fails),
  499.  *  nonzero if reversing effect is enabled. Note that an audio device in mono
  500.  *  mode is a no-op, but this call will return successful in that case.
  501.  *  Error messages can be retrieved from Mix_GetError().
  502.  */
  503. extern DECLSPEC int SDLCALL Mix_SetReverseStereo(int channel, int flip);
  504.  
  505. /* end of effects API. --ryan. */
  506.  
  507.  
  508. /* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate
  509.    them dynamically to the next sample if requested with a -1 value below.
  510.    Returns the number of reserved channels.
  511.  */
  512. extern DECLSPEC int SDLCALL Mix_ReserveChannels(int num);
  513.  
  514. /* Channel grouping functions */
  515.  
  516. /* Attach a tag to a channel. A tag can be assigned to several mixer
  517.    channels, to form groups of channels.
  518.    If 'tag' is -1, the tag is removed (actually -1 is the tag used to
  519.    represent the group of all the channels).
  520.    Returns true if everything was OK.
  521.  */
  522. extern DECLSPEC int SDLCALL Mix_GroupChannel(int which, int tag);
  523. /* Assign several consecutive channels to a group */
  524. extern DECLSPEC int SDLCALL Mix_GroupChannels(int from, int to, int tag);
  525. /* Finds the first available channel in a group of channels,
  526.    returning -1 if none are available.
  527.  */
  528. extern DECLSPEC int SDLCALL Mix_GroupAvailable(int tag);
  529. /* Returns the number of channels in a group. This is also a subtle
  530.    way to get the total number of channels when 'tag' is -1
  531.  */
  532. extern DECLSPEC int SDLCALL Mix_GroupCount(int tag);
  533. /* Finds the "oldest" sample playing in a group of channels */
  534. extern DECLSPEC int SDLCALL Mix_GroupOldest(int tag);
  535. /* Finds the "most recent" (i.e. last) sample playing in a group of channels */
  536. extern DECLSPEC int SDLCALL Mix_GroupNewer(int tag);
  537.  
  538. /* Play an audio chunk on a specific channel.
  539.    If the specified channel is -1, play on the first free channel.
  540.    If 'loops' is greater than zero, loop the sound that many times.
  541.    If 'loops' is -1, loop inifinitely (~65000 times).
  542.    Returns which channel was used to play the sound.
  543. */
  544. #define Mix_PlayChannel(channel,chunk,loops) Mix_PlayChannelTimed(channel,chunk,loops,-1)
  545. /* The same as above, but the sound is played at most 'ticks' milliseconds */
  546. extern DECLSPEC int SDLCALL Mix_PlayChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ticks);
  547. extern DECLSPEC int SDLCALL Mix_PlayMusic(Mix_Music *music, int loops);
  548.  
  549. /* Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions */
  550. extern DECLSPEC int SDLCALL Mix_FadeInMusic(Mix_Music *music, int loops, int ms);
  551. extern DECLSPEC int SDLCALL Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position);
  552. #define Mix_FadeInChannel(channel,chunk,loops,ms) Mix_FadeInChannelTimed(channel,chunk,loops,ms,-1)
  553. extern DECLSPEC int SDLCALL Mix_FadeInChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ms, int ticks);
  554.  
  555. /* Set the volume in the range of 0-128 of a specific channel or chunk.
  556.    If the specified channel is -1, set volume for all channels.
  557.    Returns the original volume.
  558.    If the specified volume is -1, just return the current volume.
  559. */
  560. extern DECLSPEC int SDLCALL Mix_Volume(int channel, int volume);
  561. extern DECLSPEC int SDLCALL Mix_VolumeChunk(Mix_Chunk *chunk, int volume);
  562. extern DECLSPEC int SDLCALL Mix_VolumeMusic(int volume);
  563.  
  564. /* Halt playing of a particular channel */
  565. extern DECLSPEC int SDLCALL Mix_HaltChannel(int channel);
  566. extern DECLSPEC int SDLCALL Mix_HaltGroup(int tag);
  567. extern DECLSPEC int SDLCALL Mix_HaltMusic(void);
  568.  
  569. /* Change the expiration delay for a particular channel.
  570.    The sample will stop playing after the 'ticks' milliseconds have elapsed,
  571.    or remove the expiration if 'ticks' is -1
  572. */
  573. extern DECLSPEC int SDLCALL Mix_ExpireChannel(int channel, int ticks);
  574.  
  575. /* Halt a channel, fading it out progressively till it's silent
  576.    The ms parameter indicates the number of milliseconds the fading
  577.    will take.
  578.  */
  579. extern DECLSPEC int SDLCALL Mix_FadeOutChannel(int which, int ms);
  580. extern DECLSPEC int SDLCALL Mix_FadeOutGroup(int tag, int ms);
  581. extern DECLSPEC int SDLCALL Mix_FadeOutMusic(int ms);
  582.  
  583. /* Query the fading status of a channel */
  584. extern DECLSPEC Mix_Fading SDLCALL Mix_FadingMusic(void);
  585. extern DECLSPEC Mix_Fading SDLCALL Mix_FadingChannel(int which);
  586.  
  587. /* Pause/Resume a particular channel */
  588. extern DECLSPEC void SDLCALL Mix_Pause(int channel);
  589. extern DECLSPEC void SDLCALL Mix_Resume(int channel);
  590. extern DECLSPEC int SDLCALL Mix_Paused(int channel);
  591.  
  592. /* Pause/Resume the music stream */
  593. extern DECLSPEC void SDLCALL Mix_PauseMusic(void);
  594. extern DECLSPEC void SDLCALL Mix_ResumeMusic(void);
  595. extern DECLSPEC void SDLCALL Mix_RewindMusic(void);
  596. extern DECLSPEC int SDLCALL Mix_PausedMusic(void);
  597.  
  598. /* Set the current position in the music stream.
  599.    This returns 0 if successful, or -1 if it failed or isn't implemented.
  600.    This function is only implemented for MOD music formats (set pattern
  601.    order number) and for OGG, FLAC, MP3_MAD, and MODPLUG music (set
  602.    position in seconds), at the moment.
  603. */
  604. extern DECLSPEC int SDLCALL Mix_SetMusicPosition(double position);
  605.  
  606. /* Check the status of a specific channel.
  607.    If the specified channel is -1, check all channels.
  608. */
  609. extern DECLSPEC int SDLCALL Mix_Playing(int channel);
  610. extern DECLSPEC int SDLCALL Mix_PlayingMusic(void);
  611.  
  612. /* Stop music and set external music playback command */
  613. extern DECLSPEC int SDLCALL Mix_SetMusicCMD(const char *command);
  614.  
  615. /* Synchro value is set by MikMod from modules while playing */
  616. extern DECLSPEC int SDLCALL Mix_SetSynchroValue(int value);
  617. extern DECLSPEC int SDLCALL Mix_GetSynchroValue(void);
  618.  
  619. /* Set/Get/Iterate SoundFonts paths to use by supported MIDI backends */
  620. extern DECLSPEC int SDLCALL Mix_SetSoundFonts(const char *paths);
  621. extern DECLSPEC const char* SDLCALL Mix_GetSoundFonts(void);
  622. extern DECLSPEC int SDLCALL Mix_EachSoundFont(int (*function)(const char*, void*), void *data);
  623.  
  624. /* Get the Mix_Chunk currently associated with a mixer channel
  625.     Returns NULL if it's an invalid channel, or there's no chunk associated.
  626. */
  627. extern DECLSPEC Mix_Chunk * SDLCALL Mix_GetChunk(int channel);
  628.  
  629. /* Close the mixer, halting all playing audio */
  630. extern DECLSPEC void SDLCALL Mix_CloseAudio(void);
  631.  
  632. /* We'll use SDL for reporting errors */
  633. #define Mix_SetError    SDL_SetError
  634. #define Mix_GetError    SDL_GetError
  635.  
  636. /* Ends C function definitions when using C++ */
  637. #ifdef __cplusplus
  638. }
  639. #endif
  640. #include "close_code.h"
  641.  
  642. #endif /* _SDL_MIXER_H */
  643.