sdl_mixer.pas 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072
  1. unit sdl_mixer;
  2. {******************************************************************************}
  3. {
  4. $Id: sdl_mixer.pas,v 1.11 2005/01/01 02:05:19 savage Exp $
  5. }
  6. { }
  7. { Borland Delphi SDL_Mixer - Simple DirectMedia Layer Mixer Library }
  8. { Conversion of the Simple DirectMedia Layer Headers }
  9. { }
  10. { Portions created by Sam Lantinga <[email protected]> are }
  11. { Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga }
  12. { 5635-34 Springhouse Dr. }
  13. { Pleasanton, CA 94588 (USA) }
  14. { }
  15. { All Rights Reserved. }
  16. { }
  17. { The original files are : SDL_mixer.h }
  18. { music_cmd.h }
  19. { wavestream.h }
  20. { timidity.h }
  21. { playmidi.h }
  22. { music_ogg.h }
  23. { mikmod.h }
  24. { }
  25. { The initial developer of this Pascal code was : }
  26. { Dominqiue Louis <[email protected]> }
  27. { }
  28. { Portions created by Dominqiue Louis are }
  29. { Copyright (C) 2000 - 2001 Dominqiue Louis. }
  30. { }
  31. { }
  32. { Contributor(s) }
  33. { -------------- }
  34. { Matthias Thoma <[email protected]> }
  35. { }
  36. { Obtained through: }
  37. { Joint Endeavour of Delphi Innovators ( Project JEDI ) }
  38. { }
  39. { You may retrieve the latest version of this file at the Project }
  40. { JEDI home page, located at http://delphi-jedi.org }
  41. { }
  42. { The contents of this file are used with permission, subject to }
  43. { the Mozilla Public License Version 1.1 (the "License"); you may }
  44. { not use this file except in compliance with the License. You may }
  45. { obtain a copy of the License at }
  46. { http://www.mozilla.org/MPL/MPL-1.1.html }
  47. { }
  48. { Software distributed under the License is distributed on an }
  49. { "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
  50. { implied. See the License for the specific language governing }
  51. { rights and limitations under the License. }
  52. { }
  53. { Description }
  54. { ----------- }
  55. { }
  56. { }
  57. { }
  58. { }
  59. { }
  60. { }
  61. { }
  62. { Requires }
  63. { -------- }
  64. { SDL.pas & SMPEG.pas somewhere within your search path. }
  65. { }
  66. { Programming Notes }
  67. { ----------------- }
  68. { See the Aliens Demo to see how this library is used }
  69. { }
  70. { Revision History }
  71. { ---------------- }
  72. { April 02 2001 - DL : Initial Translation }
  73. { }
  74. { February 02 2002 - DL : Update to version 1.2.1 }
  75. { }
  76. { April 03 2003 - DL : Added jedi-sdl.inc include file to support more }
  77. { Pascal compilers. Initial support is now included }
  78. { for GnuPascal, VirtualPascal, TMT and obviously }
  79. { continue support for Delphi Kylix and FreePascal. }
  80. { }
  81. { April 24 2003 - DL : under instruction from Alexey Barkovoy, I have added}
  82. { better TMT Pascal support and under instruction }
  83. { from Prof. Abimbola Olowofoyeku (The African Chief),}
  84. { I have added better Gnu Pascal support }
  85. { }
  86. { April 30 2003 - DL : under instruction from David Mears AKA }
  87. { Jason Siletto, I have added FPC Linux support. }
  88. { This was compiled with fpc 1.1, so remember to set }
  89. { include file path. ie. -Fi/usr/share/fpcsrc/rtl/* }
  90. { }
  91. {
  92. $Log: sdl_mixer.pas,v $
  93. Revision 1.11 2005/01/01 02:05:19 savage
  94. Updated to v1.2.6
  95. Revision 1.10 2004/09/12 21:45:17 savage
  96. Robert Reed spotted that Mix_SetMusicPosition was missing from the conversion, so this has now been added.
  97. Revision 1.9 2004/08/27 21:48:24 savage
  98. IFDEFed out Smpeg support on MacOS X
  99. Revision 1.8 2004/08/14 22:54:30 savage
  100. Updated so that Library name defines are correctly defined for MacOS X.
  101. Revision 1.7 2004/05/10 14:10:04 savage
  102. Initial MacOS X support. Fixed defines for MACOS ( Classic ) and DARWIN ( MacOS X ).
  103. Revision 1.6 2004/04/13 09:32:08 savage
  104. Changed Shared object names back to just the .so extension to avoid conflicts on various Linux/Unix distros. Therefore developers will need to create Symbolic links to the actual Share Objects if necessary.
  105. Revision 1.5 2004/04/01 20:53:23 savage
  106. Changed Linux Shared Object names so they reflect the Symbolic Links that are created when installing the RPMs from the SDL site.
  107. Revision 1.4 2004/03/31 22:20:02 savage
  108. Windows unit not used in this file, so it was removed to keep the code tidy.
  109. Revision 1.3 2004/03/31 10:05:08 savage
  110. Better defines for Endianess under FreePascal and Borland compilers.
  111. Revision 1.2 2004/03/30 20:23:28 savage
  112. Tidied up use of UNIX compiler directive.
  113. Revision 1.1 2004/02/14 23:35:42 savage
  114. version 1 of sdl_image, sdl_mixer and smpeg.
  115. }
  116. {******************************************************************************}
  117. {$I jedi-sdl.inc}
  118. interface
  119. {$IFDEF FPC}
  120. {$IFDEF FPC_LITTLE_ENDIAN}
  121. {$DEFINE IA32}
  122. {$ENDIF}
  123. {$ENDIF}
  124. uses
  125. {$IFNDEF DARWIN}
  126. smpeg,
  127. {$ENDIF}
  128. sdl;
  129. const
  130. {$IFDEF WIN32}
  131. SDL_MixerLibName = 'SDL_mixer.dll';
  132. {$ENDIF}
  133. {$IFDEF UNIX}
  134. {$IFDEF DARWIN}
  135. SDL_MixerLibName = 'libSDL_mixer.dylib';
  136. {$ELSE}
  137. SDL_MixerLibName = 'libSDL_mixer.so';
  138. {$ENDIF}
  139. {$ENDIF}
  140. {$IFDEF MACOS}
  141. SDL_MixerLibName = 'SDL_mixer';
  142. {$ENDIF}
  143. {* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL *}
  144. SDL_MIXER_MAJOR_VERSION = 1;
  145. {$EXTERNALSYM MIX_MAJOR_VERSION}
  146. SDL_MIXER_MINOR_VERSION = 2;
  147. {$EXTERNALSYM MIX_MINOR_VERSION}
  148. SDL_MIXER_PATCHLEVEL = 6;
  149. {$EXTERNALSYM MIX_PATCHLEVEL}
  150. // Backwards compatibility
  151. MIX_MAJOR_VERSION = SDL_MIXER_MAJOR_VERSION;
  152. MIX_MINOR_VERSION = SDL_MIXER_MINOR_VERSION;
  153. MIX_PATCHLEVEL = SDL_MIXER_PATCHLEVEL;
  154. // SDL_Mixer.h constants
  155. { The default mixer has 8 simultaneous mixing channels }
  156. {$IFNDEF MIX_CHANNELS}
  157. MIX_CHANNELS = 8;
  158. {$ENDIF}
  159. {$EXTERNALSYM MIX_CHANNELS}
  160. { Good default values for a PC soundcard }
  161. MIX_DEFAULT_FREQUENCY = 22050;
  162. {$EXTERNALSYM MIX_DEFAULT_FREQUENCY}
  163. {$IFDEF IA32}
  164. MIX_DEFAULT_FORMAT = AUDIO_S16LSB;
  165. {$ELSE}
  166. MIX_DEFAULT_FORMAT = AUDIO_S16MSB;
  167. {$ENDIF}
  168. {$EXTERNALSYM MIX_DEFAULT_FORMAT}
  169. MIX_DEFAULT_CHANNELS = 2;
  170. {$EXTERNALSYM MIX_DEFAULT_CHANNELS}
  171. MIX_MAX_VOLUME = 128; { Volume of a chunk }
  172. {$EXTERNALSYM MIX_MAX_VOLUME}
  173. PATH_MAX = 255;
  174. // mikmod.h constants
  175. {*
  176. * Library version
  177. *}
  178. LIBMIKMOD_VERSION_MAJOR = 3;
  179. LIBMIKMOD_VERSION_MINOR = 1;
  180. LIBMIKMOD_REVISION = 8;
  181. LIBMIKMOD_VERSION = ( ( LIBMIKMOD_VERSION_MAJOR shl 16 ) or
  182. ( LIBMIKMOD_VERSION_MINOR shl 8 ) or
  183. ( LIBMIKMOD_REVISION ) );
  184. type
  185. //music_cmd.h types
  186. PMusicCMD = ^TMusicCMD;
  187. TMusicCMD = record
  188. filename : array[ 0..PATH_MAX - 1 ] of char;
  189. cmd : array[ 0..PATH_MAX - 1 ] of char;
  190. pid : TSYS_ThreadHandle;
  191. end;
  192. //wavestream.h types
  193. PWAVStream = ^TWAVStream;
  194. TWAVStream = record
  195. wavefp : Pointer;
  196. start : longint;
  197. stop : longint;
  198. cvt : TSDL_AudioCVT;
  199. end;
  200. //playmidi.h types
  201. PMidiEvent = ^TMidiEvent;
  202. TMidiEvent = record
  203. time : Longint;
  204. channel : uint8;
  205. type_ : uint8;
  206. a : uint8;
  207. b : uint8;
  208. end;
  209. PMidiSong = ^TMidiSong;
  210. TMidiSong = record
  211. samples : Longint;
  212. events : PMidiEvent;
  213. end;
  214. //music_ogg.h types
  215. POGG_Music = ^TOGG_Music;
  216. TOGG_Music = record
  217. playing : integer;
  218. volume : integer;
  219. //vf: OggVorbis_File;
  220. section : integer;
  221. cvt : TSDL_AudioCVT;
  222. len_available : integer;
  223. snd_available : PUint8;
  224. end;
  225. // mikmod.h types
  226. {*
  227. * Error codes
  228. *}
  229. TErrorEnum = (
  230. MMERR_OPENING_FILE,
  231. MMERR_OUT_OF_MEMORY,
  232. MMERR_DYNAMIC_LINKING,
  233. MMERR_SAMPLE_TOO_BIG,
  234. MMERR_OUT_OF_HANDLES,
  235. MMERR_UNKNOWN_WAVE_TYPE,
  236. MMERR_LOADING_PATTERN,
  237. MMERR_LOADING_TRACK,
  238. MMERR_LOADING_HEADER,
  239. MMERR_LOADING_SAMPLEINFO,
  240. MMERR_NOT_A_MODULE,
  241. MMERR_NOT_A_STREAM,
  242. MMERR_MED_SYNTHSAMPLES,
  243. MMERR_ITPACK_INVALID_DATA,
  244. MMERR_DETECTING_DEVICE,
  245. MMERR_INVALID_DEVICE,
  246. MMERR_INITIALIZING_MIXER,
  247. MMERR_OPENING_AUDIO,
  248. MMERR_8BIT_ONLY,
  249. MMERR_16BIT_ONLY,
  250. MMERR_STEREO_ONLY,
  251. MMERR_ULAW,
  252. MMERR_NON_BLOCK,
  253. MMERR_AF_AUDIO_PORT,
  254. MMERR_AIX_CONFIG_INIT,
  255. MMERR_AIX_CONFIG_CONTROL,
  256. MMERR_AIX_CONFIG_START,
  257. MMERR_GUS_SETTINGS,
  258. MMERR_GUS_RESET,
  259. MMERR_GUS_TIMER,
  260. MMERR_HP_SETSAMPLESIZE,
  261. MMERR_HP_SETSPEED,
  262. MMERR_HP_CHANNELS,
  263. MMERR_HP_AUDIO_OUTPUT,
  264. MMERR_HP_AUDIO_DESC,
  265. MMERR_HP_BUFFERSIZE,
  266. MMERR_OSS_SETFRAGMENT,
  267. MMERR_OSS_SETSAMPLESIZE,
  268. MMERR_OSS_SETSTEREO,
  269. MMERR_OSS_SETSPEED,
  270. MMERR_SGI_SPEED,
  271. MMERR_SGI_16BIT,
  272. MMERR_SGI_8BIT,
  273. MMERR_SGI_STEREO,
  274. MMERR_SGI_MONO,
  275. MMERR_SUN_INIT,
  276. MMERR_OS2_MIXSETUP,
  277. MMERR_OS2_SEMAPHORE,
  278. MMERR_OS2_TIMER,
  279. MMERR_OS2_THREAD,
  280. MMERR_DS_PRIORITY,
  281. MMERR_DS_BUFFER,
  282. MMERR_DS_FORMAT,
  283. MMERR_DS_NOTIFY,
  284. MMERR_DS_EVENT,
  285. MMERR_DS_THREAD,
  286. MMERR_DS_UPDATE,
  287. MMERR_WINMM_HANDLE,
  288. MMERR_WINMM_ALLOCATED,
  289. MMERR_WINMM_DEVICEID,
  290. MMERR_WINMM_FORMAT,
  291. MMERR_WINMM_UNKNOWN,
  292. MMERR_MAC_SPEED,
  293. MMERR_MAC_START,
  294. MMERR_MAX
  295. );
  296. PMODULE = ^TMODULE;
  297. TMODULE = record
  298. (* general module information *)
  299. //CHAR* songname; (* name of the song *)
  300. //CHAR* modtype; (* string type of module loaded *)
  301. //CHAR* comment; (* module comments *)
  302. //UWORD flags; (* See module flags above *)
  303. //UBYTE numchn; (* number of module channels *)
  304. //UBYTE numvoices; (* max # voices used for full NNA playback *)
  305. //UWORD numpos; (* number of positions in this song *)
  306. //UWORD numpat; (* number of patterns in this song *)
  307. //UWORD numins; (* number of instruments *)
  308. //UWORD numsmp; (* number of samples *)
  309. //type = record INSTRUMENT* instruments; (* all instruments *)
  310. //type = record SAMPLE* samples; (* all samples *)
  311. //UBYTE realchn; (* real number of channels used *)
  312. //UBYTE totalchn; (* total number of channels used (incl NNAs) *)
  313. (* playback settings *)
  314. //UWORD reppos; (* restart position *)
  315. //UBYTE initspeed; (* initial song speed *)
  316. //UWORD inittempo; (* initial song tempo *)
  317. //UBYTE initvolume; (* initial global volume (0 - 128) *)
  318. //UWORD panning : array[ 0..64- 1 ] of ; (* 64 panning positions *)
  319. //UBYTE chanvol : array[ 0..64- 1 ] of ; (* 64 channel positions *)
  320. //UWORD bpm; (* current beats-per-minute speed *)
  321. //UWORD sngspd; (* current song speed *)
  322. //SWORD volume; (* song volume (0-128) (or user volume) *)
  323. //BOOL extspd; (* extended speed flag (default enabled) *)
  324. //BOOL panflag; (* panning flag (default enabled) *)
  325. //BOOL wrap; (* wrap module ? (default disabled) *)
  326. //BOOL loop; (* allow module to loop ? (default enabled) *)
  327. //BOOL fadeout; (* volume fade out during last pattern *)
  328. //UWORD patpos; (* current row number *)
  329. //SWORD sngpos; (* current song position *)
  330. //ULONG sngtime; (* current song time in 2^-10 seconds *)
  331. //SWORD relspd; (* relative speed factor *)
  332. (* internal module representation *)
  333. //UWORD numtrk; (* number of tracks *)
  334. //UBYTE** tracks; (* array of numtrk pointers to tracks *)
  335. //UWORD* patterns; (* array of Patterns *)
  336. //UWORD* pattrows; (* array of number of rows for each pattern *)
  337. //UWORD* positions; (* all positions *)
  338. //BOOL forbid; (* if true, no player updatenot *)
  339. //UWORD numrow; (* number of rows on current pattern *)
  340. //UWORD vbtick; (* tick counter (counts from 0 to sngspd) *)
  341. //UWORD sngremainder;(* used for song time computation *)
  342. //type = record MP_CONTROL* control; (* Effects Channel info (size pf.numchn) *)
  343. //type = record MP_VOICE* voice; (* Audio Voice information (size md_numchn) *)
  344. //UBYTE globalslide; (* global volume slide rate *)
  345. //UBYTE pat_repcrazy;(* module has just looped to position -1 *)
  346. //UWORD patbrk; (* position where to start a new pattern *)
  347. //UBYTE patdly; (* patterndelay counter (command memory) *)
  348. //UBYTE patdly2; (* patterndelay counter (real one) *)
  349. //SWORD posjmp; (* flag to indicate a jump is needed... *)
  350. end;
  351. PUNIMOD = ^TUNIMOD;
  352. TUNIMOD = TMODULE;
  353. //SDL_mixer.h types
  354. { The internal format for an audio chunk }
  355. PMix_Chunk = ^TMix_Chunk;
  356. TMix_Chunk = record
  357. allocated : integer;
  358. abuf : PUint8;
  359. alen : Uint32;
  360. volume : Uint8; { Per-sample volume, 0-128 }
  361. end;
  362. Mix_Chunk = TMix_Chunk;
  363. { The different fading types supported }
  364. TMix_Fading = (
  365. MIX_NO_FADING,
  366. MIX_FADING_OUT,
  367. MIX_FADING_IN
  368. );
  369. Mix_Fading = TMix_Fading;
  370. TMusic = ( MUS_CMD,
  371. MUS_WAV,
  372. MUS_MOD,
  373. MUS_MID,
  374. MUS_OGG,
  375. MUS_MP3
  376. );
  377. TMusicUnion = record
  378. case Byte of
  379. 0 : ( cmd : PMusicCMD );
  380. 1 : ( wave : PWAVStream );
  381. 2 : ( module : PUNIMOD );
  382. 3 : ( midi : TMidiSong );
  383. 4 : ( ogg : POGG_music );
  384. {$IFNDEF DARWIN}
  385. 5 : ( mp3 : PSMPEG );
  386. {$ENDIF}
  387. end;
  388. P_Mix_Music = ^T_Mix_Music;
  389. T_Mix_Music = record
  390. type_ : TMusic;
  391. data : TMusicUnion;
  392. fading : TMix_Fading;
  393. fade_volume : integer;
  394. fade_step : integer;
  395. fade_steps : integer;
  396. error : integer;
  397. end;
  398. { The internal format for a music chunk interpreted via mikmod }
  399. PMix_Music = ^TMix_Music;
  400. TMix_Music = T_Mix_Music;
  401. {$IFNDEF __GPC__}
  402. TMixFunction = function( udata : Pointer; stream : PUint8; len : integer ) : Pointer; cdecl;
  403. {$ELSE}
  404. TMixFunction = function( udata : Pointer; stream : PUint8; len : integer ) : Pointer;
  405. {$ENDIF}
  406. { This macro can be used to fill a version structure with the compile-time
  407. version of the SDL_mixer library. }
  408. procedure SDL_MIXER_VERSION(var X: TSDL_Version);
  409. {$EXTERNALSYM SDL_MIXER_VERSION}
  410. { This function gets the version of the dynamically linked SDL_mixer library.
  411. It should NOT be used to fill a version structure, instead you should use the
  412. SDL_MIXER_VERSION() macro. }
  413. function Mix_Linked_Version : PSDL_version;
  414. cdecl; external {$IFDEF __GPC__}name 'Mix_Linked_Version'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  415. {$EXTERNALSYM Mix_Linked_Version}
  416. { Open the mixer with a certain audio format }
  417. function Mix_OpenAudio( frequency : integer; format : Uint16; channels :
  418. integer; chunksize : integer ) : integer;
  419. cdecl; external {$IFDEF __GPC__}name 'Mix_OpenAudio'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  420. {$EXTERNALSYM Mix_OpenAudio}
  421. { Dynamically change the number of channels managed by the mixer.
  422. If decreasing the number of channels, the upper channels are
  423. stopped.
  424. This function returns the new number of allocated channels.
  425. }
  426. function Mix_AllocateChannels( numchannels : integer ) : integer;
  427. cdecl; external {$IFDEF __GPC__}name 'Mix_AllocateChannels'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  428. {$EXTERNALSYM Mix_AllocateChannels}
  429. { Find out what the actual audio device parameters are.
  430. This function returns 1 if the audio has been opened, 0 otherwise.
  431. }
  432. function Mix_QuerySpec( var frequency : integer; var format : Uint16; var channels : integer ) : integer;
  433. cdecl; external {$IFDEF __GPC__}name 'Mix_QuerySpec'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  434. {$EXTERNALSYM Mix_QuerySpec}
  435. { Load a wave file or a music (.mod .s3m .it .xm) file }
  436. function Mix_LoadWAV_RW( src : PSDL_RWops; freesrc : integer ) : PMix_Chunk;
  437. cdecl; external {$IFDEF __GPC__}name 'Mix_LoadWAV_RW'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  438. {$EXTERNALSYM Mix_LoadWAV_RW}
  439. function Mix_LoadWAV( filename : PChar ) : PMix_Chunk;
  440. function Mix_LoadMUS( const filename : PChar ) : PMix_Music;
  441. cdecl; external {$IFDEF __GPC__}name 'Mix_LoadMUS'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  442. {$EXTERNALSYM Mix_LoadMUS}
  443. (*#if 0 { This hasn't been hooked into music.c yet }
  444. { Load a music file from an SDL_RWop object (MikMod-specific currently)
  445. Matt Campbell ([email protected]) April 2000 }
  446. function Mix_LoadMUS_RW(SDL_RWops *rw) : PMix_Music; cdecl;
  447. #endif*)
  448. { Load a wave file of the mixer format from a memory buffer }
  449. function Mix_QuickLoad_WAV( mem : PUint8 ) : PMix_Chunk;
  450. cdecl; external {$IFDEF __GPC__}name 'Mix_QuickLoad_WAV'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  451. {$EXTERNALSYM Mix_QuickLoad_WAV}
  452. { Free an audio chunk previously loaded }
  453. procedure Mix_FreeChunk( chunk : PMix_Chunk );
  454. cdecl; external {$IFDEF __GPC__}name 'Mix_FreeChunk'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  455. {$EXTERNALSYM Mix_FreeChunk}
  456. procedure Mix_FreeMusic( music : PMix_Music );
  457. cdecl; external {$IFDEF __GPC__}name 'Mix_FreeMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  458. {$EXTERNALSYM Mix_FreeMusic}
  459. { Set a function that is called after all mixing is performed.
  460. This can be used to provide real-time visual display of the audio stream
  461. or add a custom mixer filter for the stream data.
  462. }
  463. procedure Mix_SetPostMix( mix_func : TMixFunction; arg : Pointer );
  464. cdecl; external {$IFDEF __GPC__}name 'Mix_SetPostMix'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  465. {$EXTERNALSYM Mix_SetPostMix}
  466. { Add your own music player or additional mixer function.
  467. If 'mix_func' is NULL, the default music player is re-enabled.
  468. }
  469. procedure Mix_HookMusic( mix_func : TMixFunction; arg : Pointer );
  470. cdecl; external {$IFDEF __GPC__}name 'Mix_HookMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  471. {$EXTERNALSYM Mix_HookMusic}
  472. { Add your own callback when the music has finished playing.
  473. }
  474. procedure Mix_HookMusicFinished( music_finished : Pointer );
  475. cdecl; external {$IFDEF __GPC__}name 'Mix_HookMusicFinished'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  476. {$EXTERNALSYM Mix_HookMusicFinished}
  477. { Get a pointer to the user data for the current music hook }
  478. function Mix_GetMusicHookData : Pointer;
  479. cdecl; external {$IFDEF __GPC__}name 'Mix_GetMusicHookData'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  480. {$EXTERNALSYM Mix_GetMusicHookData}
  481. {* Add your own callback when a channel has finished playing. NULL
  482. * to disable callback.*}
  483. type
  484. {$IFNDEF __GPC__}
  485. TChannel_finished = procedure( channel: Integer ); cdecl;
  486. {$ELSE}
  487. TChannel_finished = procedure( channel: Integer );
  488. {$ENDIF}
  489. procedure Mix_ChannelFinished( channel_finished : TChannel_finished );
  490. cdecl; external {$IFDEF __GPC__}name 'Mix_ChannelFinished'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  491. {$EXTERNALSYM Mix_ChannelFinished}
  492. const
  493. MIX_CHANNEL_POST = -2;
  494. {* This is the format of a special effect callback:
  495. *
  496. * myeffect(int chan, void *stream, int len, void *udata);
  497. *
  498. * (chan) is the channel number that your effect is affecting. (stream) is
  499. * the buffer of data to work upon. (len) is the size of (stream), and
  500. * (udata) is a user-defined bit of data, which you pass as the last arg of
  501. * Mix_RegisterEffect(), and is passed back unmolested to your callback.
  502. * Your effect changes the contents of (stream) based on whatever parameters
  503. * are significant, or just leaves it be, if you prefer. You can do whatever
  504. * you like to the buffer, though, and it will continue in its changed state
  505. * down the mixing pipeline, through any other effect functions, then finally
  506. * to be mixed with the rest of the channels and music for the final output
  507. * stream.
  508. *}
  509. type
  510. {$IFNDEF __GPC__}
  511. TMix_EffectFunc = function( chan : integer; stream : Pointer; len : integer; udata : Pointer ) : Pointer; cdecl;
  512. {$ELSE}
  513. TMix_EffectFunc = function( chan : integer; stream : Pointer; len : integer; udata : Pointer ) : Pointer;
  514. {$ENDIF}
  515. {*
  516. * This is a callback that signifies that a channel has finished all its
  517. * loops and has completed playback. This gets called if the buffer
  518. * plays out normally, or if you call Mix_HaltChannel(), implicitly stop
  519. * a channel via Mix_AllocateChannels(), or unregister a callback while
  520. * it's still playing.
  521. *}
  522. {$IFNDEF __GPC__}
  523. TMix_EffectDone = function( chan : integer; udata : Pointer ) : Pointer; cdecl;
  524. {$ELSE}
  525. TMix_EffectDone = function( chan : integer; udata : Pointer ) : Pointer;
  526. {$ENDIF}
  527. {* Register a special effect function. At mixing time, the channel data is
  528. * copied into a buffer and passed through each registered effect function.
  529. * After it passes through all the functions, it is mixed into the final
  530. * output stream. The copy to buffer is performed once, then each effect
  531. * function performs on the output of the previous effect. Understand that
  532. * this extra copy to a buffer is not performed if there are no effects
  533. * registered for a given chunk, which saves CPU cycles, and any given
  534. * effect will be extra cycles, too, so it is crucial that your code run
  535. * fast. Also note that the data that your function is given is in the
  536. * format of the sound device, and not the format you gave to Mix_OpenAudio(),
  537. * although they may in reality be the same. This is an unfortunate but
  538. * necessary speed concern. Use Mix_QuerySpec() to determine if you can
  539. * handle the data before you register your effect, and take appropriate
  540. * actions.
  541. * You may also specify a callback (Mix_EffectDone_t) that is called when
  542. * the channel finishes playing. This gives you a more fine-grained control
  543. * than Mix_ChannelFinished(), in case you need to free effect-specific
  544. * resources, etc. If you don't need this, you can specify NULL.
  545. * You may set the callbacks before or after calling Mix_PlayChannel().
  546. * Things like Mix_SetPanning() are just internal special effect functions,
  547. * so if you are using that, you've already incurred the overhead of a copy
  548. * to a separate buffer, and that these effects will be in the queue with
  549. * any functions you've registered. The list of registered effects for a
  550. * channel is reset when a chunk finishes playing, so you need to explicitly
  551. * set them with each call to Mix_PlayChannel*().
  552. * You may also register a special effect function that is to be run after
  553. * final mixing occurs. The rules for these callbacks are identical to those
  554. * in Mix_RegisterEffect, but they are run after all the channels and the
  555. * music have been mixed into a single stream, whereas channel-specific
  556. * effects run on a given channel before any other mixing occurs. These
  557. * global effect callbacks are call "posteffects". Posteffects only have
  558. * their Mix_EffectDone_t function called when they are unregistered (since
  559. * the main output stream is never "done" in the same sense as a channel).
  560. * You must unregister them manually when you've had enough. Your callback
  561. * will be told that the channel being mixed is (MIX_CHANNEL_POST) if the
  562. * processing is considered a posteffect.
  563. *
  564. * After all these effects have finished processing, the callback registered
  565. * through Mix_SetPostMix() runs, and then the stream goes to the audio
  566. * device.
  567. *
  568. * returns zero if error (no such channel), nonzero if added.
  569. * Error messages can be retrieved from Mix_GetError().
  570. *}
  571. function Mix_RegisterEffect( chan : integer; f : TMix_EffectFunc; d : TMix_EffectDone; arg : Pointer ) : integer;
  572. cdecl; external {$IFDEF __GPC__}name 'Mix_RegisterEffect'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  573. {$EXTERNALSYM Mix_RegisterEffect}
  574. {* You may not need to call this explicitly, unless you need to stop an
  575. * effect from processing in the middle of a chunk's playback.
  576. * Posteffects are never implicitly unregistered as they are for channels,
  577. * but they may be explicitly unregistered through this function by
  578. * specifying MIX_CHANNEL_POST for a channel.
  579. * returns zero if error (no such channel or effect), nonzero if removed.
  580. * Error messages can be retrieved from Mix_GetError().
  581. *}
  582. function Mix_UnregisterEffect( channel : integer; f : TMix_EffectFunc ) : integer;
  583. cdecl; external {$IFDEF __GPC__}name 'Mix_UnregisterEffect'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  584. {$EXTERNALSYM Mix_UnregisterEffect}
  585. {* You may not need to call this explicitly, unless you need to stop all
  586. * effects from processing in the middle of a chunk's playback. Note that
  587. * this will also shut off some internal effect processing, since
  588. * Mix_SetPanning( ) and others may use this API under the hood.This is
  589. * called internally when a channel completes playback.
  590. * Posteffects are never implicitly unregistered as they are for channels,
  591. * but they may be explicitly unregistered through this function by
  592. * specifying MIX_CHANNEL_POST for a channel.
  593. * returns zero if error( no such channel ), nonzero if all effects removed.
  594. * Error messages can be retrieved from Mix_GetError( ).
  595. *}
  596. function Mix_UnregisterAllEffects( channel : integer ) : integer;
  597. cdecl; external {$IFDEF __GPC__}name 'Mix_UnregisterAllEffects'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  598. {$EXTERNALSYM Mix_UnregisterAllEffects}
  599. const
  600. MIX_EFFECTSMAXSPEED = 'MIX_EFFECTSMAXSPEED';
  601. {*
  602. * These are the internally - defined mixing effects.They use the same API that
  603. * effects defined in the application use, but are provided here as a
  604. * convenience.Some effects can reduce their quality or use more memory in
  605. * the name of speed; to enable this, make sure the environment variable
  606. * MIX_EFFECTSMAXSPEED( see above ) is defined before you call
  607. * Mix_OpenAudio( ).
  608. * }
  609. {* set the panning of a channel.The left and right channels are specified
  610. * as integers between 0 and 255, quietest to loudest, respectively.
  611. *
  612. * Technically, this is just individual volume control for a sample with
  613. * two( stereo )channels, so it can be used for more than just panning.
  614. * if you want real panning, call it like this :
  615. *
  616. * Mix_SetPanning( channel, left, 255 - left );
  617. *
  618. * ...which isn't so hard.
  619. *
  620. * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
  621. * the panning will be done to the final mixed stream before passing it on
  622. * to the audio device.
  623. *
  624. * This uses the Mix_RegisterEffect( )API internally, and returns without
  625. * registering the effect function if the audio device is not configured
  626. * for stereo output.Setting both( left ) and ( right ) to 255 causes this
  627. * effect to be unregistered, since that is the data's normal state.
  628. *
  629. * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
  630. * nonzero if panning effect enabled.Note that an audio device in mono
  631. * mode is a no - op, but this call will return successful in that case .
  632. * Error messages can be retrieved from Mix_GetError( ).
  633. * }
  634. function Mix_SetPanning( channel : integer; left : Uint8; right : Uint8 ) : integer;
  635. cdecl; external {$IFDEF __GPC__}name 'Mix_SetPanning'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  636. {$EXTERNALSYM Mix_SetPanning}
  637. { * set the position ofa channel.( angle ) is an integer from 0 to 360, that
  638. * specifies the location of the sound in relation to the listener.( angle )
  639. * will be reduced as neccesary( 540 becomes 180 degrees, -100 becomes 260 ).
  640. * Angle 0 is due north, and rotates clockwise as the value increases.
  641. * for efficiency, the precision of this effect may be limited( angles 1
  642. * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
  643. * ( distance ) is an integer between 0 and 255 that specifies the space
  644. * between the sound and the listener.The larger the number, the further
  645. * away the sound is .Using 255 does not guarantee that the channel will be
  646. * culled from the mixing process or be completely silent.For efficiency,
  647. * the precision of this effect may be limited( distance 0 through 5 might
  648. * all produce the same effect, 6 through 10 are equal, etc ).Setting( angle )
  649. * and ( distance ) to 0 unregisters this effect, since the data would be
  650. * unchanged.
  651. *
  652. * if you need more precise positional audio, consider using OpenAL for
  653. * spatialized effects instead of SDL_mixer.This is only meant to be a
  654. * basic effect for simple "3D" games.
  655. *
  656. * if the audio device is configured for mono output, then you won't get
  657. * any effectiveness from the angle; however, distance attenuation on the
  658. * channel will still occur.While this effect will function with stereo
  659. * voices, it makes more sense to use voices with only one channel of sound,
  660. * so when they are mixed through this effect, the positioning will sound
  661. * correct.You can convert them to mono through SDL before giving them to
  662. * the mixer in the first place if you like.
  663. *
  664. * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
  665. * the positioning will be done to the final mixed stream before passing it
  666. * on to the audio device.
  667. *
  668. * This is a convenience wrapper over Mix_SetDistance( ) and Mix_SetPanning( ).
  669. *
  670. * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
  671. * nonzero if position effect is enabled.
  672. * Error messages can be retrieved from Mix_GetError( ).
  673. * }
  674. function Mix_SetPosition( channel :integer; angle : Sint16; distance : Uint8 ) : integer;
  675. cdecl; external {$IFDEF __GPC__}name 'Mix_SetPosition'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  676. {$EXTERNALSYM Mix_SetPosition}
  677. {* set the "distance" of a channel.( distance ) is an integer from 0 to 255
  678. * that specifies the location of the sound in relation to the listener.
  679. * Distance 0 is overlapping the listener, and 255 is as far away as possible
  680. * A distance of 255 does not guarantee silence; in such a case , you might
  681. * want to try changing the chunk's volume, or just cull the sample from the
  682. * mixing process with Mix_HaltChannel( ).
  683. * for efficiency, the precision of this effect may be limited( distances 1
  684. * through 7 might all produce the same effect, 8 through 15 are equal, etc ).
  685. * ( distance ) is an integer between 0 and 255 that specifies the space
  686. * between the sound and the listener.The larger the number, the further
  687. * away the sound is .
  688. * Setting( distance ) to 0 unregisters this effect, since the data would be
  689. * unchanged.
  690. * if you need more precise positional audio, consider using OpenAL for
  691. * spatialized effects instead of SDL_mixer.This is only meant to be a
  692. * basic effect for simple "3D" games.
  693. *
  694. * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
  695. * the distance attenuation will be done to the final mixed stream before
  696. * passing it on to the audio device.
  697. *
  698. * This uses the Mix_RegisterEffect( )API internally.
  699. *
  700. * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
  701. * nonzero if position effect is enabled.
  702. * Error messages can be retrieved from Mix_GetError( ).
  703. * }
  704. function Mix_SetDistance( channel : integer; distance : Uint8 ) : integer;
  705. cdecl; external {$IFDEF __GPC__}name 'Mix_SetDistance'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  706. {$EXTERNALSYM Mix_SetDistance}
  707. { *
  708. * !!! FIXME : Haven't implemented, since the effect goes past the
  709. * end of the sound buffer.Will have to think about this.
  710. * - -ryan.
  711. * /
  712. { if 0
  713. { * Causes an echo effect to be mixed into a sound.( echo ) is the amount
  714. * of echo to mix.0 is no echo, 255 is infinite( and probably not
  715. * what you want ).
  716. *
  717. * Setting( channel ) to MIX_CHANNEL_POST registers this as a posteffect, and
  718. * the reverbing will be done to the final mixed stream before passing it on
  719. * to the audio device.
  720. *
  721. * This uses the Mix_RegisterEffect( )API internally.If you specify an echo
  722. * of zero, the effect is unregistered, as the data is already in that state.
  723. *
  724. * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
  725. * nonzero if reversing effect is enabled.
  726. * Error messages can be retrieved from Mix_GetError( ).
  727. *
  728. extern no_parse_DECLSPEC int Mix_SetReverb( int channel, Uint8 echo );
  729. #E ndif}
  730. { * Causes a channel to reverse its stereo.This is handy if the user has his
  731. * speakers hooked up backwards, or you would like to have a minor bit of
  732. * psychedelia in your sound code. : )Calling this function with ( flip )
  733. * set to non - zero reverses the chunks's usual channels. If (flip) is zero,
  734. * the effect is unregistered.
  735. *
  736. * This uses the Mix_RegisterEffect( )API internally, and thus is probably
  737. * more CPU intensive than having the user just plug in his speakers
  738. * correctly.Mix_SetReverseStereo( )returns without registering the effect
  739. * function if the audio device is not configured for stereo output.
  740. *
  741. * if you specify MIX_CHANNEL_POST for ( channel ), then this the effect is used
  742. * on the final mixed stream before sending it on to the audio device( a
  743. * posteffect ).
  744. *
  745. * returns zero if error( no such channel or Mix_RegisterEffect( )fails ),
  746. * nonzero if reversing effect is enabled.Note that an audio device in mono
  747. * mode is a no - op, but this call will return successful in that case .
  748. * Error messages can be retrieved from Mix_GetError( ).
  749. * }
  750. function Mix_SetReverseStereo( channel : integer; flip : integer ) : integer;
  751. cdecl; external {$IFDEF __GPC__}name 'Mix_SetReverseStereo'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  752. {$EXTERNALSYM Mix_SetReverseStereo}
  753. { end of effects API. - -ryan. *}
  754. { Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate
  755. them dynamically to the next sample if requested with a -1 value below.
  756. Returns the number of reserved channels.
  757. }
  758. function Mix_ReserveChannels( num : integer ) : integer;
  759. cdecl; external {$IFDEF __GPC__}name 'Mix_ReserveChannels'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  760. {$EXTERNALSYM Mix_ReserveChannels}
  761. { Channel grouping functions }
  762. { Attach a tag to a channel. A tag can be assigned to several mixer
  763. channels, to form groups of channels.
  764. If 'tag' is -1, the tag is removed (actually -1 is the tag used to
  765. represent the group of all the channels).
  766. Returns true if everything was OK.
  767. }
  768. function Mix_GroupChannel( which : integer; tag : integer ) : integer;
  769. cdecl; external {$IFDEF __GPC__}name 'Mix_GroupChannel'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  770. {$EXTERNALSYM Mix_GroupChannel}
  771. { Assign several consecutive channels to a group }
  772. function Mix_GroupChannels( from : integer; to_ : integer; tag : integer ) :
  773. integer;
  774. cdecl; external {$IFDEF __GPC__}name 'Mix_GroupChannels'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  775. {$EXTERNALSYM Mix_GroupChannels}
  776. { Finds the first available channel in a group of channels }
  777. function Mix_GroupAvailable( tag : integer ) : integer;
  778. cdecl; external {$IFDEF __GPC__}name 'Mix_GroupAvailable'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  779. {$EXTERNALSYM Mix_GroupAvailable}
  780. { Returns the number of channels in a group. This is also a subtle
  781. way to get the total number of channels when 'tag' is -1
  782. }
  783. function Mix_GroupCount( tag : integer ) : integer;
  784. cdecl; external {$IFDEF __GPC__}name 'Mix_GroupCount'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  785. {$EXTERNALSYM Mix_GroupCount}
  786. { Finds the "oldest" sample playing in a group of channels }
  787. function Mix_GroupOldest( tag : integer ) : integer;
  788. cdecl; external {$IFDEF __GPC__}name 'Mix_GroupOldest'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  789. {$EXTERNALSYM Mix_GroupOldest}
  790. { Finds the "most recent" (i.e. last) sample playing in a group of channels }
  791. function Mix_GroupNewer( tag : integer ) : integer;
  792. cdecl; external {$IFDEF __GPC__}name 'Mix_GroupNewer'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  793. {$EXTERNALSYM Mix_GroupNewer}
  794. { The same as above, but the sound is played at most 'ticks' milliseconds }
  795. function Mix_PlayChannelTimed( channel : integer; chunk : PMix_Chunk; loops : integer; ticks : integer ) : integer;
  796. cdecl; external {$IFDEF __GPC__}name 'Mix_PlayChannelTimed'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  797. {$EXTERNALSYM Mix_PlayChannelTimed}
  798. { Play an audio chunk on a specific channel.
  799. If the specified channel is -1, play on the first free channel.
  800. If 'loops' is greater than zero, loop the sound that many times.
  801. If 'loops' is -1, loop inifinitely (~65000 times).
  802. Returns which channel was used to play the sound.
  803. }
  804. function Mix_PlayChannel( channel : integer; chunk : PMix_Chunk; loops : integer ) : integer;
  805. function Mix_PlayMusic( music : PMix_Music; loops : integer ) : integer;
  806. cdecl; external {$IFDEF __GPC__}name 'Mix_PlayMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  807. {$EXTERNALSYM Mix_PlayMusic}
  808. { Fade in music or a channel over "ms" milliseconds, same semantics as the "Play" functions }
  809. function Mix_FadeInMusic( music : PMix_Music; loops : integer; ms : integer ) : integer;
  810. cdecl; external {$IFDEF __GPC__}name 'Mix_FadeInMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  811. {$EXTERNALSYM Mix_FadeInMusic}
  812. function Mix_FadeInChannelTimed( channel : integer; chunk : PMix_Chunk; loops : integer; ms : integer; ticks : integer ) : integer;
  813. cdecl; external {$IFDEF __GPC__}name 'Mix_FadeInChannelTimed'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  814. {$EXTERNALSYM Mix_FadeInChannelTimed}
  815. function Mix_FadeInChannel( channel : integer; chunk : PMix_Chunk; loops : integer; ms : integer ) : integer;
  816. { Set the volume in the range of 0-128 of a specific channel or chunk.
  817. If the specified channel is -1, set volume for all channels.
  818. Returns the original volume.
  819. If the specified volume is -1, just return the current volume.
  820. }
  821. function Mix_Volume( channel : integer; volume : integer ) : integer;
  822. cdecl; external {$IFDEF __GPC__}name 'Mix_Volume'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  823. {$EXTERNALSYM Mix_Volume}
  824. function Mix_VolumeChunk( chunk : PMix_Chunk; volume : integer ) : integer;
  825. cdecl; external {$IFDEF __GPC__}name 'Mix_VolumeChunk'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  826. {$EXTERNALSYM Mix_VolumeChunk}
  827. function Mix_VolumeMusic( volume : integer ) : integer;
  828. cdecl; external {$IFDEF __GPC__}name 'Mix_VolumeMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  829. {$EXTERNALSYM Mix_VolumeMusic}
  830. { Halt playing of a particular channel }
  831. function Mix_HaltChannel( channel : integer ) : integer;
  832. cdecl; external {$IFDEF __GPC__}name 'Mix_HaltChannel'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  833. {$EXTERNALSYM Mix_HaltChannel}
  834. function Mix_HaltGroup( tag : integer ) : integer;
  835. cdecl; external {$IFDEF __GPC__}name 'Mix_HaltGroup'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  836. {$EXTERNALSYM Mix_HaltGroup}
  837. function Mix_HaltMusic : integer;
  838. cdecl; external {$IFDEF __GPC__}name 'Mix_HaltMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  839. {$EXTERNALSYM Mix_HaltMusic}
  840. { Change the expiration delay for a particular channel.
  841. The sample will stop playing after the 'ticks' milliseconds have elapsed,
  842. or remove the expiration if 'ticks' is -1
  843. }
  844. function Mix_ExpireChannel( channel : integer; ticks : integer ) : integer;
  845. cdecl; external {$IFDEF __GPC__}name 'Mix_ExpireChannel'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  846. {$EXTERNALSYM Mix_ExpireChannel}
  847. { Halt a channel, fading it out progressively till it's silent
  848. The ms parameter indicates the number of milliseconds the fading
  849. will take.
  850. }
  851. function Mix_FadeOutChannel( which : integer; ms : integer ) : integer;
  852. cdecl; external {$IFDEF __GPC__}name 'Mix_FadeOutChannel'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  853. {$EXTERNALSYM Mix_FadeOutChannel}
  854. function Mix_FadeOutGroup( tag : integer; ms : integer ) : integer;
  855. cdecl; external {$IFDEF __GPC__}name 'Mix_FadeOutGroup'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  856. {$EXTERNALSYM Mix_FadeOutGroup}
  857. function Mix_FadeOutMusic( ms : integer ) : integer;
  858. cdecl; external {$IFDEF __GPC__}name 'Mix_FadeOutMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  859. {$EXTERNALSYM Mix_FadeOutMusic}
  860. { Query the fading status of a channel }
  861. function Mix_FadingMusic : TMix_Fading;
  862. cdecl; external {$IFDEF __GPC__}name 'Mix_FadingMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  863. {$EXTERNALSYM Mix_FadingMusic}
  864. function Mix_FadingChannel( which : integer ) : TMix_Fading;
  865. cdecl; external {$IFDEF __GPC__}name 'Mix_FadingChannel'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  866. {$EXTERNALSYM Mix_FadingChannel}
  867. { Pause/Resume a particular channel }
  868. procedure Mix_Pause( channel : integer );
  869. cdecl; external {$IFDEF __GPC__}name 'Mix_Pause'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  870. {$EXTERNALSYM Mix_Pause}
  871. procedure Mix_Resume( channel : integer );
  872. cdecl; external {$IFDEF __GPC__}name 'Mix_Resume'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  873. {$EXTERNALSYM Mix_Resume}
  874. function Mix_Paused( channel : integer ) : integer;
  875. cdecl; external {$IFDEF __GPC__}name 'Mix_Paused'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  876. {$EXTERNALSYM Mix_Paused}
  877. { Pause/Resume the music stream }
  878. procedure Mix_PauseMusic;
  879. cdecl; external {$IFDEF __GPC__}name 'Mix_PauseMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  880. {$EXTERNALSYM Mix_PauseMusic}
  881. procedure Mix_ResumeMusic;
  882. cdecl; external {$IFDEF __GPC__}name 'Mix_ResumeMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  883. {$EXTERNALSYM Mix_ResumeMusic}
  884. procedure Mix_RewindMusic;
  885. cdecl; external {$IFDEF __GPC__}name 'Mix_RewindMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  886. {$EXTERNALSYM Mix_RewindMusic}
  887. function Mix_PausedMusic : integer;
  888. cdecl; external {$IFDEF __GPC__}name 'Mix_PausedMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  889. {$EXTERNALSYM Mix_PausedMusic}
  890. { Set the current position in the music stream.
  891. This returns 0 if successful, or -1 if it failed or isn't implemented.
  892. This function is only implemented for MOD music formats (set pattern
  893. order number) and for OGG music (set position in seconds), at the
  894. moment.
  895. }
  896. function Mix_SetMusicPosition( position : double ) : integer;
  897. cdecl; external {$IFDEF __GPC__}name 'Mix_SetMusicPosition'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  898. {$EXTERNALSYM Mix_SetMusicPosition}
  899. { Check the status of a specific channel.
  900. If the specified channel is -1, check all channels.
  901. }
  902. function Mix_Playing( channel : integer ) : integer;
  903. cdecl; external {$IFDEF __GPC__}name 'Mix_Playing'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  904. {$EXTERNALSYM Mix_Playing}
  905. function Mix_PlayingMusic : integer;
  906. cdecl; external {$IFDEF __GPC__}name 'Mix_PlayingMusic'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  907. {$EXTERNALSYM Mix_PlayingMusic}
  908. { Stop music and set external music playback command }
  909. function Mix_SetMusicCMD( const command : PChar ) : integer;
  910. cdecl; external {$IFDEF __GPC__}name 'Mix_SetMusicCMD'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  911. {$EXTERNALSYM Mix_SetMusicCMD}
  912. { Close the mixer, halting all playing audio }
  913. procedure Mix_CloseAudio;
  914. cdecl; external {$IFDEF __GPC__}name 'Mix_CloseAudio'{$ELSE} SDL_MixerLibName{$ENDIF __GPC__};
  915. {$EXTERNALSYM Mix_CloseAudio}
  916. { We'll use SDL for reporting errors }
  917. procedure Mix_SetError( fmt : PChar );
  918. function Mix_GetError : PChar;
  919. {------------------------------------------------------------------------------}
  920. { initialization }
  921. {------------------------------------------------------------------------------}
  922. {------------------------------------------------------------------------------}
  923. implementation
  924. {$IFDEF __GPC__}
  925. {$L 'sdl_mixer'} { link sdl_mixer.dll.a or libsdl_mixer.so or libsdl_mixer.a }
  926. {$ENDIF}
  927. procedure SDL_MIXER_VERSION( var X : TSDL_version );
  928. begin
  929. X.major := SDL_MIXER_MAJOR_VERSION;
  930. X.minor := SDL_MIXER_MINOR_VERSION;
  931. X.patch := SDL_MIXER_PATCHLEVEL;
  932. end;
  933. function Mix_LoadWAV( filename : PChar ) : PMix_Chunk;
  934. begin
  935. result := Mix_LoadWAV_RW( SDL_RWFromFile( filename, 'rb' ), 1 );
  936. end;
  937. function Mix_PlayChannel( channel : integer; chunk : PMix_Chunk; loops : integer ) : integer;
  938. begin
  939. result := Mix_PlayChannelTimed( channel, chunk, loops, -1 );
  940. end;
  941. function Mix_FadeInChannel( channel : integer; chunk : PMix_Chunk; loops :
  942. integer; ms : integer ) : integer;
  943. begin
  944. result := Mix_FadeInChannelTimed( channel, chunk, loops, ms, -1 );
  945. end;
  946. procedure Mix_SetError( fmt : PChar );
  947. begin
  948. SDL_SetError( fmt );
  949. end;
  950. function Mix_GetError : PChar;
  951. begin
  952. result := SDL_GetError;
  953. end;
  954. end.