sdl_mixer.pas 49 KB

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