Hi,

Based on the tuto Pattern Guide 06b: Time Based Patterns I wrote this little pattern with two keys controlled by an envelop:

```
(
p = Pseq([
Pbind(\instrument, \tic, // normal one
\seqlen, { rrand(2,10) }, // duration of the pattern
\pls, Env(#[0.8, 0.2, 0.6], #[2,2], \sin), // average duration between tics
\amp, 0.5,
\pan, Pgauss(0,0.3,inf),
\freq, Pif(Ptime(inf) <= 4, Env(#[220, 440, 220], #[2,2], \sin)), // frequency controled by envelop.
\dur, Pgauss(Pkey(\pls),Pfunc({|evt| evt[\pls]/8;}) ,inf) // time to next tic
),
Rest({1+1.rand})
], inf).play;
)
```

I compute a random length for the pattern (`\seqlen`

) and I’d like to have the envelops aligned on this duration. So I adapted the `Pif`

and the `Env`

accordingly but both lead to errors

```
(
p = Pseq([
Pbind(\instrument, \tic, // normal one
\seqlen, { rrand(2,10) }, // duration of the pattern
\pls, Env(#[0.8, 0.2, 0.6], #[Pkey(\seqlen)/2,Pkey(\seqlen)/2], \sin), // average duration between tics
\amp, 0.5,
\pan, Pgauss(0,0.3,inf),
\freq, Pif(Ptime(inf) <= Pkey(\seqlen), Env(#[220, 440, 220], #[Pkey(\seqlen)/2,Pkey(\seqlen)/2], \sin)), // frequency controled by envelop.
\dur, Pgauss(Pkey(\pls),Pfunc({|evt| evt[\pls]/8;}) ,inf) // time to next tic
),
Rest({1+1.rand})
], inf).play;
)
```

Il also tried with a `Pfunc`

with no better result.

How should I do ?