JS float-int conversion in REAPER v4.261
Behaviour differs for envelope and manual control: JS rounds (enveloped) or truncates (manual) for integer-based logical operators on values derived from sliders.
Please see the JS "effect" code below, a demo extracted from a bigger plugin.
Float value x (>=0) is derived from a control slider. The plugin also needs the integer part of x, either from rounding or from truncation.
BUT
under manual mousing of the slider, logical operators TRUNCATE to give the integer
AND
under envelope automation of the slider, logical operators ROUND to give the integer
for exactly the same plugin code.
Behaviour should be exactly the same in both cases?
There's no simple workaround (?) that make manual and automation work mutually consistently.
// A dummy JS patch to show float - integer conversion weirdness.
slider1:0<0,10,0.001>control "s"
slider2:0<0,10,0.001>derived "x"
slider3:0<0,10,0.001>integer "x_int"
slider4:0<0,10,0.001>different "x_int2"
@slider
// Compare: slider1 manually controlled vs slider1 under envelope control.
s = slider1;
x = s * 2; // x is a derived value, not even directly controlled,
slider2 = x;
x_int = x << 0; // yet this step TRUNCATES for manual control, and ROUNDS for envelope control!
slider3 = x_int;
x_int2 = x & 9999999; // another way of getting an int value: same problem
slider4 = x_int2;
|