DEADSOFTWARE

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