Typical greater vs. greater-or-equal case. This especially fixes fades
with zero delays. A zero delay in the two-argument form means no fade at
all, but previously this faded over a single frame, since the code used
"greater" semantics, while "greater or equal" is required here.
Notably, this avoids blinking/flickering in some tightly timed karaoke
scripts.
{
unsigned a;
double cf;
- if (now <= t1) {
+
+ if (now < t1) {
a = a1;
} else if (now >= t4) {
a = a3;
- } else if (now < t2) { // and > t1
+ } else if (now < t2 && t2 > t1) {
cf = ((double) (now - t1)) / (t2 - t1);
a = a1 * (1 - cf) + a2 * cf;
- } else if (now > t3) {
+ } else if (now >= t3 && t4 > t3) {
cf = ((double) (now - t3)) / (t4 - t3);
a = a2 * (1 - cf) + a3 * cf;
- } else { // t2 <= now <= t3
+ } else { // t2 <= now < t3
a = a2;
}