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