Answered
0
0

Dear Forum,

I was hoping that someone would be able to help me out. I’ve constructed my own FMOD.DSP plugin according to the FMOD_DSP_DESCRIPTION struct. Everything seems to be functioning correctly after I import the plugin into Unity and bind it to a specific channelGroup. I’ve also set up an internal integer variable that keeps track of the specific DSP object’s identity (I can successfully set the integer using the GetParameterInt(), and SetParameterInt() functions).

The custom DSP functions by taking in the input stream and then sending the samples across to a custom socket server that interfaces with a spatialization system. Hence the need for an identifier variable, to keep track of which client (FMOD event’s) data is being transmitted.

i.e. I would like to have a unique instance (in the C# Unity script) of the plugin for each FMOD event (and its specific channel group)

For instance, in a Unity C# script, I get the plugin’s handle and then create an FMOD.DSP object:

plugRes = RuntimeManager.LowlevelSystem.loadPlugin(“fmod_imdsp.dll”, out ImDSPHandle);
plugRes =RuntimeManager.LowlevelSystem.createDSPByPlugin(ImDSPHandle, out ImDSP);

My issue lies in the creation of two DSP objects, and uniquely setting their identifiers. For example:

    plugRes = RuntimeManager.LowlevelSystem.loadPlugin("fmod_imdsp.dll", out ImDSPHandle);
    plugRes =RuntimeManager.LowlevelSystem.createDSPByPlugin(ImDSPHandle, out ImDSP);

    plugRes = RuntimeManager.LowlevelSystem.loadPlugin("fmod_imdsp.dll", out ImDSPHandle2);
    plugRes =RuntimeManager.LowlevelSystem.createDSPByPlugin(ImDSPHandle2, out ImDSP2);

I then bind the DSP objects to unique channelGroups that belong to event instances that I am simply playing back (for now):

while (SingleInstGrp.handle == (IntPtr)0)
{
RuntimeManager.StudioSystem.update();
//SingleInst is the FMOD event instance
SingleInst.getChannelGroup(out SingleInstGrp);
}

    while(RainInst.handle== (IntPtr)0)
    {
        RuntimeManager.StudioSystem.updat3e();
        //RainInst is the FMOD event instance
        RainInst.getChannelGroup(out RainInstGrp);
    }

    plugRes = SingleInstGrp.addDSP(0, ImDSP);
    plugRes = RainInstGrp.addDSP(0, ImDSP2);

Now, to change the ImDSP (FMOD.DSP’s) identifiers, I call the setParameterInt() functions:

    plugRes = ImDSP.setParameterInt(0, 1);
    plugRes = ImDSP.getParameterInt(0, out holder);
    plugRes = ImDSP2.setParameterInt(0, 3);

Finally, I set the FMOD.DSP’s to active, using the .setActive(true) function.

After these steps, my problem arises. When I debug the Unity C# code and check to see whether each instance of the ImDSP FMOD.DSP plugin has the correct identifier (by using the getParameterInt() function), I find that the instances do correctly retain the correct variable (ImDSP has an identifier value of 1, and ImDSP2 has an identifier value of 3).

However, what I’ve found is that the final setParameterInt() call modifies the .DLL (ImDSP plugin). So that even if I’m playing an FMOD event with the first ImDSP object attached to it’s channel group, the identifier (within the plugin) belongs to the the last ImDSP object that made the getParameterInt() function.

i.e. With regards to the preceding code;

the ImDSP object will have an identifier value of 3, even though it expressly sets its identifier value to 1 ( plugRes = ImDSP.setParameterInt(0, 1);), and this can be confirmed from the Unity debugger.

As I mentioned above, when debugging the C# script, and calling the ImDSP.getParameterInt(0, out holder) function, I find that the parameter is indeed set to ‘1’.

On the server-side, after I begin transmitting samples, I find the identifier is always what it has last been set to (in this case, “3” (in the plugRes = ImDSP2.setParameterInt(0, 3);).

So my question is how can I get the .DLL to correctly initialize with the correct identifier values depending on the channelGroup and specific FMOD.DSP object (i.e. ImDSP and ImDSP2). i.e. How can I pass on the information retained in the C# FMOD.DSP ImDSP objects to the actual plugin file before any audio processing. Any advice or comments would be appreciated.

Kyle

  • You must to post comments
Best Answer
0
0

If you want to use the same plugin multiple times, you don’t need to load the file each time, just use the plugin handle to create multiple DSPs.

plugRes = RuntimeManager.LowlevelSystem.loadPlugin("fmod_imdsp.dll", out ImDSPHandle);
plugRes =RuntimeManager.LowlevelSystem.createDSPByPlugin(ImDSPHandle, out ImDSP);
plugRes =RuntimeManager.LowlevelSystem.createDSPByPlugin(ImDSPHandle, out ImDSP2);

As for setting a parameter before any audio is processed, the easiest way to do this would be to start the sound paused. That way everything will get created and ready to start but not actually processed.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.