Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

652 рядки
28 KiB

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