Pbrown to create a list to be used in Pseq

Hello there,

I want to use Prown to create an array with 4 elements that will be used in a Pseq. I’d like the array to change after repeating twice.
I tried to use this method Pbind().collect({ |event| ~event = event; }) to capture values created by the Pbrown into an array, so that I can feed it into a Pseq in another Pbind:

(
~pc = Pbind(
	\type, \rest,
	\dur, 8,
	\test, Pfunc({ Pbrown(0,4,2,inf).collect{ |i| i; }.asStream.nextN(4) }).trace
).collect({ |event| ~event = event; });

~mel = Pbind(
	\dur, 1,
	\scale, Scale.minor,
	\degree, Pseq(~event[\test],inf).trace,
);
)
(
t = TempoClock(120/60);
~pcp = ~pc.play(t,quant:[8,0,0.1]);
~mp = ~mel.play(t,quant:8);
)
[~pcp,~mp].do(_.stop);

The environment variable ~event[\test] does seem to be updated every 8 beat, however — and despite using a timing offset — Pseq doesn’t seem to read from it.
Do I need to do sth extra to “update” the Pseq? I tried to embed the Pseq into:

  • Pfunc — Pfunc({Pseq(~event[\test],2)}) — only returns “a Pseq” and no sound
  • Pn — Pn(Pseq(~event[\test],2)) — same result as when Pseq isn’t embedded into anything

Also, if there is a better method than what I outlined here, please let me know!

Thanks,
cd

I think I found one solution in the meantime:

(
t = TempoClock(120/60);
~mel = Pbind(
	\dur, 1/2,
	\scale, Scale.minor,
	\degree, Pn(Plazy({Pseq(Pbrown(0,4,2,4).collect{ |i| i; }.asStream.nextN(4),2) })).trace,
).play(t);
)
~mel.stop;

Ie.:

  1. Create an array of 4 elements with Pbrown with the help of .collect{}.asStream.nextN()
  2. Place this 4-element array into a Pseq and set the Pseq’s repeat to 2, so it sequences through the same array twice before the array is changed
  3. Embed this Pseq into a Plazy, so the Pbrown().collect{}.asStream.nextN() inside the Pseq can be reevaluated after the Pbind has started.
  4. Since Plazy only repeats itself once by default, it needs to be embeded in a Pn so it repeats infinitely.

This way another Pbind doesn’t even need to created.