-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlibxmp.py
1462 lines (1119 loc) · 36.3 KB
/
libxmp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import ctypes
import os
import sys
import math
from ctypes import *
# class xmp_context(Structure):
# _fields_ = [
# ("name", c_char * PATH_MAX),
# ]
libxmp = CDLL("libxmp.so", mode=RTLD_GLOBAL)
class UserString:
def __init__(self, seq):
if isinstance(seq, basestring):
self.data = seq
elif isinstance(seq, UserString):
self.data = seq.data[:]
else:
self.data = str(seq)
def __str__(self): return str(self.data)
def __repr__(self): return repr(self.data)
def __int__(self): return int(self.data)
def __long__(self): return long(self.data)
def __float__(self): return float(self.data)
def __complex__(self): return complex(self.data)
def __hash__(self): return hash(self.data)
def __cmp__(self, string):
if isinstance(string, UserString):
return cmp(self.data, string.data)
else:
return cmp(self.data, string)
def __contains__(self, char):
return char in self.data
def __len__(self): return len(self.data)
def __getitem__(self, index): return self.__class__(self.data[index])
def __getslice__(self, start, end):
start = max(start, 0)
end = max(end, 0)
return self.__class__(self.data[start:end])
def __add__(self, other):
if isinstance(other, UserString):
return self.__class__(self.data + other.data)
elif isinstance(other, basestring):
return self.__class__(self.data + other)
else:
return self.__class__(self.data + str(other))
def __radd__(self, other):
if isinstance(other, basestring):
return self.__class__(other + self.data)
else:
return self.__class__(str(other) + self.data)
def __mul__(self, n):
return self.__class__(self.data*n)
__rmul__ = __mul__
def __mod__(self, args):
return self.__class__(self.data % args)
# the following methods are defined in alphabetical order:
def capitalize(self): return self.__class__(self.data.capitalize())
def center(self, width, *args):
return self.__class__(self.data.center(width, *args))
def count(self, sub, start=0, end=sys.maxsize):
return self.data.count(sub, start, end)
def decode(self, encoding=None, errors=None): # XXX improve this?
if encoding:
if errors:
return self.__class__(self.data.decode(encoding, errors))
else:
return self.__class__(self.data.decode(encoding))
else:
return self.__class__(self.data.decode())
def encode(self, encoding=None, errors=None): # XXX improve this?
if encoding:
if errors:
return self.__class__(self.data.encode(encoding, errors))
else:
return self.__class__(self.data.encode(encoding))
else:
return self.__class__(self.data.encode())
def endswith(self, suffix, start=0, end=sys.maxsize):
return self.data.endswith(suffix, start, end)
def expandtabs(self, tabsize=8):
return self.__class__(self.data.expandtabs(tabsize))
def find(self, sub, start=0, end=sys.maxsize):
return self.data.find(sub, start, end)
def index(self, sub, start=0, end=sys.maxsize):
return self.data.index(sub, start, end)
def isalpha(self): return self.data.isalpha()
def isalnum(self): return self.data.isalnum()
def isdecimal(self): return self.data.isdecimal()
def isdigit(self): return self.data.isdigit()
def islower(self): return self.data.islower()
def isnumeric(self): return self.data.isnumeric()
def isspace(self): return self.data.isspace()
def istitle(self): return self.data.istitle()
def isupper(self): return self.data.isupper()
def join(self, seq): return self.data.join(seq)
def ljust(self, width, *args):
return self.__class__(self.data.ljust(width, *args))
def lower(self): return self.__class__(self.data.lower())
def lstrip(self, chars=None): return self.__class__(self.data.lstrip(chars))
def partition(self, sep):
return self.data.partition(sep)
def replace(self, old, new, maxsplit=-1):
return self.__class__(self.data.replace(old, new, maxsplit))
def rfind(self, sub, start=0, end=sys.maxsize):
return self.data.rfind(sub, start, end)
def rindex(self, sub, start=0, end=sys.maxsize):
return self.data.rindex(sub, start, end)
def rjust(self, width, *args):
return self.__class__(self.data.rjust(width, *args))
def rpartition(self, sep):
return self.data.rpartition(sep)
def rstrip(self, chars=None): return self.__class__(self.data.rstrip(chars))
def split(self, sep=None, maxsplit=-1):
return self.data.split(sep, maxsplit)
def rsplit(self, sep=None, maxsplit=-1):
return self.data.rsplit(sep, maxsplit)
def splitlines(self, keepends=0): return self.data.splitlines(keepends)
def startswith(self, prefix, start=0, end=sys.maxsize):
return self.data.startswith(prefix, start, end)
def strip(self, chars=None): return self.__class__(self.data.strip(chars))
def swapcase(self): return self.__class__(self.data.swapcase())
def title(self): return self.__class__(self.data.title())
def translate(self, *args):
return self.__class__(self.data.translate(*args))
def upper(self): return self.__class__(self.data.upper())
def zfill(self, width): return self.__class__(self.data.zfill(width))
class MutableString(UserString):
"""mutable string objects
Python strings are immutable objects. This has the advantage, that
strings may be used as dictionary keys. If this property isn't needed
and you insist on changing string values in place instead, you may cheat
and use MutableString.
But the purpose of this class is an educational one: to prevent
people from inventing their own mutable string class derived
from UserString and than forget thereby to remove (override) the
__hash__ method inherited from UserString. This would lead to
errors that would be very hard to track down.
A faster and better solution is to rewrite your program using lists."""
def __init__(self, string=""):
self.data = string
def __hash__(self):
raise TypeError("unhashable type (it is mutable)")
def __setitem__(self, index, sub):
if index < 0:
index += len(self.data)
if index < 0 or index >= len(self.data):
raise IndexError
self.data = self.data[:index] + sub + self.data[index+1:]
def __delitem__(self, index):
if index < 0:
index += len(self.data)
if index < 0 or index >= len(self.data):
raise IndexError
self.data = self.data[:index] + self.data[index+1:]
def __setslice__(self, start, end, sub):
start = max(start, 0)
end = max(end, 0)
if isinstance(sub, UserString):
self.data = self.data[:start]+sub.data+self.data[end:]
elif isinstance(sub, basestring):
self.data = self.data[:start]+sub+self.data[end:]
else:
self.data = self.data[:start]+str(sub)+self.data[end:]
def __delslice__(self, start, end):
start = max(start, 0)
end = max(end, 0)
self.data = self.data[:start] + self.data[end:]
def immutable(self):
return UserString(self.data)
def __iadd__(self, other):
if isinstance(other, UserString):
self.data += other.data
elif isinstance(other, basestring):
self.data += other
else:
self.data += str(other)
return self
def __imul__(self, n):
self.data *= n
return self
class String(MutableString, Union):
_fields_ = [('raw', POINTER(c_char)),
('data', c_char_p)]
def __init__(self, obj=""):
# if isinstance(obj, (str, unicode, UserString)):
if isinstance(obj, (str, UserString)):
self.data = str(obj).encode('utf-8')
else:
self.raw = obj
def __len__(self):
return self.data and len(self.data) or 0
def from_param(cls, obj):
# Convert None or 0
if obj is None or obj == 0:
return cls(POINTER(c_char)())
# Convert from String
elif isinstance(obj, String):
return obj
# Convert from str
elif isinstance(obj, str):
return cls(obj)
# Convert from c_char_p
elif isinstance(obj, c_char_p):
return obj
# Convert from POINTER(c_char)
elif isinstance(obj, POINTER(c_char)):
return obj
# Convert from raw pointer
elif isinstance(obj, int):
return cls(cast(obj, POINTER(c_char)))
# Convert from object
else:
return String.from_param(obj._as_parameter_)
from_param = classmethod(from_param)
def ReturnString(obj, func=None, arguments=None):
return String.from_param(obj)
class struct_xmp_channel(Structure):
pass
struct_xmp_channel.__slots__ = [
'pan',
'vol',
'flg',
]
struct_xmp_channel._fields_ = [
('pan', c_int),
('vol', c_int),
('flg', c_int),
]
class struct_xmp_pattern(Structure):
pass
struct_xmp_pattern.__slots__ = [
'rows',
'index',
]
struct_xmp_pattern._fields_ = [
('rows', c_int),
('index', c_int * 256),
]
class struct_xmp_event(Structure):
pass
struct_xmp_event.__slots__ = [
'note',
'ins',
'vol',
'fxt',
'fxp',
'f2t',
'f2p',
'_flag',
]
struct_xmp_event._fields_ = [
('note', c_ubyte),
('ins', c_ubyte),
('vol', c_ubyte),
('fxt', c_ubyte),
('fxp', c_ubyte),
('f2t', c_ubyte),
('f2p', c_ubyte),
('_flag', c_ubyte),
]
class struct_xmp_track(Structure):
pass
struct_xmp_track.__slots__ = [
'rows',
'event',
]
struct_xmp_track._fields_ = [
('rows', c_int),
('event', struct_xmp_event * 256),
]
class struct_xmp_envelope(Structure):
pass
struct_xmp_envelope.__slots__ = [
'flg',
'npt',
'scl',
'sus',
'sue',
'lps',
'lpe',
'data',
]
struct_xmp_envelope._fields_ = [
('flg', c_int),
('npt', c_int),
('scl', c_int),
('sus', c_int),
('sue', c_int),
('lps', c_int),
('lpe', c_int),
('data', c_short * (32 * 2)),
]
class struct_anon_1(Structure):
pass
struct_anon_1.__slots__ = [
'ins',
'xpo',
]
struct_anon_1._fields_ = [
('ins', c_ubyte),
('xpo', c_byte),
]
class struct_xmp_subinstrument(Structure):
pass
struct_xmp_subinstrument.__slots__ = [
'vol',
'gvl',
'pan',
'xpo',
'fin',
'vwf',
'vde',
'vra',
'vsw',
'rvv',
'sid',
'nna',
'dct',
'dca',
'ifc',
'ifr',
]
struct_xmp_subinstrument._fields_ = [
('vol', c_int),
('gvl', c_int),
('pan', c_int),
('xpo', c_int),
('fin', c_int),
('vwf', c_int),
('vde', c_int),
('vra', c_int),
('vsw', c_int),
('rvv', c_int),
('sid', c_int),
('nna', c_int),
('dct', c_int),
('dca', c_int),
('ifc', c_int),
('ifr', c_int),
]
class struct_xmp_instrument(Structure):
pass
struct_xmp_instrument.__slots__ = [
'name',
'vol',
'nsm',
'rls',
'aei',
'pei',
'fei',
'map',
'sub',
'extra',
]
struct_xmp_instrument._fields_ = [
('name', c_char * 32),
('vol', c_int),
('nsm', c_int),
('rls', c_int),
('aei', struct_xmp_envelope),
('pei', struct_xmp_envelope),
('fei', struct_xmp_envelope),
('map', struct_anon_1 * 121),
('sub', POINTER(struct_xmp_subinstrument)),
('extra', POINTER(None)),
]
class struct_xmp_sample(Structure):
pass
struct_xmp_sample.__slots__ = [
'name',
'len',
'lps',
'lpe',
'flg',
'data',
]
struct_xmp_sample._fields_ = [
('name', c_char * 32),
('len', c_int),
('lps', c_int),
('lpe', c_int),
('flg', c_int),
('data', POINTER(c_ubyte)),
]
class struct_xmp_sequence(Structure):
pass
struct_xmp_sequence.__slots__ = [
'entry_point',
'duration',
]
struct_xmp_sequence._fields_ = [
('entry_point', c_int),
('duration', c_int),
]
class struct_xmp_module(Structure):
pass
struct_xmp_module.__slots__ = [
'name',
'type',
'pat',
'trk',
'chn',
'ins',
'smp',
'spd',
'bpm',
'len',
'rst',
'gvl',
'xxp',
'xxt',
'xxi',
'xxs',
'xxc',
'xxo',
]
struct_xmp_module._fields_ = [
('name', c_char * 64),
('type', c_char * 64),
('pat', c_int),
('trk', c_int),
('chn', c_int),
('ins', c_int),
('smp', c_int),
('spd', c_int),
('bpm', c_int),
('len', c_int),
('rst', c_int),
('gvl', c_int),
('xxp', POINTER(POINTER(struct_xmp_pattern))),
('xxt', POINTER(POINTER(struct_xmp_track))),
('xxi', POINTER(struct_xmp_instrument)),
('xxs', POINTER(struct_xmp_sample)),
('xxc', struct_xmp_channel * 64),
('xxo', c_ubyte * 256),
]
class struct_xmp_test_info(Structure):
pass
struct_xmp_test_info.__slots__ = [
'name',
'type',
]
struct_xmp_test_info._fields_ = [
('name', c_char * 64),
('type', c_char * 64),
]
class struct_xmp_module_info(Structure):
pass
struct_xmp_module_info.__slots__ = [
'md5',
'vol_base',
'mod',
'comment',
'num_sequences',
'seq_data',
]
struct_xmp_module_info._fields_ = [
('md5', c_ubyte * 16),
('vol_base', c_int),
('mod', POINTER(struct_xmp_module)),
('comment', String),
('num_sequences', c_int),
('seq_data', POINTER(struct_xmp_sequence)),
]
class struct_xmp_channel_info(Structure):
pass
struct_xmp_channel_info.__slots__ = [
'period',
'position',
'pitchbend',
'note',
'instrument',
'sample',
'volume',
'pan',
'reserved',
'event',
]
struct_xmp_channel_info._fields_ = [
('period', c_uint),
('position', c_uint),
('pitchbend', c_short),
('note', c_ubyte),
('instrument', c_ubyte),
('sample', c_ubyte),
('volume', c_ubyte),
('pan', c_ubyte),
('reserved', c_ubyte),
('event', struct_xmp_event),
]
class struct_xmp_frame_info(Structure):
pass
struct_xmp_frame_info.__slots__ = [
'pos',
'pattern',
'row',
'num_rows',
'frame',
'speed',
'bpm',
'time',
'total_time',
'frame_time',
'buffer',
'buffer_size',
'total_size',
'volume',
'loop_count',
'virt_channels',
'virt_used',
'sequence',
'channel_info',
]
struct_xmp_frame_info._fields_ = [
('pos', c_int),
('pattern', c_int),
('row', c_int),
('num_rows', c_int),
('frame', c_int),
('speed', c_int),
('bpm', c_int),
('time', c_int),
('total_time', c_int),
('frame_time', c_int),
('buffer', POINTER(None)),
('buffer_size', c_int),
('total_size', c_int),
('volume', c_int),
('loop_count', c_int),
('virt_channels', c_int),
('virt_used', c_int),
('sequence', c_int),
('channel_info', struct_xmp_channel_info * 64),
]
xmp_context = c_long
try:
xmp_version = (String).in_dll(libxmp, 'xmp_version')
except:
pass
xmp_context = c_long
try:
xmp_version = (String).in_dll(libxmp, 'xmp_version')
except:
pass
try:
xmp_vercode = (c_uint).in_dll(libxmp, 'xmp_vercode')
except:
pass
if hasattr(libxmp, 'xmp_create_context'):
xmp_create_context = libxmp.xmp_create_context
xmp_create_context.argtypes = []
xmp_create_context.restype = xmp_context
if hasattr(libxmp, 'xmp_free_context'):
xmp_free_context = libxmp.xmp_free_context
xmp_free_context.argtypes = [xmp_context]
xmp_free_context.restype = None
if hasattr(libxmp, 'xmp_test_module'):
xmp_test_module = libxmp.xmp_test_module
xmp_test_module.argtypes = [String, POINTER(struct_xmp_test_info)]
xmp_test_module.restype = c_int
if hasattr(libxmp, 'xmp_load_module'):
xmp_load_module = libxmp.xmp_load_module
xmp_load_module.argtypes = [xmp_context, String]
xmp_load_module.restype = c_int
if hasattr(libxmp, 'xmp_scan_module'):
xmp_scan_module = libxmp.xmp_scan_module
xmp_scan_module.argtypes = [xmp_context]
xmp_scan_module.restype = None
if hasattr(libxmp, 'xmp_release_module'):
xmp_release_module = libxmp.xmp_release_module
xmp_release_module.argtypes = [xmp_context]
xmp_release_module.restype = None
if hasattr(libxmp, 'xmp_start_player'):
xmp_start_player = libxmp.xmp_start_player
xmp_start_player.argtypes = [xmp_context, c_int, c_int]
xmp_start_player.restype = c_int
if hasattr(libxmp, 'xmp_play_frame'):
xmp_play_frame = libxmp.xmp_play_frame
xmp_play_frame.argtypes = [xmp_context]
xmp_play_frame.restype = c_int
if hasattr(libxmp, 'xmp_play_buffer'):
xmp_play_buffer = libxmp.xmp_play_buffer
xmp_play_buffer.argtypes = [xmp_context, POINTER(None), c_int, c_int]
xmp_play_buffer.restype = c_int
if hasattr(libxmp, 'xmp_get_frame_info'):
xmp_get_frame_info = libxmp.xmp_get_frame_info
xmp_get_frame_info.argtypes = [xmp_context, POINTER(struct_xmp_frame_info)]
xmp_get_frame_info.restype = None
if hasattr(libxmp, 'xmp_end_player'):
xmp_end_player = libxmp.xmp_end_player
xmp_end_player.argtypes = [xmp_context]
xmp_end_player.restype = None
if hasattr(libxmp, 'xmp_inject_event'):
xmp_inject_event = libxmp.xmp_inject_event
xmp_inject_event.argtypes = [xmp_context, c_int, POINTER(struct_xmp_event)]
xmp_inject_event.restype = None
if hasattr(libxmp, 'xmp_get_module_info'):
xmp_get_module_info = libxmp.xmp_get_module_info
xmp_get_module_info.argtypes = [xmp_context, POINTER(struct_xmp_module_info)]
xmp_get_module_info.restype = None
if hasattr(libxmp, 'xmp_get_format_list'):
xmp_get_format_list = libxmp.xmp_get_format_list
xmp_get_format_list.argtypes = []
xmp_get_format_list.restype = POINTER(POINTER(c_char))
if hasattr(libxmp, 'xmp_next_position'):
xmp_next_position = libxmp.xmp_next_position
xmp_next_position.argtypes = [xmp_context]
xmp_next_position.restype = c_int
if hasattr(libxmp, 'xmp_prev_position'):
xmp_prev_position = libxmp.xmp_prev_position
xmp_prev_position.argtypes = [xmp_context]
xmp_prev_position.restype = c_int
if hasattr(libxmp, 'xmp_set_position'):
xmp_set_position = libxmp.xmp_set_position
xmp_set_position.argtypes = [xmp_context, c_int]
xmp_set_position.restype = c_int
if hasattr(libxmp, 'xmp_stop_module'):
xmp_stop_module = libxmp.xmp_stop_module
xmp_stop_module.argtypes = [xmp_context]
xmp_stop_module.restype = None
if hasattr(libxmp, 'xmp_restart_module'):
xmp_restart_module = libxmp.xmp_restart_module
xmp_restart_module.argtypes = [xmp_context]
xmp_restart_module.restype = None
if hasattr(libxmp, 'xmp_seek_time'):
xmp_seek_time = libxmp.xmp_seek_time
xmp_seek_time.argtypes = [xmp_context, c_int]
xmp_seek_time.restype = c_int
if hasattr(libxmp, 'xmp_channel_mute'):
xmp_channel_mute = libxmp.xmp_channel_mute
xmp_channel_mute.argtypes = [xmp_context, c_int, c_int]
xmp_channel_mute.restype = c_int
if hasattr(libxmp, 'xmp_channel_vol'):
xmp_channel_vol = libxmp.xmp_channel_vol
xmp_channel_vol.argtypes = [xmp_context, c_int, c_int]
xmp_channel_vol.restype = c_int
if hasattr(libxmp, 'xmp_set_player'):
xmp_set_player = libxmp.xmp_set_player
xmp_set_player.argtypes = [xmp_context, c_int, c_int]
xmp_set_player.restype = c_int
if hasattr(libxmp, 'xmp_get_player'):
xmp_get_player = libxmp.xmp_get_player
xmp_get_player.argtypes = [xmp_context, c_int]
xmp_get_player.restype = c_int
if hasattr(libxmp, 'xmp_set_instrument_path'):
xmp_set_instrument_path = libxmp.xmp_set_instrument_path
xmp_set_instrument_path.argtypes = [xmp_context, String]
xmp_set_instrument_path.restype = c_int
if hasattr(libxmp, 'xmp_load_module_from_memory'):
xmp_load_module_from_memory = libxmp.xmp_load_module_from_memory
xmp_load_module_from_memory.argtypes = [xmp_context, POINTER(None), c_long]
xmp_load_module_from_memory.restype = c_int
if hasattr(libxmp, 'xmp_start_smix'):
xmp_start_smix = libxmp.xmp_start_smix
xmp_start_smix.argtypes = [xmp_context, c_int, c_int]
xmp_start_smix.restype = c_int
if hasattr(libxmp, 'xmp_end_smix'):
xmp_end_smix = libxmp.xmp_end_smix
xmp_end_smix.argtypes = [xmp_context]
xmp_end_smix.restype = None
if hasattr(libxmp, 'xmp_smix_play_instrument'):
xmp_smix_play_instrument = libxmp.xmp_smix_play_instrument
xmp_smix_play_instrument.argtypes = [xmp_context, c_int, c_int, c_int, c_int]
xmp_smix_play_instrument.restype = c_int
if hasattr(libxmp, 'xmp_smix_play_sample'):
xmp_smix_play_sample = libxmp.xmp_smix_play_sample
xmp_smix_play_sample.argtypes = [xmp_context, c_int, c_int, c_int, c_int]
xmp_smix_play_sample.restype = c_int
if hasattr(libxmp, 'xmp_smix_channel_pan'):
xmp_smix_channel_pan = libxmp.xmp_smix_channel_pan
xmp_smix_channel_pan.argtypes = [xmp_context, c_int, c_int]
xmp_smix_channel_pan.restype = c_int
if hasattr(libxmp, 'xmp_smix_load_sample'):
xmp_smix_load_sample = libxmp.xmp_smix_load_sample
xmp_smix_load_sample.argtypes = [xmp_context, c_int, String]
xmp_smix_load_sample.restype = c_int
if hasattr(libxmp, 'xmp_smix_release_sample'):
xmp_smix_release_sample = libxmp.xmp_smix_release_sample
xmp_smix_release_sample.argtypes = [xmp_context, c_int]
xmp_smix_release_sample.restype = c_int
XMP_NAME_SIZE = 64
XMP_KEY_OFF = 129
XMP_KEY_CUT = 130
XMP_KEY_FADE = 131
XMP_FORMAT_8BIT = (1 << 0)
XMP_FORMAT_UNSIGNED = (1 << 1)
XMP_FORMAT_MONO = (1 << 2)
XMP_PLAYER_AMP = 0
XMP_PLAYER_MIX = 1
XMP_PLAYER_INTERP = 2
XMP_PLAYER_DSP = 3
XMP_PLAYER_FLAGS = 4
XMP_PLAYER_CFLAGS = 5
XMP_PLAYER_SMPCTL = 6
XMP_PLAYER_VOLUME = 7
XMP_PLAYER_STATE = 8
XMP_PLAYER_SMIX_VOLUME = 9
XMP_INTERP_NEAREST = 0
XMP_INTERP_LINEAR = 1
XMP_INTERP_SPLINE = 2
XMP_DSP_LOWPASS = (1 << 0)
XMP_DSP_ALL = XMP_DSP_LOWPASS
XMP_STATE_UNLOADED = 0
XMP_STATE_LOADED = 1
XMP_STATE_PLAYING = 2
XMP_FLAGS_VBLANK = (1 << 0)
XMP_FLAGS_FX9BUG = (1 << 1)
XMP_FLAGS_FIXLOOP = (1 << 2)
XMP_SMPCTL_SKIP = (1 << 0)
XMP_MAX_KEYS = 121
XMP_MAX_ENV_POINTS = 32
XMP_MAX_MOD_LENGTH = 256
XMP_MAX_CHANNELS = 64
XMP_MAX_SRATE = 49170
XMP_MIN_SRATE = 4000
XMP_MIN_BPM = 20
XMP_MAX_FRAMESIZE = (((5 * XMP_MAX_SRATE) * 2) / XMP_MIN_BPM)
XMP_END = 1
XMP_ERROR_INTERNAL = 2
XMP_ERROR_FORMAT = 3
XMP_ERROR_LOAD = 4
XMP_ERROR_DEPACK = 5
XMP_ERROR_SYSTEM = 6
XMP_ERROR_INVALID = 7
XMP_ERROR_STATE = 8
XMP_CHANNEL_SYNTH = (1 << 0)
XMP_CHANNEL_MUTE = (1 << 1)
XMP_ENVELOPE_ON = (1 << 0)
XMP_ENVELOPE_SUS = (1 << 1)
XMP_ENVELOPE_LOOP = (1 << 2)
XMP_ENVELOPE_FLT = (1 << 3)
XMP_ENVELOPE_SLOOP = (1 << 4)
XMP_ENVELOPE_CARRY = (1 << 5)
XMP_INST_NNA_CUT = 0
XMP_INST_NNA_CONT = 1
XMP_INST_NNA_OFF = 2
XMP_INST_NNA_FADE = 3
XMP_INST_DCT_OFF = 0
XMP_INST_DCT_NOTE = 1
XMP_INST_DCT_SMP = 2
XMP_INST_DCT_INST = 3
XMP_INST_DCA_CUT = XMP_INST_NNA_CUT
XMP_INST_DCA_OFF = XMP_INST_NNA_OFF
XMP_INST_DCA_FADE = XMP_INST_NNA_FADE
XMP_SAMPLE_16BIT = (1 << 0)
XMP_SAMPLE_LOOP = (1 << 1)
XMP_SAMPLE_LOOP_BIDIR = (1 << 2)
XMP_SAMPLE_LOOP_REVERSE = (1 << 3)
XMP_SAMPLE_LOOP_FULL = (1 << 4)
XMP_SAMPLE_SYNTH = (1 << 15)
XMP_PERIOD_BASE = 6847
xmp_channel = struct_xmp_channel
xmp_pattern = struct_xmp_pattern
xmp_event = struct_xmp_event
xmp_track = struct_xmp_track
xmp_envelope = struct_xmp_envelope
xmp_subinstrument = struct_xmp_subinstrument
xmp_instrument = struct_xmp_instrument
xmp_sample = struct_xmp_sample
xmp_sequence = struct_xmp_sequence
xmp_module = struct_xmp_module
xmp_test_info = struct_xmp_test_info
xmp_module_info = struct_xmp_module_info
xmp_channel_info = struct_xmp_channel_info
xmp_frame_info = struct_xmp_frame_info
# Begin inserted files
# Begin "interface.py"