Closed schwaaa closed 1 year ago
hmm yeah i agree if you want to span the entire stepped range in equal space increments you don't want (int)x
you want (int)std::round(x)
trunc()
is the decoding of the parameter value which is stepped, so its effective value is an integer not a double.
Please try: trunc(clap_value) + round(clap_mod + plug_mod)
or round(ftrunc(value) + .5 + clap_mod + plug_mod)
Yeah I understand where the idea is coming from and I would have probably also went with round instead of truncating, but in practice it shouldn't matter. Or at least, I'd consider setting non-integer values for a stepped parameter to be invalid behavior. Is that assumption correct?
OK, when dealing with floating point input (like an LFO) we will move the quantizing step into the host call for consistency. Meaning, the host will round the values (not truncate) and send only integer values to the plugin.
https://github.com/free-audio/clap/blob/84531b931c12285097746a9cae77690a680b8aa0/include/clap/ext/params.h#L85
The comment in params.h specifies that stepped parameter values should be converted from floating point by truncating. For any process that represents the entire [min,max] parameter space -- for example, an LFO, or visual display of an envelope -- it's more useful if values are converted by rounding, or else by dividing [min,max] into equal segments. Rounding is simplest so I would suggest changing the comment to
// if so the double value is converted to integer by rounding
Relevant discussion here, posts 4 and 5: https://forum.cockos.com/showthread.php?t=273794