Hi there!
I have a custom IControl where I want to have an activeId parameter that can be set by the IControl to determine the “active element” I am working with.
The issue is that the standard way to set a parameter in an IControl, i.e. SetValue only seems to set the value to between 0 and 1, then when I try and read it back afterwards using GetValue() or GetParam(id)->Value()
the result is no longer the integer I wanted to set.
i.e.
inside the custom IControl:
SetValue(double(11), paramId);
Then later:
int val = static_cast<int>(GetValue(paramId));
same with
int val = GetParam(paramId)->Int();
doesn’t return 11, it returns 1.
The weirdest thing is, I’ve looked through the source code, and I have absolutely no idea how it is doing this. There doesn’t seem to be any evidence of clipping the value, yet it is.
The only thing I can see is that:
void IControl::SetDirty(bool triggerAction, int valIdx)
Seems to (IMO incorrectly) clip the value to be between 0 and 1 when it executes. Is that a bug? Why isn’t the value instead clipped to what it’s original definition is like it should be?
Ah… I see that in ISwitchControlBase
there is a “hack” to get around this:
int GetSelectedIdx() const { return int(0.5 + GetValue() * (double) (mNumStates - 1)); }
But honestly, that feels pretty ugly and inefficient. Is there a better way to do this?
I.e. is there the concept in iPlug2 of a parameter that assists with storing a UI modal state. I.e. if I want a UI that stores the last interaction to highlight some region, I don’t want that parameter to be visible at all to the host, I just want it to be accessible to the UI and be updated as the user interacts with it, but store an integer id. And then have multiple other controls linked to it to also then update their UI state.