Hi list,
What would be the best way to create an array durations which follow
the three conditions:
_growing exponentially, or at least increasing (or decreasing
contrary depending on the case)
_have a fixed number of items
_first value has a fixed minimum duration (0.125), last value has a
fixed maximum duration (1)
my code somehow does it but it is clumsy, any better idea on how to
proceed? cheers F.
Accel Accelerando array
st=1 first value
max=4 bar length
add=0.2 substracted random value
min=0.05 added to random value
minimum=0.08 smallest value played
st must be smaller than max
Accel.new.init(1, 4, 0.05, 0.01, 0.125);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Accel
{
var <>last;
var <>z;
var <>x;
var <>adder;
var <>y;
init{arg st=1, max=4, add=0.2, min=0.05, minimum=0.08;
last=st;
z=[st];
x=st;
while({ ((z.sum) < max) && ( x > minimum) },{
y = add.rand+min;
x=(last-y);
z=z.add(x);
last=x;
});
if( ((z.sum) > max),{
z.removeAt(z[z.size-1]);
});
z.size.do({arg i;
if( (z[i].isNegative) ,{ z.removeAt(i) });
if( (z[i] < minimum) ,{ z.removeAt(i) });
});
adder = (max-(z.sum))/(z.size);
z.size.do({arg i;
z.put(i, z[i]+adder)
});
^z;
}
}