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