SDL_mixer_ext.h 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867
  1. /*
  2. SDL Mixer X: An extended audio mixer library, forked from SDL_mixer
  3. Copyright (C) 2014-2018 Vitaly Novichkov <[email protected]>
  4. SDL_mixer: An audio mixer library based on the SDL library
  5. Copyright (C) 1997-2018 Sam Lantinga <[email protected]>
  6. This software is provided 'as-is', without any express or implied
  7. warranty. In no event will the authors be held liable for any damages
  8. arising from the use of this software.
  9. Permission is granted to anyone to use this software for any purpose,
  10. including commercial applications, and to alter it and redistribute it
  11. freely, subject to the following restrictions:
  12. 1. The origin of this software must not be misrepresented; you must not
  13. claim that you wrote the original software. If you use this software
  14. in a product, an acknowledgment in the product documentation would be
  15. appreciated but is not required.
  16. 2. Altered source versions must be plainly marked as such, and must not be
  17. misrepresented as being the original software.
  18. 3. This notice may not be removed or altered from any source distribution.
  19. */
  20. #ifndef SDL_MIXER_H_
  21. #define SDL_MIXER_H_
  22. #include "SDL_stdinc.h"
  23. #include "SDL_rwops.h"
  24. #include "SDL_audio.h"
  25. #include "SDL_endian.h"
  26. #include "SDL_version.h"
  27. #include "begin_code.h"
  28. /* Let applications recogonize which SDL Mixer edition is in use: Official or Extended fork by Wohlstand */
  29. #define SDL_MIXER_X 1
  30. #define MIXSDLCALL
  31. #if defined(FORCE_STDCALLS) && defined(_WIN32)
  32. #ifdef SDLCALL
  33. #undef SDLCALL
  34. #endif
  35. #define SDLCALL __stdcall
  36. #define SDLCALLCC __stdcall
  37. #else
  38. #define SDLCALLCC
  39. #endif
  40. #ifndef DEPRECATED
  41. #ifdef __GNUC__
  42. #define DEPRECATED(func) func __attribute__ ((deprecated))
  43. #elif defined(_MSC_VER)
  44. #define DEPRECATED(func) __declspec(deprecated) func
  45. #else
  46. #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
  47. #define DEPRECATED(func) func
  48. #endif
  49. #endif
  50. /* Set up for C function definitions, even when using C++ */
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54. /* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
  55. */
  56. #define SDL_MIXER_MAJOR_VERSION 2
  57. #define SDL_MIXER_MINOR_VERSION 2
  58. #define SDL_MIXER_PATCHLEVEL 0
  59. /* This macro can be used to fill a version structure with the compile-time
  60. * version of the SDL_mixer library.
  61. */
  62. #define SDL_MIXER_VERSION(X) \
  63. { \
  64. (X)->major = SDL_MIXER_MAJOR_VERSION; \
  65. (X)->minor = SDL_MIXER_MINOR_VERSION; \
  66. (X)->patch = SDL_MIXER_PATCHLEVEL; \
  67. }
  68. /* Backwards compatibility */
  69. #define MIX_MAJOR_VERSION SDL_MIXER_MAJOR_VERSION
  70. #define MIX_MINOR_VERSION SDL_MIXER_MINOR_VERSION
  71. #define MIX_PATCHLEVEL SDL_MIXER_PATCHLEVEL
  72. #define MIX_VERSION(X) SDL_MIXER_VERSION(X)
  73. /**
  74. * This is the version number macro for the current SDL_mixer version.
  75. */
  76. #define SDL_MIXER_COMPILEDVERSION \
  77. SDL_VERSIONNUM(SDL_MIXER_MAJOR_VERSION, SDL_MIXER_MINOR_VERSION, SDL_MIXER_PATCHLEVEL)
  78. /**
  79. * This macro will evaluate to true if compiled with SDL_mixer at least X.Y.Z.
  80. */
  81. #define SDL_MIXER_VERSION_ATLEAST(X, Y, Z) \
  82. (SDL_MIXER_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
  83. /* This function gets the version of the dynamically linked SDL_mixer library.
  84. it should NOT be used to fill a version structure, instead you should
  85. use the SDL_MIXER_VERSION() macro.
  86. */
  87. extern DECLSPEC const SDL_version * SDLCALL Mix_Linked_Version(void);
  88. typedef enum
  89. {
  90. MIX_INIT_FLAC = 0x00000001,
  91. MIX_INIT_MOD = 0x00000002,
  92. MIX_INIT_MP3 = 0x00000008,
  93. MIX_INIT_OGG = 0x00000010,
  94. MIX_INIT_MID = 0x00000020,
  95. MIX_INIT_OPUS = 0x00000040
  96. } MIX_InitFlags;
  97. /* Loads dynamic libraries and prepares them for use. Flags should be
  98. one or more flags from MIX_InitFlags OR'd together.
  99. It returns the flags successfully initialized, or 0 on failure.
  100. */
  101. extern DECLSPEC int SDLCALL Mix_Init(int flags);
  102. /* Unloads libraries loaded with Mix_Init */
  103. extern DECLSPEC void SDLCALL Mix_Quit(void);
  104. /* The default mixer has 8 simultaneous mixing channels */
  105. #ifndef MIX_CHANNELS
  106. #define MIX_CHANNELS 8
  107. #endif
  108. /* Good default values for a PC soundcard */
  109. #define MIX_DEFAULT_FREQUENCY 44100
  110. #if SDL_BYTEORDER == SDL_LIL_ENDIAN
  111. #define MIX_DEFAULT_FORMAT AUDIO_S16LSB
  112. #else
  113. #define MIX_DEFAULT_FORMAT AUDIO_S16MSB
  114. #endif
  115. #define MIX_DEFAULT_CHANNELS 2
  116. #define MIX_MAX_VOLUME SDL_MIX_MAXVOLUME /* Volume of a chunk */
  117. /* The internal format for an audio chunk */
  118. typedef struct Mix_Chunk {
  119. int allocated;
  120. Uint8 *abuf;
  121. Uint32 alen;
  122. Uint8 volume; /* Per-sample volume, 0-128 */
  123. } Mix_Chunk;
  124. /* The different fading types supported */
  125. typedef enum {
  126. MIX_NO_FADING,
  127. MIX_FADING_OUT,
  128. MIX_FADING_IN
  129. } Mix_Fading;
  130. /* These are types of music files (not libraries used to load them) */
  131. typedef enum {
  132. MUS_NONE,
  133. MUS_CMD,
  134. MUS_WAV,
  135. MUS_MOD,
  136. MUS_MID,
  137. MUS_OGG,
  138. MUS_MP3,
  139. MUS_MP3_MAD_UNUSED,
  140. MUS_FLAC,
  141. MUS_MODPLUG_UNUSED,
  142. MUS_OPUS,
  143. MUS_GME,
  144. MUS_ADLMIDI/*Use ADLMIDI coded for super-special formats like IMF, MUS or XMI are can't be played without ADLMIDI*/
  145. } Mix_MusicType;
  146. typedef enum {
  147. MIDI_ADLMIDI,
  148. MIDI_Native,
  149. MIDI_Timidity,
  150. MIDI_OPNMIDI,
  151. MIDI_Fluidsynth,
  152. MIDI_ANY,
  153. MIDI_KnuwnDevices /* Count of MIDI device types */
  154. } Mix_MIDI_Device;
  155. /* Volume model type in the ADLMIDI */
  156. typedef enum {
  157. ADLMIDI_VM_AUTO,
  158. ADLMIDI_VM_GENERIC,
  159. ADLMIDI_VM_CMF,
  160. ADLMIDI_VM_DMX,
  161. ADLMIDI_VM_APOGEE,
  162. ADLMIDI_VM_9X
  163. } Mix_ADLMIDI_VolumeModel;
  164. /* OPL3 chip emulators for ADLMIDI */
  165. typedef enum {
  166. ADLMIDI_OPL3_EMU_DEFAULT = -1,
  167. ADLMIDI_OPL3_EMU_NUKED = 0,
  168. ADLMIDI_OPL3_EMU_NUKED_1_7_4,
  169. ADLMIDI_OPL3_EMU_DOSBOX,
  170. } Mix_ADLMIDI_Emulator;
  171. /* OPN2 chip emulators for OPNMIDI */
  172. typedef enum {
  173. OPNMIDI_OPN2_EMU_DEFAULT = -1,
  174. OPNMIDI_OPN2_EMU_MIME = 0,
  175. OPNMIDI_OPN2_EMU_NUKED,
  176. OPNMIDI_OPN2_EMU_GENS,
  177. } Mix_OPNMIDI_Emulator;
  178. /* The internal format for a music chunk interpreted via mikmod */
  179. typedef struct _Mix_Music Mix_Music;
  180. /* Open the mixer with a certain audio format */
  181. extern DECLSPEC int SDLCALL Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize);
  182. /* Open the mixer with specific device and certain audio format */
  183. extern DECLSPEC int SDLCALL Mix_OpenAudioDevice(int frequency, Uint16 format, int channels, int chunksize, const char* device, int allowed_changes);
  184. /* Dynamically change the number of channels managed by the mixer.
  185. If decreasing the number of channels, the upper channels are
  186. stopped.
  187. This function returns the new number of allocated channels.
  188. */
  189. extern DECLSPEC int SDLCALL Mix_AllocateChannels(int numchans);
  190. /* Find out what the actual audio device parameters are.
  191. This function returns 1 if the audio has been opened, 0 otherwise.
  192. */
  193. extern DECLSPEC int SDLCALL Mix_QuerySpec(int *frequency,Uint16 *format,int *channels);
  194. /* Load a wave file or a music (.mod .s3m .it .xm) file
  195. IMPORTANT: To choice a track number of NSF, GBM, HES, etc file,
  196. you must append "|xxx" to end of file path for
  197. Mix_LoadMUS function.
  198. Where xxx - actual number of chip track, (from 0 to N-1)
  199. Examples: "file.nsf|12", "file.hes|2"
  200. */
  201. extern DECLSPEC Mix_Chunk * SDLCALL Mix_LoadWAV_RW(SDL_RWops *src, int freesrc);
  202. #define Mix_LoadWAV(file) Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1)
  203. extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS(const char *file);
  204. /* Load a music file from an SDL_RWop object
  205. * Matt Campbell ([email protected]) April 2000 */
  206. extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUS_RW(SDL_RWops *src, int freesrc);
  207. /* Load a music file from an SDL_RWop object with custom arguments (trackID for GME or settings for a MIDI playing)
  208. * Arguments are taking no effect for file formats which are not supports extra arguments.
  209. */
  210. extern DECLSPEC Mix_Music *SDLCALL Mix_LoadMUS_RW_ARG(SDL_RWops *src, int freesrc, const char *args);
  211. /* Load a music file from an SDL_RWop object with custom trackID for GME.
  212. * trackID argument takes no effect for non-NSF,HES,GBM,etc. file formats.
  213. * Default value should be 0
  214. */
  215. extern DECLSPEC Mix_Music *SDLCALL Mix_LoadMUS_RW_GME(SDL_RWops *src, int freesrc, int trackID);
  216. /* Load a music file from an SDL_RWop object assuming a specific format */
  217. extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUSType_RW(SDL_RWops *src, Mix_MusicType type, int freesrc);
  218. /* Load a music file from an SDL_RWop object assuming a specific format
  219. with custom arguments (trackID for GME or settings for a MIDI playing) */
  220. extern DECLSPEC Mix_Music * SDLCALL Mix_LoadMUSType_RW_ARG(SDL_RWops *src, Mix_MusicType type, int freesrc, const char *args);
  221. /* Load a wave file of the mixer format from a memory buffer */
  222. extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_WAV(Uint8 *mem);
  223. /* Load raw audio data of the mixer format from a memory buffer */
  224. extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len);
  225. /* Free an audio chunk previously loaded */
  226. extern DECLSPEC void SDLCALL Mix_FreeChunk(Mix_Chunk *chunk);
  227. extern DECLSPEC void SDLCALL Mix_FreeMusic(Mix_Music *music);
  228. /* Get a list of chunk/music decoders that this build of SDL_mixer provides.
  229. This list can change between builds AND runs of the program, if external
  230. libraries that add functionality become available.
  231. You must successfully call Mix_OpenAudio() before calling these functions.
  232. This API is only available in SDL_mixer 1.2.9 and later.
  233. // usage...
  234. int i;
  235. const int total = Mix_GetNumChunkDecoders();
  236. for (i = 0; i < total; i++)
  237. printf("Supported chunk decoder: [%s]\n", Mix_GetChunkDecoder(i));
  238. Appearing in this list doesn't promise your specific audio file will
  239. decode...but it's handy to know if you have, say, a functioning Timidity
  240. install.
  241. These return values are static, read-only data; do not modify or free it.
  242. The pointers remain valid until you call Mix_CloseAudio().
  243. */
  244. extern DECLSPEC int SDLCALL Mix_GetNumChunkDecoders(void);
  245. extern DECLSPEC const char * SDLCALL Mix_GetChunkDecoder(int index);
  246. extern DECLSPEC SDL_bool SDLCALL Mix_HasChunkDecoder(const char *name);
  247. extern DECLSPEC int SDLCALL Mix_GetNumMusicDecoders(void);
  248. extern DECLSPEC const char * SDLCALL Mix_GetMusicDecoder(int index);
  249. extern DECLSPEC SDL_bool SDLCALL Mix_HasMusicDecoder(const char *name);
  250. /* Find out the music format of a mixer music, or the currently playing
  251. music, if 'music' is NULL.
  252. */
  253. extern DECLSPEC Mix_MusicType SDLCALL Mix_GetMusicType(const Mix_Music *music);
  254. /* Get music title from meta-tag if possible. If title tag is empty, filename will be returned */
  255. extern DECLSPEC const char *SDLCALL Mix_GetMusicTitle(const Mix_Music *music);
  256. /* Get music title from meta-tag if possible */
  257. extern DECLSPEC const char *SDLCALL Mix_GetMusicTitleTag(const Mix_Music *music);
  258. /* Get music artist from meta-tag if possible */
  259. extern DECLSPEC const char *SDLCALL Mix_GetMusicArtistTag(const Mix_Music *music);
  260. /* Get music album from meta-tag if possible */
  261. extern DECLSPEC const char *SDLCALL Mix_GetMusicAlbumTag(const Mix_Music *music);
  262. /* Get music copyright from meta-tag if possible */
  263. extern DECLSPEC const char *SDLCALL Mix_GetMusicCopyrightTag(const Mix_Music *music);
  264. /* Set a function that is called after all mixing is performed.
  265. This can be used to provide real-time visual display of the audio stream
  266. or add a custom mixer filter for the stream data.
  267. */
  268. extern DECLSPEC void SDLCALL Mix_SetPostMix(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg);
  269. /* Add your own music player or additional mixer function.
  270. If 'mix_func' is NULL, the default music player is re-enabled.
  271. */
  272. extern DECLSPEC void SDLCALL Mix_HookMusic(void (SDLCALL *mix_func)(void *udata, Uint8 *stream, int len), void *arg);
  273. /* Add your own callback for when the music has finished playing or when it is
  274. * stopped from a call to Mix_HaltMusic.
  275. */
  276. extern DECLSPEC void SDLCALL Mix_HookMusicFinished(void (SDLCALL *music_finished)(void));
  277. /* Get a pointer to the user data for the current music hook */
  278. extern DECLSPEC void * SDLCALL Mix_GetMusicHookData(void);
  279. /*
  280. * Add your own callback when a channel has finished playing. NULL
  281. * to disable callback. The callback may be called from the mixer's audio
  282. * callback or it could be called as a result of Mix_HaltChannel(), etc.
  283. * do not call SDL_LockAudio() from this callback; you will either be
  284. * inside the audio callback, or SDL_mixer will explicitly lock the audio
  285. * before calling your callback.
  286. */
  287. extern DECLSPEC void SDLCALL Mix_ChannelFinished(void (SDLCALL *channel_finished)(int channel));
  288. /* Special Effects API by ryan c. gordon. ([email protected]) */
  289. #define MIX_CHANNEL_POST -2
  290. /* This is the format of a special effect callback:
  291. *
  292. * myeffect(int chan, void *stream, int len, void *udata);
  293. *
  294. * (chan) is the channel number that your effect is affecting. (stream) is
  295. * the buffer of data to work upon. (len) is the size of (stream), and
  296. * (udata) is a user-defined bit of data, which you pass as the last arg of
  297. * Mix_RegisterEffect(), and is passed back unmolested to your callback.
  298. * Your effect changes the contents of (stream) based on whatever parameters
  299. * are significant, or just leaves it be, if you prefer. You can do whatever
  300. * you like to the buffer, though, and it will continue in its changed state
  301. * down the mixing pipeline, through any other effect functions, then finally
  302. * to be mixed with the rest of the channels and music for the final output
  303. * stream.
  304. *
  305. * DO NOT EVER call SDL_LockAudio() from your callback function!
  306. */
  307. typedef void (SDLCALL *Mix_EffectFunc_t)(int chan, void *stream, int len, void *udata);
  308. /*
  309. * This is a callback that signifies that a channel has finished all its
  310. * loops and has completed playback. This gets called if the buffer
  311. * plays out normally, or if you call Mix_HaltChannel(), implicitly stop
  312. * a channel via Mix_AllocateChannels(), or unregister a callback while
  313. * it's still playing.
  314. *
  315. * DO NOT EVER call SDL_LockAudio() from your callback function!
  316. */
  317. typedef void (SDLCALL *Mix_EffectDone_t)(int chan, void *udata);
  318. /* Register a special effect function. At mixing time, the channel data is
  319. * copied into a buffer and passed through each registered effect function.
  320. * After it passes through all the functions, it is mixed into the final
  321. * output stream. The copy to buffer is performed once, then each effect
  322. * function performs on the output of the previous effect. Understand that
  323. * this extra copy to a buffer is not performed if there are no effects
  324. * registered for a given chunk, which saves CPU cycles, and any given
  325. * effect will be extra cycles, too, so it is crucial that your code run
  326. * fast. Also note that the data that your function is given is in the
  327. * format of the sound device, and not the format you gave to Mix_OpenAudio(),
  328. * although they may in reality be the same. This is an unfortunate but
  329. * necessary speed concern. Use Mix_QuerySpec() to determine if you can
  330. * handle the data before you register your effect, and take appropriate
  331. * actions.
  332. * You may also specify a callback (Mix_EffectDone_t) that is called when
  333. * the channel finishes playing. This gives you a more fine-grained control
  334. * than Mix_ChannelFinished(), in case you need to free effect-specific
  335. * resources, etc. If you don't need this, you can specify NULL.
  336. * You may set the callbacks before or after calling Mix_PlayChannel().
  337. * Things like Mix_SetPanning() are just internal special effect functions,
  338. * so if you are using that, you've already incurred the overhead of a copy
  339. * to a separate buffer, and that these effects will be in the queue with
  340. * any functions you've registered. The list of registered effects for a
  341. * channel is reset when a chunk finishes playing, so you need to explicitly
  342. * set them with each call to Mix_PlayChannel*().
  343. * You may also register a special effect function that is to be run after
  344. * final mixing occurs. The rules for these callbacks are identical to those
  345. * in Mix_RegisterEffect, but they are run after all the channels and the
  346. * music have been mixed into a single stream, whereas channel-specific
  347. * effects run on a given channel before any other mixing occurs. These
  348. * global effect callbacks are call "posteffects". Posteffects only have
  349. * their Mix_EffectDone_t function called when they are unregistered (since
  350. * the main output stream is never "done" in the same sense as a channel).
  351. * You must unregister them manually when you've had enough. Your callback
  352. * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the
  353. * processing is considered a posteffect.
  354. *
  355. * After all these effects have finished processing, the callback registered
  356. * through Mix_SetPostMix() runs, and then the stream goes to the audio
  357. * device.
  358. *
  359. * DO NOT EVER call SDL_LockAudio() from your callback function!
  360. *
  361. * returns zero if error (no such channel), nonzero if added.
  362. * Error messages can be retrieved from Mix_GetError().
  363. */
  364. extern DECLSPEC int SDLCALL Mix_RegisterEffect(int chan, Mix_EffectFunc_t f, Mix_EffectDone_t d, void *arg);
  365. /* You may not need to call this explicitly, unless you need to stop an
  366. * effect from processing in the middle of a chunk's playback.
  367. * Posteffects are never implicitly unregistered as they are for channels,
  368. * but they may be explicitly unregistered through this function by
  369. * specifying MIX_CHANNEL_POST for a channel.
  370. * returns zero if error (no such channel or effect), nonzero if removed.
  371. * Error messages can be retrieved from Mix_GetError().
  372. */
  373. extern DECLSPEC int SDLCALL Mix_UnregisterEffect(int channel, Mix_EffectFunc_t f);
  374. /* You may not need to call this explicitly, unless you need to stop all
  375. * effects from processing in the middle of a chunk's playback. Note that
  376. * this will also shut off some internal effect processing, since
  377. * Mix_SetPanning() and others may use this API under the hood. This is
  378. * called internally when a channel completes playback.
  379. * Posteffects are never implicitly unregistered as they are for channels,
  380. * but they may be explicitly unregistered through this function by
  381. * specifying MIX_CHANNEL_POST for a channel.
  382. * returns zero if error (no such channel), nonzero if all effects removed.
  383. * Error messages can be retrieved from Mix_GetError().
  384. */
  385. extern DECLSPEC int SDLCALL Mix_UnregisterAllEffects(int channel);
  386. #define MIX_EFFECTSMAXSPEED "MIX_EFFECTSMAXSPEED"
  387. /*
  388. * These are the internally-defined mixing effects. They use the same API that
  389. * effects defined in the application use, but are provided here as a
  390. * convenience. Some effects can reduce their quality or use more memory in
  391. * the name of speed; to enable this, make sure the environment variable
  392. * MIX_EFFECTSMAXSPEED (see above) is defined before you call
  393. * Mix_OpenAudio().
  394. */
  395. /* Set the panning of a channel. The left and right channels are specified
  396. * as integers between 0 and 255, quietest to loudest, respectively.
  397. *
  398. * Technically, this is just individual volume control for a sample with
  399. * two (stereo) channels, so it can be used for more than just panning.
  400. * If you want real panning, call it like this:
  401. *
  402. * Mix_SetPanning(channel, left, 255 - left);
  403. *
  404. * ...which isn't so hard.
  405. *
  406. * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
  407. * the panning will be done to the final mixed stream before passing it on
  408. * to the audio device.
  409. *
  410. * This uses the Mix_RegisterEffect() API internally, and returns without
  411. * registering the effect function if the audio device is not configured
  412. * for stereo output. Setting both (left) and (right) to 255 causes this
  413. * effect to be unregistered, since that is the data's normal state.
  414. *
  415. * returns zero if error (no such channel or Mix_RegisterEffect() fails),
  416. * nonzero if panning effect enabled. Note that an audio device in mono
  417. * mode is a no-op, but this call will return successful in that case.
  418. * Error messages can be retrieved from Mix_GetError().
  419. */
  420. extern DECLSPEC int SDLCALL Mix_SetPanning(int channel, Uint8 left, Uint8 right);
  421. /* Set the position of a channel. (angle) is an integer from 0 to 360, that
  422. * specifies the location of the sound in relation to the listener. (angle)
  423. * will be reduced as neccesary (540 becomes 180 degrees, -100 becomes 260).
  424. * Angle 0 is due north, and rotates clockwise as the value increases.
  425. * For efficiency, the precision of this effect may be limited (angles 1
  426. * through 7 might all produce the same effect, 8 through 15 are equal, etc).
  427. * (distance) is an integer between 0 and 255 that specifies the space
  428. * between the sound and the listener. The larger the number, the further
  429. * away the sound is. Using 255 does not guarantee that the channel will be
  430. * culled from the mixing process or be completely silent. For efficiency,
  431. * the precision of this effect may be limited (distance 0 through 5 might
  432. * all produce the same effect, 6 through 10 are equal, etc). Setting (angle)
  433. * and (distance) to 0 unregisters this effect, since the data would be
  434. * unchanged.
  435. *
  436. * If you need more precise positional audio, consider using OpenAL for
  437. * spatialized effects instead of SDL_mixer. This is only meant to be a
  438. * basic effect for simple "3D" games.
  439. *
  440. * If the audio device is configured for mono output, then you won't get
  441. * any effectiveness from the angle; however, distance attenuation on the
  442. * channel will still occur. While this effect will function with stereo
  443. * voices, it makes more sense to use voices with only one channel of sound,
  444. * so when they are mixed through this effect, the positioning will sound
  445. * correct. You can convert them to mono through SDL before giving them to
  446. * the mixer in the first place if you like.
  447. *
  448. * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
  449. * the positioning will be done to the final mixed stream before passing it
  450. * on to the audio device.
  451. *
  452. * This is a convenience wrapper over Mix_SetDistance() and Mix_SetPanning().
  453. *
  454. * returns zero if error (no such channel or Mix_RegisterEffect() fails),
  455. * nonzero if position effect is enabled.
  456. * Error messages can be retrieved from Mix_GetError().
  457. */
  458. extern DECLSPEC int SDLCALL Mix_SetPosition(int channel, Sint16 angle, Uint8 distance);
  459. /* Set the "distance" of a channel. (distance) is an integer from 0 to 255
  460. * that specifies the location of the sound in relation to the listener.
  461. * Distance 0 is overlapping the listener, and 255 is as far away as possible
  462. * A distance of 255 does not guarantee silence; in such a case, you might
  463. * want to try changing the chunk's volume, or just cull the sample from the
  464. * mixing process with Mix_HaltChannel().
  465. * For efficiency, the precision of this effect may be limited (distances 1
  466. * through 7 might all produce the same effect, 8 through 15 are equal, etc).
  467. * (distance) is an integer between 0 and 255 that specifies the space
  468. * between the sound and the listener. The larger the number, the further
  469. * away the sound is.
  470. * Setting (distance) to 0 unregisters this effect, since the data would be
  471. * unchanged.
  472. * If you need more precise positional audio, consider using OpenAL for
  473. * spatialized effects instead of SDL_mixer. This is only meant to be a
  474. * basic effect for simple "3D" games.
  475. *
  476. * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
  477. * the distance attenuation will be done to the final mixed stream before
  478. * passing it on to the audio device.
  479. *
  480. * This uses the Mix_RegisterEffect() API internally.
  481. *
  482. * returns zero if error (no such channel or Mix_RegisterEffect() fails),
  483. * nonzero if position effect is enabled.
  484. * Error messages can be retrieved from Mix_GetError().
  485. */
  486. extern DECLSPEC int SDLCALL Mix_SetDistance(int channel, Uint8 distance);
  487. /*
  488. * !!! FIXME : Haven't implemented, since the effect goes past the
  489. * end of the sound buffer. Will have to think about this.
  490. * --ryan.
  491. */
  492. #if 0
  493. /* Causes an echo effect to be mixed into a sound. (echo) is the amount
  494. * of echo to mix. 0 is no echo, 255 is infinite (and probably not
  495. * what you want).
  496. *
  497. * Setting (channel) to MIX_CHANNEL_POST registers this as a posteffect, and
  498. * the reverbing will be done to the final mixed stream before passing it on
  499. * to the audio device.
  500. *
  501. * This uses the Mix_RegisterEffect() API internally. If you specify an echo
  502. * of zero, the effect is unregistered, as the data is already in that state.
  503. *
  504. * returns zero if error (no such channel or Mix_RegisterEffect() fails),
  505. * nonzero if reversing effect is enabled.
  506. * Error messages can be retrieved from Mix_GetError().
  507. */
  508. extern no_parse_DECLSPEC int SDLCALL Mix_SetReverb(int channel, Uint8 echo);
  509. #endif
  510. /* Causes a channel to reverse its stereo. This is handy if the user has his
  511. * speakers hooked up backwards, or you would like to have a minor bit of
  512. * psychedelia in your sound code. :) Calling this function with (flip)
  513. * set to non-zero reverses the chunks's usual channels. If (flip) is zero,
  514. * the effect is unregistered.
  515. *
  516. * This uses the Mix_RegisterEffect() API internally, and thus is probably
  517. * more CPU intensive than having the user just plug in his speakers
  518. * correctly. Mix_SetReverseStereo() returns without registering the effect
  519. * function if the audio device is not configured for stereo output.
  520. *
  521. * If you specify MIX_CHANNEL_POST for (channel), then this the effect is used
  522. * on the final mixed stream before sending it on to the audio device (a
  523. * posteffect).
  524. *
  525. * returns zero if error (no such channel or Mix_RegisterEffect() fails),
  526. * nonzero if reversing effect is enabled. Note that an audio device in mono
  527. * mode is a no-op, but this call will return successful in that case.
  528. * Error messages can be retrieved from Mix_GetError().
  529. */
  530. extern DECLSPEC int SDLCALL Mix_SetReverseStereo(int channel, int flip);
  531. /* end of effects API. --ryan. */
  532. /* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate
  533. them dynamically to the next sample if requested with a -1 value below.
  534. Returns the number of reserved channels.
  535. */
  536. extern DECLSPEC int SDLCALL Mix_ReserveChannels(int num);
  537. /* Channel grouping functions */
  538. /* Attach a tag to a channel. A tag can be assigned to several mixer
  539. channels, to form groups of channels.
  540. If 'tag' is -1, the tag is removed (actually -1 is the tag used to
  541. represent the group of all the channels).
  542. Returns true if everything was OK.
  543. */
  544. extern DECLSPEC int SDLCALL Mix_GroupChannel(int which, int tag);
  545. /* Assign several consecutive channels to a group */
  546. extern DECLSPEC int SDLCALL Mix_GroupChannels(int from, int to, int tag);
  547. /* Finds the first available channel in a group of channels,
  548. returning -1 if none are available.
  549. */
  550. extern DECLSPEC int SDLCALL Mix_GroupAvailable(int tag);
  551. /* Returns the number of channels in a group. This is also a subtle
  552. way to get the total number of channels when 'tag' is -1
  553. */
  554. extern DECLSPEC int SDLCALL Mix_GroupCount(int tag);
  555. /* Finds the "oldest" sample playing in a group of channels */
  556. extern DECLSPEC int SDLCALL Mix_GroupOldest(int tag);
  557. /* Finds the "most recent" (i.e. last) sample playing in a group of channels */
  558. extern DECLSPEC int SDLCALL Mix_GroupNewer(int tag);
  559. /* Play an audio chunk on a specific channel.
  560. If the specified channel is -1, play on the first free channel.
  561. If 'loops' is greater than zero, loop the sound that many times.
  562. If 'loops' is -1, loop inifinitely (~65000 times).
  563. Returns which channel was used to play the sound.
  564. */
  565. #define Mix_PlayChannel(channel,chunk,loops) Mix_PlayChannelTimed(channel,chunk,loops,-1)
  566. /* The same as above, but the sound is played at most 'ticks' milliseconds */
  567. extern DECLSPEC int SDLCALL Mix_PlayChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ticks);
  568. extern DECLSPEC int SDLCALL Mix_PlayMusic(Mix_Music *music, int loops);
  569. #define Mix_PlayChannelVol(channel,chunk,loops,vol) Mix_PlayChannelTimedVolume(channel,chunk,loops,-1,vol)/*MIXER-X*/
  570. extern DECLSPEC int SDLCALL Mix_PlayChannelTimedVolume(int which, Mix_Chunk *chunk, int loops, int ticks, int volume);/*MIXER-X*/
  571. /* Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions */
  572. extern DECLSPEC int SDLCALL Mix_FadeInMusic(Mix_Music *music, int loops, int ms);
  573. extern DECLSPEC int SDLCALL Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position);
  574. #define Mix_FadeInChannel(channel,chunk,loops,ms) Mix_FadeInChannelTimed(channel,chunk,loops,ms,-1)
  575. extern DECLSPEC int SDLCALL Mix_FadeInChannelTimed(int channel, Mix_Chunk *chunk, int loops, int ms, int ticks);
  576. #define Mix_FadeInChannelVolume(channel,chunk,loops,ms,vol) Mix_FadeInChannelTimed(channel,chunk,loops,ms,-1,vol)/*MIXER-X*/
  577. extern DECLSPEC int SDLCALL Mix_FadeInChannelTimedVolume(int which, Mix_Chunk *chunk, int loops, int ms, int ticks, int volume);/*MIXER-X*/
  578. /* Set the volume in the range of 0-128 of a specific channel or chunk.
  579. If the specified channel is -1, set volume for all channels.
  580. Returns the original volume.
  581. If the specified volume is -1, just return the current volume.
  582. */
  583. extern DECLSPEC int SDLCALL Mix_Volume(int channel, int volume);
  584. extern DECLSPEC int SDLCALL Mix_VolumeChunk(Mix_Chunk *chunk, int volume);
  585. extern DECLSPEC int SDLCALL Mix_VolumeMusic(int volume);
  586. /* Halt playing of a particular channel */
  587. extern DECLSPEC int SDLCALL Mix_HaltChannel(int channel);
  588. extern DECLSPEC int SDLCALL Mix_HaltGroup(int tag);
  589. extern DECLSPEC int SDLCALL Mix_HaltMusic(void);
  590. /* Change the expiration delay for a particular channel.
  591. The sample will stop playing after the 'ticks' milliseconds have elapsed,
  592. or remove the expiration if 'ticks' is -1
  593. */
  594. extern DECLSPEC int SDLCALL Mix_ExpireChannel(int channel, int ticks);
  595. /* Halt a channel, fading it out progressively till it's silent
  596. The ms parameter indicates the number of milliseconds the fading
  597. will take.
  598. */
  599. extern DECLSPEC int SDLCALL Mix_FadeOutChannel(int which, int ms);
  600. extern DECLSPEC int SDLCALL Mix_FadeOutGroup(int tag, int ms);
  601. extern DECLSPEC int SDLCALL Mix_FadeOutMusic(int ms);
  602. /* Query the fading status of a channel */
  603. extern DECLSPEC Mix_Fading SDLCALL Mix_FadingMusic(void);
  604. extern DECLSPEC Mix_Fading SDLCALL Mix_FadingChannel(int which);
  605. /* Pause/Resume a particular channel */
  606. extern DECLSPEC void SDLCALL Mix_Pause(int channel);
  607. extern DECLSPEC void SDLCALL Mix_Resume(int channel);
  608. extern DECLSPEC int SDLCALL Mix_Paused(int channel);
  609. /* Pause/Resume the music stream */
  610. extern DECLSPEC void SDLCALL Mix_PauseMusic(void);
  611. extern DECLSPEC void SDLCALL Mix_ResumeMusic(void);
  612. extern DECLSPEC void SDLCALL Mix_RewindMusic(void);
  613. extern DECLSPEC int SDLCALL Mix_PausedMusic(void);
  614. /* Set the current position in the music stream.
  615. This returns 0 if successful, or -1 if it failed or isn't implemented.
  616. This function is only implemented for MOD music formats (set pattern
  617. order number) and for WAV, OGG, FLAC, MP3_MAD, MP3_MPG, and MODPLUG music
  618. (set position in seconds), at the moment.
  619. */
  620. extern DECLSPEC int SDLCALL Mix_SetMusicPosition(double position);
  621. /*
  622. Get the time current position of music stream
  623. returns -1.0 if this feature is not supported for some codec
  624. */
  625. extern DECLSPEC double SDLCALL Mix_GetMusicPosition(Mix_Music *music);
  626. /*
  627. Get the total time length of music stream
  628. returns -1.0 if this feature is not supported for some codec
  629. */
  630. extern DECLSPEC double SDLCALL Mix_GetMusicTotalTime(Mix_Music *music);
  631. /*
  632. Get the loop start time position of music stream
  633. returns -1.0 if this feature is not used for this music or not supported for some codec
  634. */
  635. extern DECLSPEC double SDLCALL Mix_GetMusicLoopStartTime(Mix_Music *music);
  636. /*
  637. Get the loop end time position of music stream
  638. returns -1.0 if this feature is not used for this music or not supported for some codec
  639. */
  640. extern DECLSPEC double SDLCALL Mix_GetMusicLoopEndTime(Mix_Music *music);
  641. /*
  642. Get the loop time length of music stream
  643. returns -1.0 if this feature is not used for this music or not supported for some codec
  644. */
  645. extern DECLSPEC double SDLCALL Mix_GetMusicLoopLengthTime(Mix_Music *music);
  646. /* Check the status of a specific channel.
  647. If the specified channel is -1, check all channels.
  648. */
  649. extern DECLSPEC int SDLCALL Mix_Playing(int channel);
  650. extern DECLSPEC int SDLCALL Mix_PlayingMusic(void);
  651. /* Stop music and set external music playback command */
  652. extern DECLSPEC int SDLCALL Mix_SetMusicCMD(const char *command);
  653. /* Synchro value is set by MikMod from modules while playing */
  654. extern DECLSPEC int SDLCALL Mix_SetSynchroValue(int value);
  655. extern DECLSPEC int SDLCALL Mix_GetSynchroValue(void);
  656. /* Set/Get/Iterate SoundFonts paths to use by supported MIDI backends */
  657. extern DECLSPEC int SDLCALL Mix_SetSoundFonts(const char *paths);
  658. extern DECLSPEC const char* SDLCALL Mix_GetSoundFonts(void);
  659. extern DECLSPEC int SDLCALL Mix_EachSoundFont(int (SDLCALL *function)(const char*, void*), void *data);
  660. /* Get the Mix_Chunk currently associated with a mixer channel
  661. Returns NULL if it's an invalid channel, or there's no chunk associated.
  662. */
  663. extern DECLSPEC Mix_Chunk * SDLCALL Mix_GetChunk(int channel);
  664. /* Close the mixer, halting all playing audio */
  665. extern DECLSPEC void SDLCALL Mix_CloseAudio(void);
  666. /* Add additional Timidity bank path */
  667. extern DECLSPEC void SDLCALL Mix_Timidity_addToPathList(const char *path);
  668. /* ADLMIDI Setup functions */
  669. /* Get count of available hardcoded banks */
  670. extern DECLSPEC int SDLCALL Mix_ADLMIDI_getTotalBanks(void);
  671. /* Get array of the bank names */
  672. extern DECLSPEC const char *const *SDLCALL Mix_ADLMIDI_getBankNames(void);
  673. /* Get bank ID */
  674. extern DECLSPEC int SDLCALL Mix_ADLMIDI_getBankID(void);
  675. /* Set bank ID (Applying on stop/play) */
  676. extern DECLSPEC void SDLCALL Mix_ADLMIDI_setBankID(int bnk);
  677. /* Get state of deep vibrato */
  678. extern DECLSPEC int SDLCALL Mix_ADLMIDI_getTremolo(void);
  679. /* Set deep tremolo mode (0 off, 1 on) (Applying on stop/play) */
  680. extern DECLSPEC void SDLCALL Mix_ADLMIDI_setTremolo(int tr);
  681. /* Get state of deep vibrato */
  682. extern DECLSPEC int SDLCALL Mix_ADLMIDI_getVibrato(void);
  683. /* Set deep vibrato mode (0 off, 1 on) (Applying on stop/play) */
  684. extern DECLSPEC void SDLCALL Mix_ADLMIDI_setVibrato(int vib);
  685. /* Get state of scalable modulation mode */
  686. extern DECLSPEC int SDLCALL Mix_ADLMIDI_getScaleMod(void);
  687. /* Set scalable modulation mode (0 off, 1 on) (Applying on stop/play) */
  688. extern DECLSPEC void SDLCALL Mix_ADLMIDI_setScaleMod(int sc);
  689. /* Get state of adlib drums mode */
  690. extern DECLSPEC int SDLCALL Mix_ADLMIDI_getAdLibMode(void);
  691. /* Set adlib drums mode mode (0 off, 1 on) (Applying on stop/play) */
  692. extern DECLSPEC void SDLCALL Mix_ADLMIDI_setAdLibMode(int tr);
  693. /* Get state of logarithmic mode */
  694. extern DECLSPEC int SDLCALL Mix_ADLMIDI_getLogarithmicVolumes(void);
  695. /* Set logarithmic volumes mode in the generic/CMF volume models (0 off, 1 on) (Applying on stop/play) */
  696. extern DECLSPEC void SDLCALL Mix_ADLMIDI_setLogarithmicVolumes(int lv);
  697. /* Get current volume model ID */
  698. extern DECLSPEC int SDLCALL Mix_ADLMIDI_getVolumeModel(void);
  699. /* Change current volumes model (Applying on stop/play) */
  700. extern DECLSPEC void SDLCALL Mix_ADLMIDI_setVolumeModel(int vm);
  701. /* Get full range mode for CC74-Brightness controller */
  702. extern DECLSPEC int SDLCALL Mix_ADLMIDI_getFullRangeBrightness(void);
  703. /* Set full range mode for CC74-Brightness controller */
  704. extern DECLSPEC void SDLCALL Mix_ADLMIDI_setFullRangeBrightness(int frb);
  705. /* Get the current OPL3 Emulator for ADLMIDI */
  706. extern DECLSPEC int SDLCALL Mix_ADLMIDI_getEmulator(void);
  707. /* Select the OPL3 Emulator for ADLMIDI */
  708. extern DECLSPEC void SDLCALL Mix_ADLMIDI_setEmulator(int emu);
  709. /* Reset all ADLMIDI properties to default state */
  710. extern DECLSPEC void SDLCALL Mix_ADLMIDI_setSetDefaults(void);
  711. /* Sets WOPL bank file for ADLMIDI playing device, affects on MIDI file reopen */
  712. extern DECLSPEC void SDLCALL Mix_ADLMIDI_setCustomBankFile(const char *bank_wonl_path);
  713. /* Reset all OPNMIDI properties to default state */
  714. extern DECLSPEC void SDLCALL Mix_OPNMIDI_setSetDefaults(void);
  715. /* Get full range mode for CC74-Brightness controller */
  716. extern DECLSPEC int SDLCALL Mix_OPNMIDI_getFullRangeBrightness(void);
  717. /* Set full range mode for CC74-Brightness controller */
  718. extern DECLSPEC void SDLCALL Mix_OPNMIDI_setFullRangeBrightness(int frb);
  719. /* Get the OPN2 Emulator for OPNMIDI */
  720. extern DECLSPEC int SDLCALL Mix_OPNMIDI_getEmulator(void);
  721. /* Select the OPN2 Emulator for OPNMIDI */
  722. extern DECLSPEC void SDLCALL Mix_OPNMIDI_setEmulator(int emu);
  723. /* Sets WOPN bank file for OPNMIDI playing device, affects on MIDI file reopen */
  724. extern DECLSPEC void SDLCALL Mix_OPNMIDI_setCustomBankFile(const char *bank_wonp_path);
  725. /* Get type of MIDI player library currently in use */
  726. extern DECLSPEC int SDLCALL Mix_GetMidiPlayer(void);
  727. /* Get type of MIDI player library prepared for next opening of MIDI file */
  728. extern DECLSPEC int SDLCALL Mix_GetNextMidiPlayer(void);
  729. /* Set the MIDI playing library (ADLMIDI, Timidity, Native MIDI (if available) and FluidSynth) */
  730. extern DECLSPEC int SDLCALL Mix_SetMidiPlayer(int player);
  731. /* Disables support of MIDI file arguments */
  732. extern DECLSPEC void SDLCALL Mix_SetLockMIDIArgs(int lock_midiargs);
  733. /* DEPRECATED NAMES for new-added SDL Mixer X functions
  734. Those names are made with mistake - beginning with "MIX_" than "Mix_"
  735. which makes confusion when you looking for Mix_ function in your IDE
  736. because some applications are still use them, to don't break ABI we will keep those
  737. aliases until we will remove all usages of them from applications and libraries are used them
  738. */
  739. DEPRECATED(extern DECLSPEC int SDLCALL Mix_GetMidiDevice(void));
  740. DEPRECATED(extern DECLSPEC int SDLCALL Mix_GetNextMidiDevice(void));
  741. DEPRECATED(extern DECLSPEC int SDLCALL Mix_SetMidiDevice(int player));
  742. /* We'll use SDL for reporting errors */
  743. #define Mix_SetError SDL_SetError
  744. #define Mix_GetError SDL_GetError
  745. #define Mix_ClearError SDL_ClearError
  746. /* Ends C function definitions when using C++ */
  747. #ifdef __cplusplus
  748. }
  749. #endif
  750. #include "close_code.h"
  751. #endif /* SDL_MIXER_H_ */
  752. /* vi: set ts=4 sw=4 expandtab: */