Penv timing management?


I’m using Penv a lot lately in my patterns, for transformations in time. The only problem is, of course, the “times” attribute (equivalent to Env) doesn’t really work, meaning it doesn’t translate in actual seconds but goes on its own time pretty randomly, being controlled by the Event flow. Is there any workaround or other similar objects that are actually time accurate?
Maybe Pseg?


I took a look at the source code. There’s no randomness.

It’s calculating a time value as “now” (in beats, not seconds) minus the number of beats at the moment when the envelope started: now - start. This is time-accurate. Then it’s calculating the envelope’s value at that time index.

Pseg uses the same “now - start” technique, just going segment-by-segment instead of specifying the envelope all at once.

If I do this to plot the Penv with constant event durations, I don’t see any distortion of the envelope shape.

var resp;

a =;

p = Pbind(
	\dur, 0.1,
	\env, Penv([0, 1, 0], [1, 2], \sin)
).collect { |ev|

resp = SimpleController(p)
.put(\stopped, {
	defer { a.array.plot }

So I don’t know what you mean by “‘times’ … [going] on its own time randomly.” I haven’t been able to reproduce that. Can you be more specific?