sdl_mixer_nosmpeg.pas 40 KB

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