PLshuf dynamic scope Pshuf variant
Part of: miSCellaneous
Inherits from: PL_ListPattern
Takes Symbol args for later reference by the Streams, which will read from variables in the Environments of their instantiation. See PLx suite. A PLshuf stream keeps a permutation until it ends or there is a list replacement. See PLshufn for ongoing choice of new permutations.
See also: Pshuf, Pshufn, PLshufn, PLrand, PLwrand, Event patterns and Functions, VarGui, VarGui shortcut builds
Creation / Class Methods
*new (list, repeats, envir)
Creates a new PLshuf object.
list - Symbol or Pshuf 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 Pshuf 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, PLshuf(\a),
\dur, 0.2
);
// prepare Environment
~a = (67..72);
)
x = p.play;
// replace array elements ...
~a[0] = 63;
// ... or whole arrays
// evaluating more than once gives a newly chosen permutation
~a = (60..65);
x.stop;
//////////////////////
// placeholder may also get lists of event patterns
(
p = PLshuf(\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;