Duty like ugen that also outputs the duration?

I feel like this exists, but I can’t seem to find it (maybe it doesn’t exist) but i’m looking for something really simple.
I’m looking for a Demand ugen that takes a demand rate list of durations and

  1. requests the next duration after the last duration has elapsed
  2. outputs the duration

so it would demand a duration from the list, lets say it gets 2.
it will output 2 and also wait 2 before it demands the next duration
then it gets 1.5
it outputs 1.5 and waits 1.5 before demanding the next duration.

I feel like this exists, but if it doesn’t what would be the best way to do this. I’ve tried

var durs = Drand(2.pow(-2..2), inf);
// just outputs each time
Duty.ar(durs);
// seems like when it's requesting the dur and requesting the level, it's getting different values from the Drand
Duty.ar(durs, 0, durs);

Hi and welcome,

the point here is that demand rate ugens behave very much like Streams, not like Patterns in the SC language. Hence, the number pulled for duration will not be pulled again for the value to return, it will already be the next one. One possible solution: the source should output twice. This can be done with Ddup:

(
{
	var durs = Ddup(2, Dseq([1, 2, 3] / 100, inf));
	Duty.ar(durs, 0, durs);
}.plot(0.12)
)

Perhaps another maybe more idiomatic solution would just use a routine instead. I tend to prefer to have something like durations be client side, especially if they’re this long. There really isn’t a need for ugen to be audio rate here if you do go server side with a demand ugen. 0.25 is a pretty long duration and the others are just longer.

This should work, but I don’t currently have access to SC just as a disclaimer.

fork{
     var dur, pows = (-2..2);
     loop{
          dur = 2.pow(pows.choose);
          dur.wait;
          dur.postln;
     }
};