@@ -57,28 +57,15 @@ def import_pyfmodex():
5757
5858 # prepare the environment for pyfmodex
5959 if system == "Windows" :
60- # register fmod.dll, so that windll.fmod in pyfmodex can find it
61- ctypes .WinDLL (os .path .join (LIB_PATH , "fmod.dll" ))
62- import pyfmodex
60+ os .environ ["PYFMODEX_DLL_PATH" ] = os .path .join (LIB_PATH , "fmod.dll" )
6361 else :
64- # It's a bit more complicated on Linux and Mac
65- # as CDLL doesn't cache the loaded libraries.
66- # So our only option is to hook into the ctypes loader
67- # and add the path to the library there.
68- CDLL = ctypes .CDLL
69-
70- def cdll_hook (name , * args , ** kwargs ):
71- if name .startswith ("libfmod" ):
72- name = os .path .join (LIB_PATH , name )
73- return CDLL (name , * args , ** kwargs )
74-
75- ctypes .CDLL = cdll_hook
76-
62+ ext = "dylib" if system == "Darwin" else "so"
63+ os .environ ["PYFMODEX_DLL_PATH" ] = os .path .join (LIB_PATH , f"libfmod.{ ext } " )
64+
7765 # hotfix ctypes for pyfmodex for non windows
7866 ctypes .windll = getattr (ctypes , "windll" , None )
79- import pyfmodex
80-
81- ctypes .CDLL = CDLL
67+
68+ import pyfmodex
8269
8370
8471def extract_audioclip_samples (audio ) -> dict :
@@ -112,7 +99,7 @@ def dump_samples(clip):
11299 sound = system .create_sound (
113100 bytes (clip .m_AudioData ),
114101 pyfmodex .flags .MODE .OPENMEMORY ,
115- exinfo = pyfmodex .system .CREATESOUNDEXINFO (
102+ exinfo = pyfmodex .structure_declarations .CREATESOUNDEXINFO (
116103 length = clip .m_Size ,
117104 numchannels = clip .m_Channels ,
118105 defaultfrequency = clip .m_Frequency ,
@@ -137,7 +124,7 @@ def dump_samples(clip):
137124
138125def subsound_to_wav (subsound ):
139126 # get sound settings
140- length = subsound .get_length (0x00000004 ) # TIMEUNIT.PCMBYTES
127+ length = subsound .get_length (pyfmodex . enums . TIMEUNIT .PCMBYTES )
141128 channels = subsound .format .channels
142129 bits = subsound .format .bits
143130 sample_rate = int (subsound .default_frequency )
0 commit comments