Iterate over an array of frequencies in a Pdef specifying waiting time

Hi to all

is there any way to specify how long a Pseq should wait until it reads the next element in an array?

(
Pdef(\under, Pmono(
\undercurrent,

\freq1, Pseq([50, 45, 75, 89],  inf).trace, //here! :)
\freq2, Pseq(~underC.freq2, inf),

\atk, 0.1,
\sus, 10,
\rel, 1,
));

);

Thanks!!

That’s the role of the \dur parameter that tells when the next Event will be built and played. But it means that all your Pseq will be incremented at the same time.
If this is not what you want (you want one Pseq to progress at a slower pace), then you could look at the Pgate that lets advance a Pattern upon reception of a true signal.

Simple example:

(
Plazy({
	Pbind(\dur, 1, 
		\next, Pfunc({0.3.coin} ).trace, 
		\degree, Pgate(Pseq((0..7)),inf,\next).trace,
	)
}).play;
)

The “true” signal is given thru the key \next which is randomly set to true/false.

A more complicated example, where time is used.

(
Plazy({
	var time=1.rrand(10).debug("delta"); // random waiting time
	var prev=0;
	Pbind(\dur, 1, 
		\elapsed, (Ptime.new-Pfunc{prev}).trace,
		\next, Pfunc({|e| if (e.elapsed>time){prev=prev+time; time=1.rrand(10).debug("delta"); true;}{false}}), 
		\degree, Pgate(Pseq((0..7)),inf,\next),
	)
}).play;
)

A waiting time is randomly computed.
The at each iteration of the Pbind, the Pbind execution time (Ptime) is compared to that waiting-time. If >, then it sets the key \next to “true” which triggers the Pgate.

1 Like

Also take a look at the Pstep class, which let’s you step through a parameter with durations independent of the \dur parameter. So, for example, Pbind(\dur, 1, \freq, Pstep(Pseq([100, 200, 300]), 2) would produce 1 Event per beat, but only pull a new \freq every 2 beats.

1 Like

Hi, thanks to both! this is great and perfectly clear :slight_smile: