10 {$IF DEFINED(WINDOWS)}
11 {$IFDEF LIBXMP_WINDOZE_STATIC}
13 {$LINKLIB libxmp-lite.a}
20 const xmplib
= 'libxmp-lite.dll';
22 const xmplib
= 'libxmp.dll';
25 {$ELSEIF DEFINED(UNIX)}
29 const xmplib
= 'libxmp-lite.so';
31 const xmplib
= 'libxmp.so';
34 {$ERROR libxmp not supported on this platform. Fix it!}
38 XMP_VER_STRING
= '4.4.1';
39 XMP_VER_CODE
= $040401;
45 XMP_NAME_SIZE
= 64; (* Size of module name and type *)
46 XMP_KEY_OFF
= $81; (* Note number for key off event *)
47 XMP_KEY_CUT
= $82; (* Note number for key cut event *)
48 XMP_KEY_FADE
= $83; (* Note number for fade event *)
49 (* mixer parameter macros *)
50 (* sample format flags *)
51 XMP_FORMAT_8BIT
= (1 shl 0); (* Mix to 8-bit instead of 16 *)
52 XMP_FORMAT_UNSIGNED
= (1 shl 1); (* Mix to unsigned samples *)
53 XMP_FORMAT_MONO
= (1 shl 2); (* Mix to mono instead of stereo *)
54 (* player parameters *)
55 XMP_PLAYER_AMP
= 0; (* Amplification factor *)
56 XMP_PLAYER_MIX
= 1; (* Stereo mixing *)
57 XMP_PLAYER_INTERP
= 2; (* Interpolation type *)
58 XMP_PLAYER_DSP
= 3; (* DSP effect flags *)
59 XMP_PLAYER_FLAGS
= 4; (* Player flags *)
60 XMP_PLAYER_CFLAGS
= 5; (* Player flags for current module *)
61 XMP_PLAYER_SMPCTL
= 6; (* Sample control flags *)
62 XMP_PLAYER_VOLUME
= 7; (* Player module volume *)
63 XMP_PLAYER_STATE
= 8; (* Internal player state (read only) *)
64 XMP_PLAYER_SMIX_VOLUME
= 9; (* SMIX volume *)
65 XMP_PLAYER_DEFPAN
= 10; (* Default pan setting *)
66 XMP_PLAYER_MODE
= 11; (* Player personality *)
67 XMP_PLAYER_MIXER_TYPE
= 12; (* Current mixer (read only) *)
68 XMP_PLAYER_VOICES
= 13; (* Maximum number of mixer voices *)
69 (* interpolation types *)
70 XMP_INTERP_NEAREST
= 0; (* Nearest neighbor *)
71 XMP_INTERP_LINEAR
= 1; (* Linear (default) *)
72 XMP_INTERP_SPLINE
= 2; (* Cubic spline *)
73 (* dsp effect types *)
74 XMP_DSP_LOWPASS
= (1 shl 0); (* Lowpass filter effect *)
75 XMP_DSP_ALL
= (XMP_DSP_LOWPASS
);
77 XMP_STATE_UNLOADED
= 0; (* Context created *)
78 XMP_STATE_LOADED
= 1; (* Module loaded *)
79 XMP_STATE_PLAYING
= 2; (* Module playing *)
81 XMP_FLAGS_VBLANK
= (1 shl 0); (* Use vblank timing *)
82 XMP_FLAGS_FX9BUG
= (1 shl 1); (* Emulate FX9 bug *)
83 XMP_FLAGS_FIXLOOP
= (1 shl 2); (* Emulate sample loop bug *)
84 XMP_FLAGS_A500
= (1 shl 3); (* Use Paula mixer in Amiga modules *)
86 XMP_MODE_AUTO
= 0; (* Autodetect mode (default) *)
87 XMP_MODE_MOD
= 1; (* Play as a generic MOD player *)
88 XMP_MODE_NOISETRACKER
= 2; (* Play using Noisetracker quirks *)
89 XMP_MODE_PROTRACKER
= 3; (* Play using Protracker quirks *)
90 XMP_MODE_S3M
= 4; (* Play as a generic S3M player *)
91 XMP_MODE_ST3
= 5; (* Play using ST3 bug emulation *)
92 XMP_MODE_ST3GUS
= 6; (* Play using ST3+GUS quirks *)
93 XMP_MODE_XM
= 7; (* Play as a generic XM player *)
94 XMP_MODE_FT2
= 8; (* Play using FT2 bug emulation *)
95 XMP_MODE_IT
= 9; (* Play using IT quirks *)
96 XMP_MODE_ITSMP
= 10; (* Play using IT sample mode quirks *)
98 XMP_MIXER_STANDARD
= 0; (* Standard mixer *)
99 XMP_MIXER_A500
= 1; (* Amiga 500 *)
100 XMP_MIXER_A500F
= 2; (* Amiga 500 with led filter *)
102 XMP_SMPCTL_SKIP
= (1 shl 0); (* Don't load samples *)
104 XMP_MAX_KEYS
= 121; (* Number of valid keys *)
105 XMP_MAX_ENV_POINTS
= 32; (* Max number of envelope points *)
106 XMP_MAX_MOD_LENGTH
= 256; (* Max number of patterns in module *)
107 XMP_MAX_CHANNELS
= 64; (* Max number of channels in module *)
108 XMP_MAX_SRATE
= 49170; (* max sampling rate (Hz) *)
109 XMP_MIN_SRATE
= 4000; (* min sampling rate (Hz) *)
110 XMP_MIN_BPM
= 20; (* min BPM *)
111 (* frame rate = (50 * bpm / 125) Hz *)
112 (* frame size = (sampling rate * channels * size) / frame rate *)
113 XMP_MAX_FRAMESIZE
= (5*XMP_MAX_SRATE
*2 div XMP_MIN_BPM
);
116 XMP_ERROR_INTERNAL
= 2; (* Internal error *)
117 XMP_ERROR_FORMAT
= 3; (* Unsupported module format *)
118 XMP_ERROR_LOAD
= 4; (* Error loading file *)
119 XMP_ERROR_DEPACK
= 5; (* Error depacking file *)
120 XMP_ERROR_SYSTEM
= 6; (* System error *)
121 XMP_ERROR_INVALID
= 7; (* Invalid parameter *)
122 XMP_ERROR_STATE
= 8; (* Invalid player state *)
125 XMP_CHANNEL_SYNTH
= (1 shl 0); (* Channel is synthesized *)
126 XMP_CHANNEL_MUTED
= (1 shl 1); (* Channel is muted *)
127 XMP_CHANNEL_SPLIT
= (1 shl 2); (* Split Amiga channel in bits 5-4 *)
128 XMP_CHANNEL_SURROUND
= (1 shl 4); (* Surround channel *)
131 XMP_ENVELOPE_ON
= (1 shl 0); (* Envelope is enabled *)
132 XMP_ENVELOPE_SUS
= (1 shl 1); (* Envelope has sustain point *)
133 XMP_ENVELOPE_LOOP
= (1 shl 2); (* Envelope has loop *)
134 XMP_ENVELOPE_FLT
= (1 shl 3); (* Envelope is used for filter *)
135 XMP_ENVELOPE_SLOOP
= (1 shl 4); (* Envelope has sustain loop *)
136 XMP_ENVELOPE_CARRY
= (1 shl 5); (* Don't reset envelope position *)
139 XMP_INST_NNA_CUT
= $00;
140 XMP_INST_NNA_CONT
= $01;
141 XMP_INST_NNA_OFF
= $02;
142 XMP_INST_NNA_FADE
= $03;
143 XMP_INST_DCT_OFF
= $00;
144 XMP_INST_DCT_NOTE
= $01;
145 XMP_INST_DCT_SMP
= $02;
146 XMP_INST_DCT_INST
= $03;
147 XMP_INST_DCA_CUT
= XMP_INST_NNA_CUT
;
148 XMP_INST_DCA_OFF
= XMP_INST_NNA_OFF
;
149 XMP_INST_DCA_FADE
= XMP_INST_NNA_FADE
;
152 XMP_SAMPLE_16BIT
= (1 shl 0); (* 16bit sample *)
153 XMP_SAMPLE_LOOP
= (1 shl 1); (* Sample is looped *)
154 XMP_SAMPLE_LOOP_BIDIR
= (1 shl 2); (* Bidirectional sample loop *)
155 XMP_SAMPLE_LOOP_REVERSE
= (1 shl 3); (* Backwards sample loop *)
156 XMP_SAMPLE_LOOP_FULL
= (1 shl 4); (* Play full sample before looping *)
157 XMP_SAMPLE_SLOOP
= (1 shl 5); (* Sample has sustain loop *)
158 XMP_SAMPLE_SLOOP_BIDIR
= (1 shl 6); (* Bidirectional sustain loop *)
159 XMP_SAMPLE_SYNTH
= (1 shl 15); (* Data contains synth patch *)
163 pan
: longint; (* Channel pan (0x80 is center) *)
164 vol
: longint; (* Channel volume *)
165 flg
: longint; (* Channel flags *)
169 rows
: longint; (* Number of rows *)
170 index
: array [0..0] of longint; (* Track index *)
174 note
: byte; (* Note number (0 means no note) *)
175 ins
: byte; (* Patch number *)
176 vol
: byte; (* Volume (0 to basevol) *)
177 fxt
: byte; (* Effect type *)
178 fxp
: byte; (* Effect parameter *)
179 f2t
: byte; (* Secondary effect type *)
180 f2p
: byte; (* Secondary effect parameter *)
181 _flag
: byte; (* Internal (reserved) flags *)
184 pxmp_event
= ^xmp_event
;
187 rows
: longint; (* Number of rows *)
188 event
: array [0..0] of xmp_event
; (* Event data *)
191 xmp_envelope
= record
192 flg
: longint; (* Flags *)
193 npt
: longint; (* Number of envelope points *)
194 scl
: longint; (* Envelope scaling *)
195 sus
: longint; (* Sustain start point *)
196 sue
: longint; (* Sustain end point *)
197 lps
: longint; (* Loop start point *)
198 lpe
: longint; (* Loop end point *)
199 data
: array [0..(XMP_MAX_ENV_POINTS
*2)-1] of smallint
;
202 xmp_subinstrument
= record
203 vol
: longint; (* Default volume *)
204 gvl
: longint; (* Global volume *)
205 pan
: longint; (* Pan *)
206 xpo
: longint; (* Transpose *)
207 fin
: longint; (* Finetune *)
208 vwf
: longint; (* Vibrato waveform *)
209 vde
: longint; (* Vibrato depth *)
210 vra
: longint; (* Vibrato rate *)
211 vsw
: longint; (* Vibrato sweep *)
212 rvv
: longint; (* Random volume/pan variation (IT) *)
213 sid
: longint; (* Sample number *)
214 nna
: longint; (* New note action *)
215 dct
: longint; (* Duplicate check type *)
216 dca
: longint; (* Duplicate check action *)
217 ifc
: longint; (* Initial filter cutoff *)
218 ifr
: longint; (* Initial filter resonance *)
221 pxmp_subinstrument
= ^xmp_subinstrument
;
223 xmp_instrument
= record
224 name
: array [0..31] of char; (* Instrument name *)
225 vol
: longint; (* Instrument volume *)
226 nsm
: longint; (* Number of samples *)
227 rls
: longint; (* Release (fadeout) *)
228 aei
: xmp_envelope
; (* Amplitude envelope info *)
229 pei
: xmp_envelope
; (* Pan envelope info *)
230 fei
: xmp_envelope
; (* Frequency envelope info *)
231 map
: array[0..(XMP_MAX_KEYS
)-1] of record
235 sub
: pxmp_subinstrument
;
240 name
: array [0..31] of char; (* Sample name *)
241 len
: longint; (* Sample length *)
242 lps
: longint; (* Loop start *)
243 lpe
: longint; (* Loop end *)
244 flg
: longint; (* Flags *)
245 data
: pbyte
; (* Sample data *)
248 xmp_sequence
= record
249 entry_point
: longint;
253 pxmp_sequence
= ^xmp_sequence
;
256 name
: array [0..XMP_NAME_SIZE
-1] of char; (* Module title *)
257 format
: array [0..XMP_NAME_SIZE
-1] of char; (* Module format *)
259 pat
: longint; (* Number of patterns *)
260 trk
: longint; (* Number of tracks *)
261 chn
: longint; (* Tracks per pattern *)
262 ins
: longint; (* Number of instruments *)
263 smp
: longint; (* Number of samples *)
264 spd
: longint; (* Initial speed *)
265 bpm
: longint; (* Initial BPM *)
266 len
: longint; (* Module length in patterns *)
267 rst
: longint; (* Restart position *)
268 gvl
: longint; (* Global volume *)
270 xxp
: pointer; // xmp_pattern**
271 xxt
: pointer; // xmp_track**
272 xxi
: pointer; // xmp_instrument*
273 xxs
: pointer; // xmp_sample*
274 xxc
: array [0..XMP_MAX_CHANNELS
-1] of xmp_channel
;
275 xxo
: array [0..XMP_MAX_MOD_LENGTH
-1] of byte;
278 pxmp_module
= ^xmp_module
;
280 xmp_test_info
= record
281 name
: array [0..XMP_NAME_SIZE
-1] of char; (* Module title *)
282 format
: array [0..XMP_NAME_SIZE
-1] of char; (* Module format *)
285 xmp_module_info
= record
286 md5
: array [0..15] of byte; (* MD5 message digest *)
287 vol_base
: longint; (* Volume scale *)
288 module
: pxmp_module
; (* Pointer to module data *)
289 comment
: pchar
; (* Comment text, if any *)
290 num_sequences
: longint; (* Number of valid sequences *)
291 seq_data
: pxmp_sequence
; (* Pointer to sequence data *)
294 xmp_channel_info
= record
295 period
: longword
; (* Sample period (times 4096) *)
296 position
: longword
; (* Sample position *)
297 pitchbend
: word; (* Linear bend from base note*)
298 note
: byte; (* Current base note number *)
299 instrument
: byte; (* Current instrument number *)
300 usample
: byte; (* Current sample number *)
301 volume
: byte; (* Current volume *)
302 pan
: byte; (* Current stereo pan *)
303 reserved
: byte; (* Reserved *)
304 event
: xmp_event
; (* Current track event *)
307 (* Current frame information *)
308 xmp_frame_info
= record
309 pos
: longint; (* Current position *)
310 pattern
: longint; (* Current pattern *)
311 row
: longint; (* Current row in pattern *)
312 num_rows
: longint; (* Number of rows in current pattern *)
313 frame
: longint; (* Current frame *)
314 speed
: longint; (* Current replay speed *)
315 bpm
: longint; (* Current bpm *)
316 time
: longint; (* Current module time in ms *)
317 total_time
: longint; (* Estimated replay time in ms*)
318 frame_time
: longint; (* Frame replay time in us *)
319 buffer
: plongint
; (* Pointer to sound buffer *)
320 buffer_size
: longint; (* Used buffer size *)
321 total_size
: longint; (* Total buffer size *)
322 volume
: longint; (* Current master volume *)
323 loop_count
: longint; (* Loop counter *)
324 virt_channels
: longint; (* Number of virtual channels *)
325 virt_used
: longint; (* Used virtual channels *)
326 sequence
: longint; (* Current sequence *)
327 channel_info
: array [0..XMP_MAX_CHANNELS
-1] of xmp_channel_info
;
330 xmp_context
= pointer;
333 xmp_version
: pchar
; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
334 xmp_vercode
: longword
; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
336 function xmp_create_context(): xmp_context
; cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
337 procedure xmp_free_context(ctx
: xmp_context
); cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
338 function xmp_get_format_list(): ppchar
; cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
340 function xmp_test_module(fname
: pchar
; var info
: xmp_test_info
): longint; cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
341 function xmp_load_module(ctx
: xmp_context
; fname
: pchar
): longint; cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
342 function xmp_load_module_from_memory(ctx
: xmp_context
; buf
: pointer; bufsiz
: longint): longint; cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
343 function xmp_load_module_from_file(ctx
: xmp_context
; fstream
: pointer; msize
: longint): longint; cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
344 procedure xmp_scan_module(ctx
: xmp_context
); cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
345 procedure xmp_get_module_info(ctx
: xmp_context
; var info
: xmp_module_info
); cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
346 procedure xmp_release_module(ctx
: xmp_context
); cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
348 function xmp_start_player(ctx
: xmp_context
; rate
, format
: longint): longint; cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
349 function xmp_play_frame(ctx
: xmp_context
): longint; cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
350 function xmp_play_buffer(ctx
: xmp_context
; buf
: pointer; bufsiz
: longint; loop
: longint): longint; cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
351 procedure xmp_get_frame_info(ctx
: xmp_context
; var info
: xmp_frame_info
); cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
352 procedure xmp_end_player(ctx
: xmp_context
); cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
354 procedure xmp_inject_event(ctx
: xmp_context
; ch
: longint; ev
: pxmp_event
); cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
356 function xmp_next_position(ctx
: xmp_context
): longint; cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
357 function xmp_prev_position(ctx
: xmp_context
): longint; cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
358 function xmp_set_position(ctx
: xmp_context
; pos
: longint): longint; cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
359 function xmp_seek_time(ctx
: xmp_context
; ms
: longint): longint; cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
360 procedure xmp_stop_module(ctx
: xmp_context
); cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
361 procedure xmp_restart_module(ctx
: xmp_context
); cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
363 function xmp_channel_mute(ctx
: xmp_context
; ch
, mute
: longint): longint; cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
364 function xmp_channel_vol(ctx
: xmp_context
; ch
, vol
: longint): longint; cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
366 function xmp_set_player(ctx
: xmp_context
; param
, value
: longint): longint; cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
367 function xmp_get_player(ctx
: xmp_context
; param
: longint): longint; cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
368 function xmp_set_instrument_path(ctx
: xmp_context
; path
: pchar
): longint; cdecl; external {$IFDEF XMP_DYNAMIC}xmplib
{$ENDIF};
371 function xmp_start_smix;
372 procedure xmp_end_smix;
373 function xmp_smix_play_instrument;
374 function xmp_smix_play_sample;
375 function xmp_smix_channel_pan;
376 function xmp_smix_load_sample;
377 function xmp_smix_release_sample;