2 summary:: pass values from stream to stream
3 related:: Classes/Pbindf
4 categories:: Streams-Patterns-Events>Patterns>Composition
9 ## Pchain(pattern1, pattern2, ... patternN) || pattern1 <- pattern2 <- ...patternN
12 Values produced by the stream of strong::pattern2:: are used as inval to the stream of strong::pattern1::. Therefore pattern1 overrides (or filters) the output of pattern2, and so forth. This is an equivalent to the composite pattern: emphasis::pattern1 <> pattern2 <> ... patternN::
18 argument:: ... patterns
19 The patterns to be chained up.
24 Add another pattern to the chain.
31 Pbind(\detune, Pseq([-30, 0, 40], inf), \dur, Prand([0.2, 0.4], inf)),
32 Pbind(\degree, Pseq([1, 2, 3], inf), \dur, 1)
37 // also events can be used directly:
40 Pbind(\degree, Pseq([1, 2, 3], inf)),
45 // compose some more complicated patterns:
49 Pbind(\degree, Pseq([0, 1, 3, 5, 6])),
50 Pbind(\dur, Pshuf([0.4, 0.3, 0.3]), \degree, Pseq([3, -1]))
53 Pbind(\ctranspose, Pn(1, 4)),
54 Pbind(\mtranspose, Pn(2, 7))
57 Pbind(\detune, Pfuncn( { [0, 10.0].rand }, 5), \legato, 0.2, \dur, 0.2),
58 Pbind(\legato, Pseq([0.2, 0.5, 1.5], 2), \dur, 0.3)
60 Pchain(a, b, c).trace.play;
64 section::pattern composition
66 pattern <> pattern <> pattern
69 // implicitly, the composition operator <> returns a Pchain when applied to a pattern.
70 // so that a <> b creates a Pchain (a, b).
71 // as seen above, in Pchain(a, b), a specifies (and overrides) b: b is the input to a.
73 // the above example is equivalent to:
75 (Pbind(\degree, Pseq([1, 2, 3], inf)) <> (detune: [0, 4])).trace.play;
78 a = Pbind(\degree, Pseq([1, 2, 3], inf), \dur, Prand([0.2, 0.4], inf));
79 b = Pbind(\detune, Pseq([-30, 0, [0, 40]], inf), \dur, 0.1);
81 c.play; // see that the \dur key of a is overridden by b
84 // also value streams can be composed
86 a = Pfunc { |x| x + 1.33 };
87 b = Pfunc { |x| x * 3 };
88 c = Pseries(1, 2, inf);
91 // post some values from the composite streams:
93 t = (a <> b).asStream;
94 10.do { t.value(10).postln };
96 t = (a <> b <> c).asStream;
97 10.do { t.value(10).postln };
99 t = (b <> c <> a).asStream;
100 10.do { t.value(10).postln };