sdl_mixer_nosmpeg.pas 40 KB

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