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