PLwalk dynamic scope Pwalk 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: Pwalk, Event patterns and Functions, VarGui, VarGui shortcut builds



Creation / Class Methods


*new (list, stepPattern, directionPattern, startPos, envir)

Creates a new PLwalk object.

list - Symbol or Pwalk 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.

stepPattern - Symbol or Pwalk stepPattern arg. Defaults to Prand([1, -1], inf).

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

Can be dynamically replaced by Patterns or Streams.

directionPattern - Symbol or Pwalk directionPattern arg. Defaults to 1.

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

Can be dynamically replaced by Patterns or Streams.

startPos - Symbol or Pwalk startPos arg. Defaults to 0.

If a Symbol is passed, startPos 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;

)

// definition for future reference in arbitrary Environments


p = PLwalk(\a, \step, \dir, \start);



// prepare current Environment


(

~a = (60, 64..102);

~step = 1;

~start = 70;

~dir = -1;

)



// run


(

x = Pbind(

\midinote, p + [0, 3], 

\dur, 0.1, 

\legato, 1.2

).play;

)



// replace with Patterns

// PLx ListPatterns default to repeats = inf


~step = PLrand([1, 2]);


~dir = PLseq([-1, 1]);



// replace list


~a = ~a - 1.5;



x.stop;




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



// placeholder may also get lists of event patterns



(

p = PLwalk(\a, \step, \dir);


~a = [ Pbind(

\midinote, Pwhite(60,65,1) + [0, -8.7],

\dur, 0.2

),

Pbind(

\midinote, Pwhite(70,75,2) + [0, -3.3],

\dur, 0.2

),

Pbind(

\midinote, Pwhite(80,90,3) + [0, -4.3],

\dur, 0.1

),

Pbind(

\midinote, Pwhite(90,100,2) + [0, 5.7],

\dur, 0.05

)

];


~step = 1;


~dir = 1;


x = p.play;

)



// replace step pattern, pending between two source patterns

// try evaluating several times


~step = PLseq([1, -1]);


~step = 1;



// replace array element


(

~step = 1;


~a[0] = Pbind(

\midinote, Pwhite(60,75,1) + [0, 5, 14, 19, 22],

\dur, 0.15

);


~a[3] = Pbind(

\midinote, Pseq((90..95)),

\dur, 0.05

);

)



// replace whole array


(

~a = [ Pbind(

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

\dur, 0.05

),

Pbind(

\midinote, Pwhite(70,90,2),

\dur, 0.25

),

Pbind(

\midinote, Pwhite(70,75,3),

\dur, 0.05

),

Pbind(

\midinote, Pwhite(80,95,3) + [0, -5.3],

\dur, 0.3

)

];

)


x.stop;