Extracting from already made Env its levels and Times

Hi there!

I was wondering if there is a way to extract data (levels and times) from an Env that has already been made?
I want to use its timing for an other envelope with different levels.

thank you!

Hi,
yep, quite straight:

e = Env.perc  // default vals
e.levels
e.times

Thanx for the fast reply!

Unfortunately this seems not to work at my case.

I am trying to do the following:

(
SynthDef(\envArray, { |out = 0, freq = 440, amp = 0.1, timeScale = 1, gate = 1|
var sig, env, envArray, envSig;
envArray = Env([0, 1, 0, 0, 0, 0, 0], [1, 1, 0, 0, 0, 0]).asArray;
env = \env.kr(envArray);
envSig = EnvGen.kr(env, gate, timeScale: timeScale, doneAction: 2);

//env.times is not working here
sig = SinOsc.ar(envSig);
Out.ar(out, sig)
}).add;
)

(
p = Pbind(
\type, \on,
\instrument, \envArray,
\envData,Pn(Pseq([
[[40, 50, 600], [1, 1]]
])),
\env, Pkey(\envData).collect { |x| Env(*x) },
\timeScale, Pfunc { |e| e.dur / e.envData[1].sum },
\dur, Pseq([2],inf)*Pkey(\timeScale),
).play;
)

when the env is inside the synthdef I want to change its timing in order to match with an other synth’s timing so the two envelopes hit together. I am passing through a bus (its not on this example i posted)
a sustain value inside the \envArray synth which then I use it to create smaller timing that adds up to the sustain passed previously in order to use it in a new envelope.

how would I do it here?

thank you!!!

Ah, ok, there was no hint in your first post that you need that server-side.
I can think of two options:

1.) You can extract from the converted array. This looks like a bit of a hack, but if you regard the result of the conversion it becomes pretty clear, especially in the example given:

 // in lang

~env = Env((1..7) * 100, (1..6) * 1000).asArray;

~levels = ~env[0, 4..24]; // short for ~env[[0, 4, 8, 12, 16, 20, 24]]
~times = ~env[5, 9..25];

// or in SynthDef

{
	// Env used as frequency container
	var env = \env.kr(Env((1..7) * 100, (1..6) * 1000).asArray);
	// Select does expand
	var times = Select.kr((0, 4..20), env);
	times.poll;
	SinOsc.ar(times, 0, 0.1).sum
}.play

2.) You could also send times as array, but that would be a bit redundant - you could alternatively send levels and times separately and rewrite the SynthDef.

I’d tend to use the first variant here.

BTW: in your Pbind e.dur will always take the default dur 1 in this line as dur is defined below.

\timeScale, Pfunc { |e| e.dur / e.envData[1].sum },

Thanx a lot this was very helpful!!
and sorry for the late reply!!