DEADSOFTWARE

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