-
Multiple linear() in an expression
I’m trying to have multiple linear() ramps defining a value at different times…
My arrays seem to be all being defined correctly… however, when I try to conditionally set the ram (see note in all caps below), I’m not getting the expected results… what am I doing wrong?
beats_per_min = 104
sec_per_min = 60
beats_per_bar = 4
seconds_per_beat = sec_per_min / beats_per_min
section_bars = [0,2,8,8,4,8,2,8,4,8,2,8,8,9,8];
// set the bar number at the end of each section
section_bars_cum = new Array(section_bars.length)
section_bars_cum[0]=0
for(arrIndex = 0 ; arrIndex< section_bars.length-1; arrIndex++)
{
section_bars_cum[arrIndex+1]= section_bars_cum[arrIndex]+section_bars[arrIndex+1]
}
// set the time(in sec) at the end of each section
section_time_cumulative = new Array(section_bars.length)
for(arrIndex = 0 ; arrIndex< section_time_cumulative.length; arrIndex++)
{
section_time_cumulative[arrIndex]= section_bars_cum[arrIndex] * beats_per_bar * seconds_per_beat
}
// compute each linear()
var linears = new Array(section_bars.length)
for(arrIndex = 0 ; arrIndex< section_bars.length-1; arrIndex++)
{
linears[arrIndex]= linear(time, section_time_cumulative[arrIndex], section_time_cumulative[arrIndex+1],100,0)
}
/// THIS IS WHERE I AM HAVING ISSUE
// try to aggregate all the linear()
if(section_time_cumulative[0]>= time && section_time_cumulative[1]<=time)
{
linears[1]
}
else if(section_time_cumulative[1]>= time && section_time_cumulative[2]<=time)
{
linears[2]
}