@@ -57,25 +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- import pyfmodex
77-
78- ctypes .CDLL = CDLL
62+ ext = "dylib" if system == "Darwin" else "so"
63+ os .environ ["PYFMODEX_DLL_PATH" ] = os .path .join (LIB_PATH , f"libfmod.{ ext } " )
64+
65+ # hotfix ctypes for pyfmodex for non windows
66+ ctypes .windll = getattr (ctypes , "windll" , None )
67+
68+ import pyfmodex
7969
8070
8171def extract_audioclip_samples (audio ) -> dict :
@@ -109,7 +99,7 @@ def dump_samples(clip):
10999 sound = system .create_sound (
110100 bytes (clip .m_AudioData ),
111101 pyfmodex .flags .MODE .OPENMEMORY ,
112- exinfo = pyfmodex .system .CREATESOUNDEXINFO (
102+ exinfo = pyfmodex .structure_declarations .CREATESOUNDEXINFO (
113103 length = clip .m_Size ,
114104 numchannels = clip .m_Channels ,
115105 defaultfrequency = clip .m_Frequency ,
@@ -134,7 +124,7 @@ def dump_samples(clip):
134124
135125def subsound_to_wav (subsound ):
136126 # get sound settings
137- length = subsound .get_length (0x00000004 ) # TIMEUNIT.PCMBYTES
127+ length = subsound .get_length (pyfmodex . enums . TIMEUNIT .PCMBYTES )
138128 channels = subsound .format .channels
139129 bits = subsound .format .bits
140130 sample_rate = int (subsound .default_frequency )
0 commit comments