PLwrand dynamic scope Pwrand 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: Pwrand, PLrand, PLshuf, PLshufn, Event patterns and Functions, VarGui, VarGui shortcut builds
Creation / Class Methods
*new (list, weights, repeats, envir)
Creates a new PLwrand object.
list - Symbol or Pwrand 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.
weights - Symbol or Pwrand weights arg.
If a Symbol is passed, weights can be assigned to an envir variable later on.
Can be dynamically replaced by Patterns or Streams.
repeats - Symbol or Pwrand 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(
\freq, 50 * PLwrand(\a, \w),
\dur, 0.01,
\amp, 0.02
);
// prepare (current) Environment
// give low overtones more weight
~a = (1..8);
~w = (8..1).cubed.normalizeSum;
)
x = p.play;
// reverse overtone weights
~w = (1..8).cubed.normalizeSum;
// replace with Pattern for weights,
// PLseq taken as repeats defaults to inf
~w = Pstutter(50, PLseq([(8..1), (1..8)].collect { |x| x.cubed.normalizeSum }));
// replace arrays (must be sufficiently long)
~a = (3..10);
~a = (5..12);
~a = (1,3..15);
~a = (1,4..22);
~a = (1,5..29);
~a = (1,6..36);
~a = (2,7..37);
~a = (3,8..38);
~a = (4,9..39);
~a = (5,10..40);
x.stop;