I recently started building my first plugin and stole/copied bits of code here and there from the different examples. One bit of code I stole from the AGain example is the GainParameter class. Things were working just fine, and my project was compiling. I haven’t touched anything in my controller.cpp file, I was editing the process() method in my processor.cpp file, but now suddenly the following error appears:
|Error||IUnitInfo interface is missing, but ParameterInfo::unitID is not 000 (kRootUnitId)
And by commenting out code I’ve pinpointed that the issue comes from the following lines:
auto* gainParam = new GainParameter(Vst::ParameterInfo::kIsReadOnly, RMSParams::kParamRMSId);
Please forgive the fact that I kept names from copy pasting that do not reflect what this parameter is actually for: in my case it’s a read-only RMS display which also needed to be shown in the UI as dB, so I figured I’d steal the Gain parameter from AGain and just switch it to read-only and keep all the methods that converted things nicely from [0,1] to [-infinity,0]. This is not relevant so please do not be distracted by it.
What matters is that when I comment out the last line, the project compiles again, but I guess in effect it also means my parameter is not going to be working properly.
I hadn’t touched the controller.cpp code at all, and here I was just rewriting how often RMS was getting evaluated in process() from processor.cpp, so I’m a bit confused/surprised about what happened. The code used to work just as it was. Could anyone help me figure out what the problem could be ?
While copying you did not copy the information that is set on the parameter with the method setUnitID. You can at first ignore that call. But you should read up on how a VST plug-in is structured in the documentation about parameters and units.
Thank you for replying. I’m not sure I understood your answer.
“Copy the information that is set on the parameter with the method setUnitID”.
Do you mean that the setUnitID method is overridden in the class GainParameter ? Looking at the AGain example, I did not see this method being overridden and when I use the “Go to definition” feature of Visual Studio, I land in vstparameters.h, and the method simply states:
unitInfo.id = 1;
unitInfo.parentUnitId = kRootUnitId; // attached to the root unit
Steinberg::UString (unitInfo.name, USTRINGSIZE (unitInfo.name)).assign (USTRING ("Unit1"));
unitInfo.programListId = kNoProgramListId;
unit = new Unit (unitInfo);
I see unitInfo there, and unit seems to be created from it, I had hoped that would be enough.
But I think I must have misunderstood your answer. I will read more about the units link you have provided me, I remember reading the parameters section already.
After reading up more on the links you provided, I think I actually do not need the “Unit1”, and only need the “GainParameter” class with overrides on toString and fromString methods. I’ve edited out of my code the parts relevant to Unit1 and things seem to work just fine.
I would still be curious to understand what went wrong, but for my current use-case it is not critical anymore.