supernova: fixes for boost-1.49 and gcc-4.7
[supercollider.git] / Help / Streams-Patterns-Events / StreamClutch.html
blob56df91fe78382d81aee3ce04e24b0d91e374ef45
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta http-equiv="Content-Style-Type" content="text/css">
6 <title></title>
7 <meta name="Generator" content="Cocoa HTML Writer">
8 <meta name="CocoaVersion" content="824.42">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica}
11 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #a71e12}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #0019b7}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
17 span.s1 {font: 9.0px Monaco}
18 span.s2 {color: #000000}
19 span.s3 {color: #0019b7}
20 span.s4 {color: #326f17}
21 span.Apple-tab-span {white-space:pre}
22 </style>
23 </head>
24 <body>
25 <p class="p1"><b>StreamClutch</b><span class="s1"> <span class="Apple-converted-space">         </span></span></p>
26 <p class="p2"><br></p>
27 <p class="p2"><br></p>
28 <p class="p3"><b>superclass: Stream</b></p>
29 <p class="p2"><br></p>
30 <p class="p4">buffers a streamed value</p>
31 <p class="p2"><br></p>
32 <p class="p3"><b>StreamClutch.new(pattern, connected)</b></p>
33 <p class="p2"><br></p>
34 <p class="p3"><b>pattern</b> <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a pattern or stream to be buffered</p>
35 <p class="p3"><b>connected</b><span class="Apple-converted-space"> </span></p>
36 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>if true it wil call the next stream value for each time next is called</p>
37 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>if false it returns the last value</p>
38 <p class="p2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
39 <p class="p2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
40 <p class="p2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
41 <p class="p5">//example:</p>
42 <p class="p2"><br></p>
43 <p class="p6">SynthDescLib<span class="s2">.read;</span></p>
44 <p class="p2"><br></p>
45 <p class="p7">a = <span class="s3">Pseq</span>([1, 2, 3], <span class="s3">inf</span>);</p>
46 <p class="p6"><span class="s2">b = </span>StreamClutch<span class="s2">(a);</span></p>
47 <p class="p2"><br></p>
48 <p class="p7">6.do({ b.next.postln });</p>
49 <p class="p7">b.connected = <span class="s3">false</span>;</p>
50 <p class="p7">6.do({ b.next.postln });</p>
51 <p class="p2"><br></p>
52 <p class="p2"><br></p>
53 <p class="p5">//statistical clutch</p>
54 <p class="p7">a = <span class="s3">Pseq</span>([1, 2, 3], <span class="s3">inf</span>);</p>
55 <p class="p7">b = <span class="s3">StreamClutch</span>(a, { 0.5.coin });</p>
56 <p class="p2"><br></p>
57 <p class="p7">12.do({ b.next.postln });</p>
58 <p class="p2"><br></p>
59 <p class="p2"><br></p>
60 <p class="p5">//sound example:</p>
61 <p class="p7">(</p>
62 <p class="p7"><span class="s3">var</span> clutch, pat, decicion;</p>
63 <p class="p7">decicion = <span class="s3">Pseq</span>([<span class="s3">Pn</span>(<span class="s3">true</span>,10), <span class="s3">Prand</span>([<span class="s3">true</span>, <span class="s3">false</span>], 10)], <span class="s3">inf</span>).asStream;</p>
64 <p class="p7">pat = <span class="s3">Pbind</span>(<span class="s4">\freq</span>, <span class="s3">Pseq</span>([200, [300, 302], 400, 450], <span class="s3">inf</span>), <span class="s4">\dur</span>, 0.3);</p>
65 <p class="p7">clutch = <span class="s3">StreamClutch</span>(pat, decicion);</p>
66 <p class="p7">clutch.asEventStreamPlayer.play;</p>
67 <p class="p7">)</p>
68 <p class="p2"><br></p>
69 <p class="p5">// independant stepping</p>
70 <p class="p7">(</p>
71 <p class="p7"><span class="s3">var</span> clutch, pat, decicion;</p>
72 <p class="p7">pat = <span class="s3">Pbind</span>(<span class="s4">\freq</span>, <span class="s3">Pseq</span>([200, [300, 302], 400, 450], <span class="s3">inf</span>), <span class="s4">\dur</span>, 0.3);</p>
73 <p class="p6"><span class="s2">b = </span>StreamClutch<span class="s2">(pat);</span></p>
74 <p class="p7">b.connected = <span class="s3">false</span>;</p>
75 <p class="p7">b.asEventStreamPlayer.play;</p>
76 <p class="p7">)</p>
77 <p class="p2"><br></p>
78 <p class="p7">b.step;</p>
79 <p class="p2"><br></p>
80 <p class="p2"><br></p>
81 <p class="p2"><br></p>
82 <p class="p2"><br></p>
83 </body>
84 </html>