Hello guys,
The question is that the title says: How use correctly the dsp.setParameterData function?
For example, what is the correct way to get the byteArray that you have to pass to the function, if your data is a DSP_PARAMETER_3DATTRIBUTES object?
In my project I do that with this code:
I’m using resonanse plugin, and sourceDSP is an instanse of the sourcePlugin of resonanceAudio.
DSP_PARAMETER_3DATTRIBUTES atr3d = new DSP_PARAMETER_3DATTRIBUTES();
atr3d.absolute = new _3D_ATTRIBUTES{position= pos, velocity= vel, forward= listenerForward, up=listenerUp};
atr3d.relative = new _3D_ATTRIBUTES{ position = relativePos, velocity = vel, forward = listenerForward, up = listenerUp };
errcheck(sourceDSP.setParameterFloat(2, 1.0f)); //Min distance
errcheck(sourceDSP.setParameterFloat(3, 100.0f)); //Max distance
byte[] dspdatabytes = new byte[Marshal.SizeOf(typeof(DSP_PARAMETER_3DATTRIBUTES))];
GCHandle pinStructure = GCHandle.Alloc(atr3d, GCHandleType.Pinned);
try
{
Marshal.Copy(pinStructure.AddrOfPinnedObject(), dspdatabytes, 0, dspdatabytes.Length);
errcheck(sourceDSP.setParameterData(8,dspdatabytes));
}
catch (Exception e)
{
Console.WriteLine($"Prolemas al copiar convertir los bytes {e.Message}");
}
finally
{
pinStructure.Free();
}
This code works, but is ugly… Exist other way (and better) to achieve this?
The documentation of setParameterData has this note:
But, how you can use that class (FMOD_DSP_PARAMETER_DESC_DATA) to easy get the byteArray of the data to pass to the option?
That is!
¡thanks for your possible answers!