Hi Martin!
I might be wrong since I haven’t tested your setup directly, but I think the core issue is that linears[] isn’t a function. When you do:
linears[i] = linear(time, t0, t1, 100, 0);
linear() is evaluated immediately, so each linears[i] just stores a number for the current frame. There’s nothing to “call” later.
Your range checks also look inverted. You probably want:
if (time >= t0 && time < t1)
instead of
t0 >= time && t1 <= time
A simple pattern that might solve it is to calculate the ramp only for the active section:
for (i = 0; i < section_time_cumulative.length - 1; i++){
t0 = section_time_cumulative[i];
t1 = section_time_cumulative[i+1];
if (time >= t0 && time < t1){
value = linear(time, t0, t1, 100, 0);
break;
}
}
value;
Hopefully that points you in the right direction.