I’ve created a custom DSP node (based almost exactly on the C# custom DSP example), but when I add that node to my network the profile stops working, reporting "Corrupt packet detected, ignoring packet" as the status, and the node graph doesn’t get updated to show any changes.
Any thoughts as to why this would be happening?
- opusmcn asked 5 years ago
Here’s the construction (adapted from the sample code)
private FMOD.DSP CreateDSP(FMOD.System system)
FMOD.DSP thisdsp = new FMOD.DSP();
FMOD.DSP_DESCRIPTION dspdesc = new FMOD.DSP_DESCRIPTION();
String dspname = "custom dsp "; // pad this to 32 characters
FMOD.DSP_READCALLBACK dspreadcallback = new FMOD.DSP_READCALLBACK(customCallback);
dspdesc.name = dspname.ToCharArray(0, 32); dspdesc.channels = 0; dspdesc.read = dspreadcallback; dspDescriptions.Add(dspdesc); // keep hold of the pointer to avoid garbage collection FMOD.RESULT result; result = system.createDSP(ref dspdesc, ref thisdsp); ERRCHECK(result, "Creating custom DSP"); result = thisdsp.setActive(true); ERRCHECK(result, "Activating custom DSP"); return thisdsp; }
The callback routine just copies the input straight to the output (for debugging) and is being called fine and does what it’s supposed to do (at least I think it does
Anything you can see out of order with this?
The issue is dspdesc.name isn’t null terminated, it has a heap of spaces up to the array length which FMOD reads as an invalid packet.
I’m certainly no C# pro, there may be better ways to do this but this will work:
[code:2xaqhbhn]private String dspname = "My first DSP Unit";
char nameArray = new char;
dspdesc.name = nameArray;
Yep, that fixes it.
Interestingly, that code is copied directly from the C# sample that comes with FMOD, and it doesn’t terminate the string either. I noticed it, but decided to follow the example so you might want to update that to do the right thing
(from the sample)
private String dspname = "My first DSP unit ";
[snip... code later on] /* Create DSP unit */ dspdesc.name = dspname.ToCharArray(0, 32); dspdesc.channels = 0; dspdesc.read = dspreadcallback; result = system.createDSP(ref dspdesc, ref mydsp); ERRCHECK(result);
Please login first to submit.