2 // InterplEnvs are a fixed duration
3 // Envelope specification for an IEnvGen, InterplEnv is not a UGen itself
5 InterplEnv : AbstractEnv {
8 *new { arg levels=#[0,1,0], times=#[1,1], curve='lin', offset = 0.0;
9 ^super.newCopyArgs(levels, times, curve).offset_(offset)
15 ^env.asArray.envAt((time - offset).max(0))
19 ^Env(this.levels, this.times, this.curves);
22 storeArgs { ^[levels, times, curves, offset] }
24 plot { arg size = 400, bounds, minval, maxval, parent;
25 this.asEnv.plot(size, bounds, minval, maxval, parent);
29 var contents, curvesArray;
30 contents = [offset, levels.at(0), times.size, times.sum];
31 curvesArray = curves.asArray;
32 times.size.do({ arg i;
33 contents = contents ++ [
35 this.class.shapeNumber(curvesArray.wrapAt(i)),
36 this.curveValue(curvesArray.wrapAt(i)),
45 // InterplXYC([0, 0, \lin], [1, 2, \sin], [2, 0])
46 // at time 0, value 0, lin to time 1, value 2, sin to time 2, value 0
48 InterplXYC : InterplEnv {
51 var x, y, c, times, levels, curves, offset;
52 #x, y, c = xyc.flat.clump(3).flop;
55 times = Array.fill(x.size - 1, { arg i; x[i + 1] - x[i]});
56 c.removeAt(c.size - 1);
57 ^InterplEnv.new(levels, times, c, offset);
61 InterplPairs : InterplEnv {
63 *new { arg pairs, curve;
64 var x, y, times, levels, offset;
66 #x, y = pairs.flat.clump(2).flop;
69 times = Array.fill(x.size - 1, {arg i; x[i + 1] - x[i]});
70 ^InterplEnv.new(levels, times, curve, offset);
74 // pairs is an array of [time, [val, val, val], time, [val, val, val]]
75 // format. All chords MUST have the same number of members
81 ^super.new.init(pairs);
86 times = Array.newClear(pairs.size * 0.5 - 1);
87 points = Array.fill(pairs.size * 0.5, {arg i; pairs[i * 2]});
88 points.doAdjacentPairs({ arg val1, val2, i; times[i] = val2 - val1 });
89 envs = Array.fill(pairs[1].size, {arg i;
91 levels = Array.fill(pairs.size * 0.5, {arg j;
98 ^Array.fill(envs.size, { arg i; envs[i][time] });