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