1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
TITLE:: Plet
summary:: Define a value within the scope (namespace) of a Plambda
categories:: Streams-Patterns-Events>Patterns>Data Sharing
related:: Classes/Plambda, Classes/Pget
DESCRIPTION::
link::Classes/Plet::/link::Classes/Pget:: are used to share data between patterns inside of a link::Classes/Plambda::
Plet defines a variable containing a pattern or data for sharing within the scope of a link::Classes/Plambda::.
Using the link::Classes/Pget:: class, the contents of this variable can then be accessed by key in other patterns within the link::Classes/Plambda::.
CLASSMETHODS::
METHOD:: new
ARGUMENT:: key
The name of the variable
ARGUMENT:: pattern
The contents of the variable
ARGUMENT:: return
If return is nil, the pattern will be returned.
If not nil, the contents of the return argument will be returned while the variable defined by the Plet will be set to the value of pattern
INSTANCEMETHODS::
METHOD:: storeArgs
METHOD:: embedInStream
ARGUMENT:: inval
METHOD:: pattern
METHOD:: silent
METHOD:: key
METHOD:: return
EXAMPLES::
code::
(
/*
Two patterns playing in parallel,
sharing data between eachother
*/
// a melody playing random scale degrees
a = Pbind(
\dur, 0.125,
\octave, 4,
\degree, Plet(\melody, pattern: Pwhite(0,7))
);
// the bass, scale degrees sampled from the \melody variable defined above
b = Pbind(
\dur, 0.5,
\octave, 3,
\degree, Pget(\melody, default: 1, repeats: inf).trace
);
// Play the patterns in parallel
Plambda(
Ppar([a, b], inf)
).play;
)
::
|