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