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



Creation / Class Methods


*new (list, repeats, cutItems, envir)

Creates a new PLtuple object.

list - Symbol or Ptuple 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 Ptuple repeats arg. Defaults to inf.

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

cutItems - Symbol or Boolean or Integer (0 or 1) or a Function returning Boolean or Integer.

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

Determines if list items, which are Patterns or Streams themselves,

will be finished if a replacement occurs during their embedding, or if they will be replaced immediately. 

The latter is the default behaviour (default value true).

For protecting whole lists from immediate replacements see PLn.

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 = PLtuple(\a);



// prepare current Environment

// PLtuple defaults to repeats = inf,

// so inner Patterns are repeatedly embedded


~a = [ Pshuf((60..65)), 70, Pshuf((75..80)) ];



// run


x = Pbind(\midinote, p, \dur, 0.2).trace.play;



// replace elements


~a[0] = 72.5;


~a[1] = 74.5;


~a[2] = Prand([85, 86, 87]);



// replace array


// Ptuple and PLtuple start with new embedding of ALL patterns

// if one ends, so here default repeats = inf of PLshuf has no effect:

// new permutation with every loop as Pshuf has repeats = 1


~a = [ Pshuf((60..65)), 70, PLshuf((75..80)) ];



// both Patterns have repeats = inf,

// permutation is kept


~a = [ PLshuf((60..65)), 70, PLshuf((75..80)) ];



x.stop;