DEADSOFTWARE

3c56ea1364d502601566661a389e72112845a69e
[d2df-sdl.git] / src / lib / modplug / modplug.pas
1 {
2 Translation of the libmodplug headers for FreePascal
3 Copyright (C) 2006 by Ivo Steinmann
4 }
6 (*
7 * This source code is public domain.
8 *
9 * Authors: Kenton Varda <temporal@gauge3d.org> (C interface wrapper)
10 *)
12 unit modplug;
14 {$MODE OBJFPC}
15 {$PACKRECORDS C}
17 interface
19 uses
20 ctypes;
22 {$IF DEFINED(WINDOWS)}
23 {$IFDEF MODPLUG_WINDOZE_STATIC}
24 {$LINKLIB libstdc++.a} // is this necessary?
25 {$LINKLIB libmodplug.a}
26 {$ELSE}
27 {$DEFINE MP_DYNAMIC}
28 const modpluglib = 'libmodplug-1.dll';
29 {$ENDIF}
30 {$ELSEIF DEFINED(UNIX)}
31 {$DEFINE MP_DYNAMIC}
32 const modpluglib = 'libmodplug.so';
33 {$ELSE}
34 {$ERROR libmpg123 not supported on this platform. Fix it!}
35 {$ENDIF}
37 type
38 PModPlugFile = Pointer;
39 ModPlugFile = record
40 end;
42 (* Load a mod file. [data] should point to a block of memory containing the complete
43 * file, and [size] should be the size of that block.
44 * Return the loaded mod file on success, or NULL on failure. *)
45 function ModPlug_Load(data: pointer; size: cint): PModPlugFile; cdecl; external {$IFDEF MP_DYNAMIC}modpluglib{$ENDIF};
47 (* Unload a mod file. *)
48 procedure ModPlug_Unload(_file: PModPlugFile); cdecl; external {$IFDEF MP_DYNAMIC}modpluglib{$ENDIF};
50 (* Read sample data into the buffer. Returns the number of bytes read. If the end
51 * of the mod has been reached, zero is returned. *)
52 function ModPlug_Read(_file: PModPlugFile; buffer: pointer; size: cint): cint; cdecl; external {$IFDEF MP_DYNAMIC}modpluglib{$ENDIF};
54 (* Get the name of the mod. The returned buffer is stored within the ModPlugFile
55 * structure and will remain valid until you unload the file. *)
56 function ModPlug_GetName(_file: PModPlugFile): pcchar; cdecl; external {$IFDEF MP_DYNAMIC}modpluglib{$ENDIF};
58 (* Get the length of the mod, in milliseconds. Note that this result is not always
59 * accurate, especially in the case of mods with loops. *)
60 function ModPlug_GetLength(_file: PModPlugFile): cint; cdecl; external {$IFDEF MP_DYNAMIC}modpluglib{$ENDIF};
62 (* Seek to a particular position in the song. Note that seeking and MODs don't mix very
63 * well. Some mods will be missing instruments for a short time after a seek, as ModPlug
64 * does not scan the sequence backwards to find out which instruments were supposed to be
65 * playing at that time. (Doing so would be difficult and not very reliable.) Also,
66 * note that seeking is not very exact in some mods -- especially those for which
67 * ModPlug_GetLength() does not report the full length. *)
68 procedure ModPlug_Seek(_file: PModPlugFile; millisecond: cint); cdecl; external {$IFDEF MP_DYNAMIC}modpluglib{$ENDIF};
71 const
72 // _ModPlug_Flags
73 MODPLUG_ENABLE_OVERSAMPLING = 1 shl 0; (* Enable oversampling (highly recommended) *)
74 MODPLUG_ENABLE_NOISE_REDUCTION = 1 shl 1; (* Enable noise reduction *)
75 MODPLUG_ENABLE_REVERB = 1 shl 2; (* Enable reverb *)
76 MODPLUG_ENABLE_MEGABASS = 1 shl 3; (* Enable megabass *)
77 MODPLUG_ENABLE_SURROUND = 1 shl 4; (* Enable surround sound. *)
79 // _ModPlug_ResamplingMode
80 MODPLUG_RESAMPLE_NEAREST = 0; (* No interpolation (very fast, extremely bad sound quality) *)
81 MODPLUG_RESAMPLE_LINEAR = 1; (* Linear interpolation (fast, good quality) *)
82 MODPLUG_RESAMPLE_SPLINE = 2; (* Cubic spline interpolation (high quality) *)
83 MODPLUG_RESAMPLE_FIR = 3; (* 8-tap fir filter (extremely high quality) *)
85 type
86 PModPlug_Settings = ^ModPlug_Settings;
87 ModPlug_Settings = record
88 mFlags : cint; (* One or more of the MODPLUG_ENABLE_* flags above, bitwise-OR'ed *)
89 mChannels : cint; (* Number of channels - 1 for mono or 2 for stereo *)
90 mBits : cint; (* Bits per sample - 8, 16, or 32 *)
91 mFrequency : cint; (* Sampling rate - 11025, 22050, or 44100 *)
92 mResamplingMode : cint; (* One of MODPLUG_RESAMPLE_*, above *)
93 mStereoSeparation : cint; (* 1-256 *)
94 mMaxMixChannels : cint; (* Maximum number of mixing channels, 32-256 *)
95 mReverbDepth : cint; (* Reverb level 0(quiet)-100(loud) *)
96 mReverbDelay : cint; (* Reverb delay in ms, usually 40-200ms *)
97 mBassAmount : cint; (* XBass level 0(quiet)-100(loud) *)
98 mBassRange : cint; (* XBass cutoff in Hz 10-100 *)
99 mSurroundDepth : cint; (* Surround level 0(quiet)-100(heavy) *)
100 mSurroundDelay : cint; (* Surround delay in ms, usually 5-40ms *)
101 mLoopCount : cint; (* Number of times to loop. Zero prevents looping. -1 loops forever. *)
102 end;
104 (* Get and set the mod decoder settings. All options, except for channels, bits-per-sample,
105 * sampling rate, and loop count, will take effect immediately. Those options which don't
106 * take effect immediately will take effect the next time you load a mod. *)
107 procedure ModPlug_GetSettings(settings: PModPlug_Settings); cdecl; external {$IFDEF MP_DYNAMIC}modpluglib{$ENDIF};
108 procedure ModPlug_SetSettings(const settings: PModPlug_Settings); cdecl; external {$IFDEF MP_DYNAMIC}modpluglib{$ENDIF};
110 implementation
112 // TODO: why the fuck does this exist here
114 (*
116 function cppNew(s: cint): pointer; cdecl; public; alias : '_Znaj'; alias : '_Znwj';
117 begin
118 GetMem(Result, s);
119 end;
121 procedure cppDelete(p: pointer); cdecl; public; alias : '_ZdlPv'; alias : '_ZdaPv';
122 begin
123 FreeMem(p);
124 end;
126 *)
128 end.