PLshufn dynamic scope Pshufn variant 


Part of: miSCellaneous


Inherits from: PLshuf


Takes Symbol args for later reference by the Streams, which will read from variables in the Environments of their instantiation. See PLx suite. A PLshufn stream keeps on choosing permutations for the current list. See PLshuf for keeping one permutation.



See also: Pshufn, Pshuf, PLshuf, PLrand, PLwrand, Event patterns and Functions, VarGui, VarGui shortcut builds



Creation / Class Methods


*new (list, repeats, envir)

Creates a new PLshufn object.

list - Symbol or Pshufn list arg. 

If a Symbol is passed, list can be assigned to an envir variable later on.

This lists's elements can be dynamically replaced by Patterns or Streams.

repeats - Symbol or Pshufn repeats arg. Defaults to inf.

If a Symbol is passed, repeats can be assigned to an envir variable later on.

envir - Dictionary or one of the Symbols

\top, \t (topEnvironment), \current, \c (currentEnvironment).

Dictionary to be taken for variable reference. Defaults to \current.




Examples


(

s = Server.local;

Server.default = s;

s.boot;

)

(

p = Pbind(

\midinote, PLshufn(\a),

\dur, 0.2

);


// prepare Environments


e = (a: (67..72));

f = (a: (77..82));

)


e.use { x = p.play(quant: 0.2) };

f.use { y = p.play(quant: 0.2) };



// replace array elements ...


e.a[0] = 97;

f.a[0] = 98;



// ... or arrays 


(

e.a = [80, 81];

f.a = (70..73);

)


e.a[0] = Pwhite(60, 65, 1) + [0, -5, 29.5];


y.stop;

x.stop;




//////////////////////



// placeholder may also get lists of event patterns


(

p = PLshufn(\a);


~a = [ Pbind(

\midinote, Pwhite(60,65,3),

\dur, 0.2

),

Pbind(

\midinote, Pwhite(80,85,3),

\dur, 0.2

),

Pbind(

\midinote, Pwhite(80,85,6),

\dur, 0.1

)

];


x = p.play;

)



// replace array element


(

~a[2] = Pbind(

\midinote, Pwhite(70,75,3) + [0, 5],

\dur, 0.15

);

)


// replace whole array


(

~a = [ Pbind(

\midinote, Pwhite(60,65,3) + [0, 5],

\dur, 0.15

),

Pbind(

\midinote, Pwhite(70,80,2) + [0, 4],

\dur, 0.25

),

Pbind(

\midinote, Pwhite(95,100,6) + [0, -9],

\dur, 0.05

)

];

)


x.stop;