I am now able to run my Faust instrument inside of an IPlug2 app, and I was able to get far enough to link IPlug params to Faust params and create controls that at least start out matching the DSP defaults. However, changing the controls in the UI does nothing:
Relevant code snippets:
// near the top of the constructor
mFaustProcessor.CreateIPlugParameters(this, 0, mFaustProcessor.NParams());
pushBandParams(0);
pushBandParams(1);
pushBandParams(2);
pushBandParams(4);
pushBandParams(6);
pushBandParams(8);
pushBandParams(10);
pushBandParams(12);
pushBandParams(14);
pushBandParams(16);
// inside mLayoutFunc
for (auto band = 0; band < mBandParams.size(); band++) {
auto &bandParamIds = mBandParams.at(band);
IRECT bandStrip = b.GetGridCell(0, band, 1, mBandParams.size());
IRECT slider = bandStrip.ReduceFromTop(150);
pGraphics->AttachControl(new IVSliderControl(slider, bandParamIds.gain, "Gain"));
IRECT envKnobs = bandStrip.ReduceFromTop(250);
pGraphics->AttachControl(new IVKnobControl(envKnobs.GetGridCell(0, 0, 4, 1), bandParamIds.attack, "Attack"));
pGraphics->AttachControl(new IVKnobControl(envKnobs.GetGridCell(1, 0, 4, 1), bandParamIds.decay, "Decay"));
pGraphics->AttachControl(new IVKnobControl(envKnobs.GetGridCell(2, 0, 4, 1), bandParamIds.sustain, "Sustain"));
pGraphics->AttachControl(new IVKnobControl(envKnobs.GetGridCell(3, 0, 4, 1), bandParamIds.release, "Release"));
}
// the helper pushBandParams function. this iterates over all plugin params - initialised by
// mFaustProcessor.CreateIPlugParameters - and builds a map of partial number to param ids
// based on what I called the parameters in the Faust code.
void WeirdOrgan::pushBandParams(int bandId)
{
std::string gainName = "partial gain " + std::to_string(bandId);
std::string attackName = "attack " + std::to_string(bandId);
std::string decayName = "decay " + std::to_string(bandId);
std::string sustainName = "sustain " + std::to_string(bandId);
std::string releaseName = "release " + std::to_string(bandId);
int gainId = -1;
int attackId = -1;
int decayId = -1;
int sustainId = -1;
int releaseId = -1;
for (int i = 0; i < NParams(); i++) {
auto name = GetParam(i)->GetName();
if (gainName.compare(name) == 0) {
gainId = i;
continue;
}
if (attackName.compare(name) == 0) {
attackId = i;
continue;
}
if (decayName.compare(name) == 0) {
decayId = i;
continue;
}
if (sustainName.compare(name) == 0) {
sustainId = i;
continue;
}
if (releaseName.compare(name) == 0) {
releaseId = i;
continue;
}
}
mBandParams.emplace_back(gainId, attackId, decayId, sustainId, releaseId);
}