@@ -57,28 +57,15 @@ def import_pyfmodex():
57
57
58
58
# prepare the environment for pyfmodex
59
59
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" )
63
61
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
+
77
65
# hotfix ctypes for pyfmodex for non windows
78
66
ctypes .windll = getattr (ctypes , "windll" , None )
79
- import pyfmodex
80
-
81
- ctypes .CDLL = CDLL
67
+
68
+ import pyfmodex
82
69
83
70
84
71
def extract_audioclip_samples (audio ) -> dict :
@@ -112,7 +99,7 @@ def dump_samples(clip):
112
99
sound = system .create_sound (
113
100
bytes (clip .m_AudioData ),
114
101
pyfmodex .flags .MODE .OPENMEMORY ,
115
- exinfo = pyfmodex .system .CREATESOUNDEXINFO (
102
+ exinfo = pyfmodex .structure_declarations .CREATESOUNDEXINFO (
116
103
length = clip .m_Size ,
117
104
numchannels = clip .m_Channels ,
118
105
defaultfrequency = clip .m_Frequency ,
@@ -137,7 +124,7 @@ def dump_samples(clip):
137
124
138
125
def subsound_to_wav (subsound ):
139
126
# get sound settings
140
- length = subsound .get_length (0x00000004 ) # TIMEUNIT.PCMBYTES
127
+ length = subsound .get_length (pyfmodex . enums . TIMEUNIT .PCMBYTES )
141
128
channels = subsound .format .channels
142
129
bits = subsound .format .bits
143
130
sample_rate = int (subsound .default_frequency )
0 commit comments