How to get the proper duration of an env in the Pattern context?

Hi everyone,
I’m trying to wrap my mind around on how could I pass the right amount of time to the Env
considering that I want the env long as \dur from the Pbindef?

        var env =
    	    levelBias: minAmp,

x = Pbindef(\test,     
    \instrument, \DcOuts,

TempoClock.default.tempo = 2

Thank you very much for your attention.

While we wait for some more expert voices about Patterns, here are my discoveries:

  • Only the clock knows durations in seconds? Duration values are in beats up until EventStreamPlayer plays the event on the clock
  • However, synths get a \dur in beats from patterns. And you can pass the tempo along as well, so that you can do your conversion inside the synth:
// receives \dur in beats, \tempo in bps.
SynthDef(\beatEnv){ |out=0|
  // convert dur in seconds
  var dur = \ / \; 
  var env =,timeScale:dur);
  dur.poll; // let's see some numbers in the post window, env);


// when changing tempo, synths get updated on the next event
TempoClock.default.tempo = 2;
TempoClock.default.tempo = 1;

I posted a slightly more advanced example of how to use envelope passing in a real workflow here:

Among other things, I’ve got a post-processing phase in \finish where I ensure all my Env parameters are actually Envs, and set their durations to 1…0. Then later, in the synth, I rescale them back to \sustain… this is a bit of a simplification, but I think it’s roughly the right approach for scaling env arguments, depending on use-case of course.