This line should be relTimes.sort{arg a, b; a < b};
to sort the envelope times according to the following line:
The following might be a possible way to do this with a SynthDef (but I think there should be a better way than my suggestion):
(
SynthDef(\randSynth, { |out=0|
var num, freqs, relTimes, envs, sig;
num = 12;
freqs = { Rand(31, 63).poll(0).midicps } * (1.. num);
relTimes = num.collect { |i| Rand(1, 5.0 * (i + 1) / num) };
envs = Env.perc(0.01, relTimes).kr / (1.. num);
FreeSelf.kr(
envs.collect { |thisEnv|
Done.kr(thisEnv)
}.product
);
sig = SinOsc.ar(freqs) * envs / num;
sig = sig.sum ! 2/* * [1, -1]*/;
Out.ar(out, sig)
}).add
)
Synth(\randSynth)