SCDoc: Use proper static string constants instead of comparing string literals.
[supercollider.git] / Help / Control / NodeWatcher.html
blobd19ec7af88f5e896066dbba7c2141c9a18924b42
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: 12.0px Helvetica}
11 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica; min-height: 22.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica; min-height: 16.0px}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica}
17 p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #a71e12}
18 p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica}
19 p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #0019b7}
20 span.s1 {font: 18.0px Helvetica}
21 span.s2 {font: 13.0px Helvetica}
22 span.s3 {font: 9.0px Monaco}
23 span.s4 {color: #0019b7}
24 span.s5 {color: #000000}
25 span.Apple-tab-span {white-space:pre}
26 </style>
27 </head>
28 <body>
29 <p class="p1"><span class="s1"><b>NodeWatcher<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></span><b>notify sc-lang side node objects of their server sided state</b></p>
30 <p class="p2"><br></p>
31 <p class="p3"><br></p>
32 <p class="p1">Node instances (Synths and Groups) can be registered with the NodeWatcher. <span class="Apple-converted-space"> </span></p>
33 <p class="p1">It watches for server node status messages:</p>
34 <p class="p4"><span class="s2"><span class="Apple-tab-span"> </span></span><span class="Apple-tab-span"> </span></p>
35 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>n_go<span class="Apple-converted-space"> </span></p>
36 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>n_end</p>
37 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>n_off</p>
38 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>n_on</p>
39 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
40 <p class="p6"><br></p>
41 <p class="p1">and sets the isPlaying and isRunning variables on the Node instance accordingly.<span class="Apple-converted-space">  </span>A Node that ends is unregistered at that time.</p>
42 <p class="p3"><br></p>
43 <p class="p1">In some cases this can be an invaluable service.<span class="Apple-converted-space">  </span>The use of an independant object to maintain the state keeps the implementation of the Node classes simple.<span class="Apple-converted-space"> </span></p>
44 <p class="p1">Note that server notification should be on. (this is default. see: aServer.notify)</p>
45 <p class="p4"><br></p>
46 <p class="p1"><span class="s3"><span class="Apple-tab-span"> </span></span><b>the most common use:<span class="Apple-converted-space"> </span></b></p>
47 <p class="p1"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>NodeWatcher.register(aNode);</p>
48 <p class="p4"><br></p>
49 <p class="p4"><br></p>
50 <p class="p7"><b><span class="Apple-tab-span"> </span>*new(server)</b></p>
51 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>create a new instance listening to the server's address</p>
52 <p class="p3"><br></p>
53 <p class="p7"><span class="Apple-tab-span"> </span><b>*newFrom(server)</b></p>
54 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span> create a new instance listening to the server's address</p>
55 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span> if there is one present already return that one</p>
56 <p class="p3"><span class="Apple-tab-span"> </span></p>
57 <p class="p7"><span class="Apple-tab-span"> </span><b>*register(aNode, assumePlaying)</b></p>
58 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>aNode can be a Group or a Synth.</p>
59 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>the NodeWatcher is created internally</p>
60 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>assumePlaying: </b>if true, the node's <b>isPlaying</b> field is set to true</p>
61 <p class="p3"><span class="Apple-tab-span"> </span></p>
62 <p class="p7"><span class="Apple-tab-span"> </span><b>*unregister(aNode)</b></p>
63 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>remove the node from the list of nodes.</p>
64 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>this happens also when a node is freed.</p>
65 <p class="p3"><span class="Apple-tab-span"> </span></p>
66 <p class="p7"><span class="s3"><span class="Apple-tab-span"> </span></span><b>start</b></p>
67 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>add the OSCresponderNode to listen to the address</p>
68 <p class="p3"><span class="Apple-tab-span"> </span></p>
69 <p class="p7"><span class="Apple-tab-span"> </span><b>stop</b></p>
70 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>remove the OSCresponderNode to stop listen to the address<span class="Apple-converted-space"> </span></p>
71 <p class="p4"><span class="Apple-tab-span"> </span></p>
72 <p class="p4"><br></p>
73 <p class="p4"><br></p>
74 <p class="p8">// example:</p>
75 <p class="p4"><br></p>
76 <p class="p5"><span class="Apple-tab-span"> </span>(</p>
77 <p class="p5"><span class="Apple-tab-span"> </span>b = s.makeBundle(<span class="s4">false</span>, {</p>
78 <p class="p8"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a = </span><span class="s4">Group</span><span class="s5">.new(s); </span>//create a node object</p>
79 <p class="p8"><span class="s5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s4">NodeWatcher</span><span class="s5">.register(a); </span>// register before creating on the server</p>
80 <p class="p5"><span class="Apple-tab-span"> </span>});</p>
81 <p class="p5"><span class="Apple-tab-span"> </span>)</p>
82 <p class="p5"><span class="Apple-tab-span"> </span>a.isPlaying;</p>
83 <p class="p8"><span class="s5"><span class="Apple-tab-span"> </span>s.listSendBundle(nil, b); </span>//start the node on the server</p>
84 <p class="p5"><span class="Apple-tab-span"> </span>a.isPlaying;</p>
85 <p class="p5"><span class="Apple-tab-span"> </span>a.isRunning;</p>
86 <p class="p5"><span class="Apple-tab-span"> </span>a.run(<span class="s4">false</span>);</p>
87 <p class="p5"><span class="Apple-tab-span"> </span>a.isRunning;</p>
88 <p class="p8"><span class="s5"><span class="Apple-tab-span"> </span>s.freeAll; </span>//free all nodes</p>
89 <p class="p5"><span class="Apple-tab-span"> </span>a.isPlaying;</p>
90 <p class="p5"><span class="Apple-tab-span"> </span>a.isRunning;</p>
91 <p class="p4"><span class="Apple-tab-span"> </span></p>
92 <p class="p4"><br></p>
93 <p class="p4"><br></p>
94 <p class="p9"><b>DebugNodeWatcher</b></p>
95 <p class="p4"><br></p>
96 <p class="p7"><span class="Apple-tab-span"> </span>for debugging, it can be useful to see every node start and end</p>
97 <p class="p7"><span class="Apple-tab-span"> </span>it doesn't require registration, reacts to each message.</p>
98 <p class="p3"><br></p>
99 <p class="p3"><span class="Apple-tab-span"> </span></p>
100 <p class="p4"><br></p>
101 <p class="p8">// example:</p>
102 <p class="p10"><span class="s5"><span class="Apple-tab-span"> </span>n = </span>DebugNodeWatcher<span class="s5">(s);</span></p>
103 <p class="p5"><span class="Apple-tab-span"> </span>n.start;</p>
104 <p class="p5"><span class="Apple-tab-span"> </span>x = <span class="s4">Group</span>(s);</p>
105 <p class="p5"><span class="Apple-tab-span"> </span>x.run(<span class="s4">false</span>);</p>
106 <p class="p5"><span class="Apple-tab-span"> </span>x.free;</p>
107 <p class="p5"><span class="Apple-tab-span"> </span>n.stop;</p>
108 <p class="p4"><span class="Apple-tab-span"> </span></p>
109 <p class="p4"><span class="Apple-tab-span"> </span></p>
110 <p class="p4"><br></p>
111 </body>
112 </html>