diff --git a/README.md b/README.md index 19030bda..aa3a844c 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,8 @@ blackboxprotobuf git+https://github.com/Perlence/rpp ``` +[.dlls/.so](https://github.com/SatyrDiamond/DawVert-Libs) + ## Required Libraries for UI ``` PyQt6 diff --git a/objects/extlib/c700_brr.py b/objects/extlib/c700_brr.py index d82ab9bd..658b78a2 100644 --- a/objects/extlib/c700_brr.py +++ b/objects/extlib/c700_brr.py @@ -10,7 +10,7 @@ def __init__(self): self.codec_lib = None def load_lib(self): - libloadstat = globalstore.extlib.load('brr', "./libs/brr_codec.dll") + libloadstat = globalstore.extlib.load_native('brr', "brr_codec") self.codec_lib = globalstore.extlib.get('brr') if libloadstat == 1: brr_decode = self.codec_lib._Z9brrdecodePhPsii diff --git a/objects/extlib/openmpt.py b/objects/extlib/openmpt.py index 9b39ac32..c9d88042 100644 --- a/objects/extlib/openmpt.py +++ b/objects/extlib/openmpt.py @@ -28,7 +28,7 @@ def __init__(self): self.mod = None def load_lib(self): - libloadstat = globalstore.extlib.load('libopenmpt', "./libs/libopenmpt") + libloadstat = globalstore.extlib.load_native('libopenmpt', "libopenmpt") self.libopenmpt = globalstore.extlib.get('libopenmpt') if libloadstat == 1: self.libopenmpt.openmpt_module_get_order_name.restype = ctypes.c_char_p diff --git a/objects/extlib/superctr_adpcm.py b/objects/extlib/superctr_adpcm.py index e2ca3aac..71d18404 100644 --- a/objects/extlib/superctr_adpcm.py +++ b/objects/extlib/superctr_adpcm.py @@ -22,7 +22,7 @@ def __init__(self): self.codec_lib = None def load_lib(self): - libloadstat = globalstore.extlib.load('adpcm_qsound', "./libs/bs_codec") + libloadstat = globalstore.extlib.load_native('adpcm_qsound', "bs_codec") self.codec_lib = globalstore.extlib.get('adpcm_qsound') if libloadstat == 1: self.codec_lib.bs_decode.argtypes = [POINTER(c_ubyte), POINTER(c_int16), c_long] @@ -43,7 +43,7 @@ def __init__(self): self.codec_lib = None def load_lib(self): - libloadstat = globalstore.extlib.load('adpcm_oki', "./libs/oki_codec") + libloadstat = globalstore.extlib.load_native('adpcm_oki', "oki_codec") self.codec_lib = globalstore.extlib.get('adpcm_oki') if libloadstat == 1: self.codec_lib.oki6258_decode.argtypes = [POINTER(c_ubyte), POINTER(c_int16), c_long] @@ -76,7 +76,7 @@ def __init__(self): self.codec_lib = None def load_lib(self): - libloadstat = globalstore.extlib.load('adpcm_yamaha_a', "./libs/yma_codec") + libloadstat = globalstore.extlib.load_native('adpcm_yamaha_a', "yma_codec") self.codec_lib = globalstore.extlib.get('adpcm_yamaha_a') if libloadstat == 1: self.codec_lib.yma_decode.argtypes = [POINTER(c_ubyte), POINTER(c_int16), c_long] @@ -97,7 +97,7 @@ def __init__(self): self.codec_lib = None def load_lib(self): - libloadstat = globalstore.extlib.load('adpcm_yamaha_b', "./libs/ymb_codec") + libloadstat = globalstore.extlib.load_native('adpcm_yamaha_b', "ymb_codec") self.codec_lib = globalstore.extlib.get('adpcm_yamaha_b') if libloadstat == 1: self.codec_lib.ymb_decode.argtypes = [POINTER(c_ubyte), POINTER(c_int16), c_long] @@ -118,7 +118,7 @@ def __init__(self): self.codec_lib = None def load_lib(self): - libloadstat = globalstore.extlib.load('adpcm_yamaha_z', "./libs/ymz_codec") + libloadstat = globalstore.extlib.load_native('adpcm_yamaha_z', "ymz_codec") self.codec_lib = globalstore.extlib.get('adpcm_yamaha_z') if libloadstat == 1: self.codec_lib.aica_decode.argtypes = [POINTER(c_ubyte), POINTER(c_int16), c_long] diff --git a/objects/globalstore.py b/objects/globalstore.py index 2677451f..d379f8bc 100644 --- a/objects/globalstore.py +++ b/objects/globalstore.py @@ -11,6 +11,7 @@ from objects.datastorage import idvals as iv_class from objects.datastorage import paramremap as pr_class from objects.datastorage import plugts as pts_class +import sys logger_globalstore = logging.getLogger('globalstore') @@ -64,14 +65,48 @@ def count(plugtype): if plugtype == 'ladspa': return ep_class.ladspa.count() if plugtype == 'all': return ep_class.vst2.count()+ep_class.vst3.count()+ep_class.clap.count() +def extlib_check_bits(): + osbits = 64 if sys.maxsize > 2**32 else 32 + return osbits + +def extlib_get_ostype(): + if sys.platform == 'win32': return 'win' + elif sys.platform == 'cygwin': return 'cygwin' + elif sys.platform == 'linux': return 'linux' + elif sys.platform == 'linux2': return 'linux' + elif sys.platform == 'msys': return 'win' + elif sys.platform == 'darwin': return 'mac' + elif sys.platform == 'freebsd7': return 'freebsd7' + elif sys.platform == 'freebsd8': return 'freebsd8' + elif sys.platform == 'freebsdN': return 'freebsdn' + elif sys.platform == 'openbsd6': return 'openbsd6' + else: return 'unix' + +def extlib_get_ext(): + if sys.platform == 'win32': return '.dll' + elif sys.platform == 'cygwin': return '.dll' + elif sys.platform == 'msys': return '.dll' + elif sys.platform == 'darwin': return '.dylib' + else: return '.so' + class extlib: loaded_parts = {} + + def load_native(nameid, dllname): + osbits = str(extlib_check_bits()) + filepath = os.path.join('.', 'libs', extlib_get_ostype()+'_'+osbits, dllname+extlib_get_ext()) + extlib.load(nameid, filepath) + def load(nameid, filepath): if nameid not in extlib.loaded_parts: try: - extlib.loaded_parts[nameid] = cdll.LoadLibrary(filepath) - logger_globalstore.info('extlib: Loaded "'+filepath+'" as '+nameid) - return 1 + if os.path.exists(filepath): + extlib.loaded_parts[nameid] = cdll.LoadLibrary(filepath) + logger_globalstore.info('extlib: Loaded "'+filepath+'" as '+nameid) + return 1 + else: + logger_globalstore.warning('extlib: file "'+filepath+"\" dosen't exist.") + return -1 except: return -1 else: return 0