PLrand dynamic scope Prand 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.
See also: Prand, PLwrand, PLshuf, PLshufn, Event patterns and Functions, VarGui, VarGui shortcut builds
Creation / Class Methods
*new (list, repeats, envir)
Creates a new PLrand object.
list - Symbol or Prand 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 Prand 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;
)
// define Pattern and prepare Environments
(
p = Pbind(
\midinote, PLrand(\a),
\dur, 0.2
);
e = (a: (67..72));
f = (a: (77..82));
)
// start together or not, but sync anyway
e.use { x = p.play(quant: 0.2) };
f.use { y = p.play(quant: 0.2) };
// replace array elements ...
f.a[0] = 97;
e.a[0] = 96;
// ... or arrays
f.a = (72, 72.5..77);
e.a = [60];
e.a = [Pseq([60, 47.5]) + [0, 5], [61, 65.5]];
x.stop;
y.stop;
//////////////////////
// placeholder may also get lists of event patterns
(
p = PLrand(\a);
~a = [ Pbind(
\midinote, Pwhite(60,65,3),
\dur, 0.2
),
Pbind(
\midinote, Pwhite(80,85,3),
\dur, 0.2
)
];
x = p.play;
)
// replace array element
(
~a[0] = Pbind(
\midinote, Pwhite(70,75,3) + [0, 5],
\dur, 0.15
);
)
// replace whole array
(
~a = [ Pbind(
\midinote, Pwhite(60,65,3),
\dur, 0.05
),
Pbind(
\midinote, Pwhite(70,90,2),
\dur, 0.25
)
];
)
x.stop;