Using Pfuncn to wrap probabilities in Pwrand?

Hey!

I’m trying to change the probablities inside a Pwrand in a pattern with my MIDI-controller.

(
~p4_top = 100;
~prob1 = 0.7;
Pdef(\p6,
	Pbind(
		\type, \midi,
		\midiout, ~synth,
		\midicmd, \noteOn,
		\midinote, Pwrand([Pseq([61,63,65,64,66,74],1),Pwhite(60,Pfuncn({~p4_top},inf),5)],[0.3,0.7],inf),
		\dur, Pwrand([Pwhite(0.01,0.1,3),Pwhite(0.5,0.8,1)],[Pfuncn({~prob1},inf),Pfuncn({1.0-~prob1},inf)],inf)
	);
);
)

It works fine when changing the upper range of the Pwhite on the \midinote argument, but for some reason it doesn’t take the Pfuncn as a valid argument for probablities in the Pwrand. Is there a way around this?

Martin

Hi,

Pwrand allows sequencing of probabilities, but then it must be a Pattern / Stream, not an Array. BTW instead of Pfuncn you could use Pfunc, then you don’t have to set repeats to inf.

(
~prob = 0.6;

p = Pbind(
	\dur, 0.2,
	\midinote, Pwrand(
		[Pwhite(60.0, 65, 3), Pwhite(80.0, 85, 1)],
		Pfunc { [~prob, 1 - ~prob] },
		inf
	)
).play
)

~prob = 0.1;

p.stop
1 Like

I see!! Thank you very much for the info. Much Appreciated!