Excerpting an Envelope

Hi there -

I’ve been working with some long envelopes. I’d like to be able to take a piece of a bigger envelope and use it to generate a new envelope.

For instance, with something like this
a = Env.new([0, 1, 0], [1, 2000]).plot;

Is there a simple way to pull out the first 300 ms and put it into a new envelope? I’m sure I could write a more complex bit of code where I do a set of mathematical operations on the specs - but I’m wondering if there are any methods built-in that I might be missing.

Thank you!

There’s a built-in at method which at least helps with the slicing (in that you can find the value at a specific point in time). This can get you most of the way - the only thing that will be missing is matching the curves between breakpoints in the trimmed envelope - which obviously won’t stay the same if you trim a curve half-way (maybe there’s a way to adjust the curves mathematically to fit the previous shape, but it’s not intuitively obvious to me). You would still need to adjust the levels and times arrays to reflect the new times and levels after the trim.

Well I just poked around for a sec, haven’t really verified but this visually seems to work out?

The issue is trying to split a curve like this into two pieces, first naive attempt doesn’t work as scztt says

e = Env([0, 1], [1], -4);
f = Env([0, e[0.5], 1], [0.5, 0.5], -4);
[e, f].plot

But this looks perfect:

e = Env([0, 1], [1], -4);
f = Env([0, e[0.5], 1], [0.5, 0.5], -4/2);
[e, f].plot

And if it’s not evenly split in the middle, adjust the curve for each segment according to percentage of the total:

e = Env([0, 1], [1], -4);
f = Env([0, e[0.25], 1], [0.25, 0.75], [-4 * 0.25, -4 * 0.75]);
[e, f].plot

And incidentally the exponential curve does seem to just work:

e = Env([0.01, 1], [1], \exp);
f = Env([0.01, e[0.5], 1], [0.5, 0.5], \exp);
[e, f].plot

Also obviously the linear curve will be fine. Don’t know how you would go about splitting sine shapes…

1 Like