"GetGUI()->SetControlFromPlug(Idx, value)" equivalent method in iPlug2? - SOLVED

I am trying to update a bitmap (frame number) in response to plugin action. In iPlug1 it was simply "GetGUI()->SetControlFromPlug(ControlIdx, value) but that is no longer the case in iPlug2.

I have studied the iPlugControls project - and similar threads here - and have tried what appears to be the means for updating a multi-frame bitmap control - but so far no go.

I have initialized the IBitmap control like this:

    IBitmap bitmap = pGraphics->LoadBitmap(CLIPLED_FN, 2);// bitmap has two frames
    pGraphics->AttachControl(new IBitmapControl(215, 109, bitmap, kCtrlTagLED1))

I have this at the end of the Process block, outside the for loop:

mSendUpdate = true;

and attempted to update the control like this:

void MyPlugin::OnIdle()
{
  if (mSendUpdate)
  {
   if (GetUI())
    {
      GetUI()->GetControlWithTag(kCtrlTagLED1)->SetValue(value);//value 0.0 - 1.0
      GetUI()->SetAllControlsDirty();
    }
    mSendUpdate = false;
  }
}

But it does not work. Bitmap stays at frame 0 regardless of “value”. Also tried “SetValueFromDelegate(value)” with same result (doesn’t do anything).

So what is the approach to updating a bitmap?

Also, I noticed that the “AttachControls” function doesn’t seem to know the difference between kControls and kCtrlTags even though enumerated in separate EParams and ECtrlTags blocks. Both interpret as the same int values according to MSVS and end up crosscoupling. What’s the problem HERE? Almost seems like it should be like this:

enum EParams
{
  kControl1 = 0,
  kControl2,
...
  kNumParams
};

enum ECtrlTags
{
  kCtrlTag1 = kNumParams,// should continue rather than start at zero?
  kCtrlTag2,
...
  kNumCtrlTags
};

I don’t see “kNumCtrlTags” used anywhere so maybe something is missing?

SOLVED!

Problem was in my AttachControl statement. Correct format is this:

    pGraphics->AttachControl(new IBitmapControl(215, 109, bitmap), kCtrlTagLED1);

The control tag ID goes OUTSIDE IBitmapControl and is part of AttachControl. The bitmap itself, as in iPlug1, is set to no parameter (-1). I was replacing the parameterID with the CtrlTag and that’s NOT how you do it in iPlug2.

yes that’s it.

Control tags are unique integer IDs for controls, don’t have any connection to paramIDs which are unique IDs for parameters.

here is a simple example of how to do it, bearing in mind, its just setting the control value based on the first sample in the block. The ISender pattern used in the examples shows how you can use a queue to send more data for visualization.

1 Like