I created a FMOD Plugin on C++ and generated both dynamic library (.dylib) and static library (.a).
I am able to successfully use the dynamic library with FMOD Studio GUI and also I’m able to use it in Unity3d Mac simulator (which picks the dynamic library from Assets/Plugins. But I’m having problems getting things working on the iPhone.
For iOS, I need to use the static library (*.a), which means I have to manually load the plugin in Unity3d (C#), generate the Xcode project and installed it on the iPhone. I tried implementing a basic function in C and load it on C# and it works fine. That means that static library is generated properly and that I can load it successfully on the iPhone and use it. But I can’t get working the FMOD Description Function.
Here is my code, when I run it in the iPhone, i’m getting this error:
Thanks in advanced for your help! I’ve been struggling with this for 5 days and haven’t been able to solve it.
C++ side:
F_DECLSPEC F_DLLEXPORT int F_STDCALL AigooGetDSPDescription2(FMOD_DSP_DESCRIPTION *FmodDesc)
{
// defines the user interface, maximum distance knob
static float distance_mapping_values[] = { 0, 1, 5, 20, 100, 500, 10000 };
static float distance_mapping_scale[] = { 0, 1, 2, 3, 4, 4.5, 5 };
// defines the 3D location attributes
FMOD_DSP_INIT_PARAMDESC_DATA(p_3d_attributes, "3D Attributes", "", "", FMOD_DSP_PARAMETER_DATA_TYPE_3DATTRIBUTES);
FMOD_DSP_DESCRIPTION Aigoo_Simple_Plugin_Desc =
{
FMOD_PLUGIN_SDK_VERSION,
"AigooSimplePlugin6", // name
0x00010000, // plug-in version
1, // number of input buffers to process
1, // number of output buffers to process
Aigoo_Simple_Plugin_dspcreate,
Aigoo_Simple_Plugin_dsprelease,
Aigoo_Simple_Plugin_dspreset,
Aigoo_Simple_Plugin_dspread,
0,
0,
AIGOO_SIMPLE_PLUGIN_NUM_PARAMETERS,
Aigoo_Simple_Plugin_dspparam,
Aigoo_Simple_Plugin_dspsetparamfloat,
0, // Aigoo_Simple_Plugin_dspsetparamint,
0, // Aigoo_Simple_Plugin_dspsetparambool,
Aigoo_Simple_Plugin_dspsetparamdata,
Aigoo_Simple_Plugin_dspgetparamfloat,
0, // Aigoo_Simple_Plugin_dspgetparamint,
0, // Aigoo_Simple_Plugin_dspgetparambool,
Aigoo_Simple_Plugin_dspgetparamdata,
Aigoo_Simple_Plugin_shouldiprocess,
0, // userdata
Aigoo_Simple_Plugin_sys_register,
Aigoo_Simple_Plugin_sys_deregister,
Aigoo_Simple_Plugin_sys_mix
};
FmodDesc = &Aigoo_Simple_Plugin_Desc;
return 9291983; //this is to test that I'm able to get this value on C# and iOS side
}
C# side:
public class AigooPlugInHandler {
[DllImport ("__Internal")]
public static extern int AigooGetDSPDescription2(out IntPtr FmodDesc);
}
public class MyAigooClass : MonoBehaviour
{
if (Application.platform == RuntimePlatform.IPhonePlayer) {
IntPtr FmodDescPtr;
plugin_result = AigooPlugInHandler.AigooGetDSPDescription2(out FmodDescPtr);
//printing plugin_result returns 9291983 which is the value returned from C
if (FmodDescPtr != IntPtr.Zero)
{
DSP_DESCRIPTION FmodDesc = (DSP_DESCRIPTION)Marshal.PtrToStructure(FmodDescPtr, typeof(DSP_DESCRIPTION));
FmodDesc.numinputbuffers = 1;
ERRCHECK(sys.registerDSP(ref FmodDesc, out mmdsp_handle));
}
else
Console.WriteLine("FmodDescPtr is IntPtr.Zero");
}
}
Thanks,
Carlos