Skip to content

Commit

Permalink
add load_native to extlib and DawVert-Libs link
Browse files Browse the repository at this point in the history
  • Loading branch information
SatyrDiamond committed Nov 2, 2024
1 parent 849700e commit 9dcb5ce
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 10 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ blackboxprotobuf
git+https://github.com/Perlence/rpp
```

[.dlls/.so](https://github.com/SatyrDiamond/DawVert-Libs)

## Required Libraries for UI
```
PyQt6
Expand Down
2 changes: 1 addition & 1 deletion objects/extlib/c700_brr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion objects/extlib/openmpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions objects/extlib/superctr_adpcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand Down Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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]
Expand Down
41 changes: 38 additions & 3 deletions objects/globalstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 9dcb5ce

Please sign in to comment.