sdl_mixer_nosmpeg.pas 40 KB

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