Hi all,
are we sure that using:
Code:
mValue = floor(0.5 + mValue / mStep) * mStep;
for stepping values is a good deal between Control and Param?
Example.
Let say I tweak my IKnob from the GUI, which will change the linked Param's mValue (which is a double, where I've set a step of 0.1).
Let say that the (normalized) tweaked value correspond (once converted in "real" mValue within SetNormalized) exactly to a rounding edge point; 0.05 in our example, which can be exactly expressed in floating point notation.
The calculated (and stepped) mValue become (with the stepping formula used by IPlug) 0.10000000000000001; so the stepped value we will use for audio is 0.1 (well, not exactly 0.1, but we will consider it 0.1, approximation is not important here).
The problem is that the label that the IKnob will show (using default WDL_string, which operate with the vsnprintf family):
Code:
mTextValue.SetFormatted(MAX_PARAM_DISPLAY_LEN, %.1f, 0.05, pParam->GetLabelForHost());
will be 0.0, because it use a different "round" method (which will depends
by the compiler and os).
So basically, you work with audio around 0.1, but the knob will display 0.0.
Heres the code with the test I did:
http://coliru.stacked-crooked.com/a/b9084e6001eb85e7
I know there are very few values/situations for these scenario... but... it could happens! Do you just ignore it?
If I'm unlucky, and I set the knob to the value above for a Pitch param, it will play +1 semitones even if the knob show +0 semitones...