supernova: c++11 compile fix
[supercollider.git] / Help / ServerArchitecture / Group.html
blobf2c4d64a81494c79175f07a5f50b0ffd5f299825
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="949.54">
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: 9.0px Monaco; min-height: 12.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica}
14 p.p5 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco; min-height: 12.0px}
15 p.p6 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica}
16 p.p7 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica; min-height: 14.0px}
17 p.p8 {margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica}
18 p.p9 {margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica; min-height: 14.0px}
19 p.p10 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco}
20 p.p11 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco; color: #613829}
21 p.p12 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica}
22 p.p13 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica; color: #bf0000}
23 p.p14 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000; min-height: 12.0px}
24 p.p15 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #000000}
25 p.p16 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #bf0000}
26 p.p17 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #606060}
27 p.p18 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #0000bf}
28 span.s1 {font: 18.0px Helvetica}
29 span.s2 {font: 9.0px Monaco; color: #5e6337}
30 span.s3 {font: 9.0px Monaco}
31 span.s4 {color: #000000}
32 span.s5 {color: #1c3e99}
33 span.s6 {color: #5e6337}
34 span.s7 {color: #0a2cee}
35 span.s8 {font: 12.0px Helvetica}
36 span.s9 {color: #1f4bdc}
37 span.s10 {color: #0000bf}
38 span.s11 {color: #606060}
39 span.s12 {color: #007300}
40 span.Apple-tab-span {white-space:pre}
41 </style>
42 </head>
43 <body>
44 <p class="p1"><span class="s1"><b>Group<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></span><b>client-side representation of a group node on the server</b><span class="s1"><b><span class="Apple-tab-span"> </span></b></span></p>
45 <p class="p1"><b>superclass: Node</b></p>
46 <p class="p2"><br></p>
47 <p class="p1">A Group is the client-side representation of a group node on the server, which is a collection of other nodes organized as a linked list. The Nodes within a Group may be controlled together, and may be both Synths and other Groups. Groups are thus useful for controlling a number of nodes at once, and when used as targets can be very helpful in controlling order of execution. (See <b>Order-of-execution </b>for more details on this topic).</p>
48 <p class="p3"><br></p>
49 <p class="p1">For more on the crucial distinction between client objects and server nodes, see <b>ClientVsServer</b>. For information on creating nodes without using objects, see <b>NodeMessaging</b>.</p>
50 <p class="p3"><br></p>
51 <p class="p1"><b>N.B. </b>Group is a subclass of <b>Node</b>, and thus many of its most useful and important methods are documented in the <b>Node</b> help file. Please refer to it for more information.</p>
52 <p class="p3"><br></p>
53 <p class="p4"><b>RootNode and the default group</b></p>
54 <p class="p3"><br></p>
55 <p class="p1">When a <b>Server</b> is booted there is a top level group with an ID of zero that defines the root of the tree. This is represented by a subclass of Group: <b>RootNode</b>. If the Server was booted from within SCLang (as opposed to from the command line) then a <b>default_group</b> with an ID of 1 will be automatically created. This group is the default enclosing group for all Nodes, i.e. it's what you get if you don't specify. In general you should create new Nodes within the default group of a Server rather than in its RootNode. See <b>Server</b>, <b>default_group</b> and <b>RootNode </b>for more detail.</p>
56 <p class="p3"><br></p>
57 <p class="p4"><b>Bundling</b></p>
58 <p class="p3"><br></p>
59 <p class="p1">Some of the methods below have two versions: a regular one which sends its corresponding message to the server immediately, and one which returns the message in an <b>Array</b> so that it can be added to a bundle. It is also possible to capture the messages generated by the regular methods using Server's automated bundling capabilities. See <b>Server</b> and <b>bundledCommands</b> for more detail.</p>
60 <p class="p3"><br></p>
61 <p class="p4"><b>Creation with Immediate Instantiation on the Server</b></p>
62 <p class="p5"><br></p>
63 <p class="p6"><b><span class="Apple-tab-span"> </span>*new(target, addAction)</b></p>
64 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
65 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Create and return a Group.</p>
66 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
67 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>target </b>- A target for this Group. If target is not a Group or <b>Synth</b>, it will be converted as follows: If it is a <b>Server</b>, it will be converted to the <b>default_group</b> of that server. If it is nil, to the <b>default_group</b> of the default <b>Server</b>. <b>Note: </b>A Synth is not a valid target for <span class="s2">\addToHead</span> and <span class="s2">\addToTail</span>.</p>
68 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
69 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>addAction</b> - one of the following Symbols:<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
70 <p class="p8"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">\addToHead <span class="Apple-tab-span"> </span></span>- (the default) add at the head of the group specified by <b>target</b></p>
71 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">\addToTail <span class="Apple-tab-span"> </span></span>- add at the tail of the group specified by <b>target</b></p>
72 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">\addAfter</span> <span class="Apple-tab-span"> </span>- add immediately after <b>target </b>in its server's node order</p>
73 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">\addBefore</span> <span class="Apple-tab-span"> </span>- add immediately before <b>target </b>in its server's node order</p>
74 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">\addReplace</span> <span class="Apple-tab-span"> </span>- replace <b>target</b> and take its place in its server's node order</p>
75 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
76 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
77 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>s.boot;</p>
78 <p class="p11"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g = </span><span class="s5">Group</span><span class="s4">.new; </span>// add a Group at the head of the default Server's default group</p>
79 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>h = <span class="s5">Group</span>.new(g, <span class="s6">\addAfter</span>);</p>
80 <p class="p11"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>s.queryAllNodes; </span>// note the Group within the default group (ID 1)</p>
81 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.free; h.free;</p>
82 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
83 <p class="p6">The following convenience methods correspond to the add actions above:</p>
84 <p class="p5"><br></p>
85 <p class="p6"><b><span class="Apple-tab-span"> </span>*after(aNode)</b></p>
86 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></p>
87 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Create and return a Group and add it immediately after <b>aNode</b>.<span class="Apple-converted-space"> </span></p>
88 <p class="p7"><br></p>
89 <p class="p6"><b><span class="Apple-tab-span"> </span>*before(aNode)</b></p>
90 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></p>
91 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Create and return a Group and add it immediately before <b>aNode</b>.</p>
92 <p class="p7"><br></p>
93 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span></span><b>*head(aGroup)</b></p>
94 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
95 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Create and return a Group. If <b>aGroup</b> is a Group add it at the head of that group. If it is a <b>Server</b>, add it at the head of the <b>default_group</b> of that server. If it is nil, add it at the head of the <b>default_group</b> of the default <b>Server.</b></p>
96 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
97 <p class="p6"><span class="s3"><span class="Apple-tab-span"> </span></span><b>*tail(aGroup)</b></p>
98 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></p>
99 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Create and return a Group. If <b>aGroup</b> is a Group add it at the tail of that group. If it is a <b>Server</b>, add it at the tail of the <b>default_group</b> of that server. If it is nil, add it at the tail of the <b>default_group</b> of the default <b>Server.</b></p>
100 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
101 <p class="p6"><span class="Apple-tab-span"> </span><b>*replace(nodeToReplace)</b></p>
102 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></p>
103 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Create and return a Group and use it to replace <b>nodeToReplace</b>, taking its place in its server's node order.</p>
104 <p class="p7"><br></p>
105 <p class="p4"><b>Creation without Instantiation on the Server</b></p>
106 <p class="p3"><br></p>
107 <p class="p1">For use in message bundles it is also possible to create a Group object in the client app without immediately creating a group node on the server. Once done one can call methods which create messages to add to a bundle, which when sent to the server will instantiate the group or perform other operations. (See <a href="../UGens/Synth control/Control.html"><span class="s7">Control</span></a>, below.)</p>
108 <p class="p7"><br></p>
109 <p class="p6"><span class="Apple-tab-span"> </span><b>*basicNew(server, nodeID)</b></p>
110 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
111 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Create and return a Group object without creating a group node on the server. (This method is inherited from <b>Node</b> and is documented here only for convenience.)</p>
112 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
113 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>server</b> - An optional instance of <b>Server</b>. If nil this will default to the default <b>Server</b>.<span class="Apple-converted-space"> </span></p>
114 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
115 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>nodeID </b>- An optional node ID number. If not supplied one will be generated by the Server's NodeIDAllocator. Normally you should not need to supply an ID.</p>
116 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
117 <p class="p10"><span class="s8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>s.boot;</p>
118 <p class="p11"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g = </span><span class="s5">Group</span><span class="s4">.basicNew(s); </span>// Create without sending</p>
119 <p class="p11"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>s.sendBundle(</span><span class="s5">nil</span><span class="s4">, g.newMsg;); </span>// Now send a message; create at the head of s' default group</p>
120 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>s.queryAllNodes;</p>
121 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>g.free;</p>
122 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
123 <p class="p6"><span class="Apple-tab-span"> </span><b>newMsg(target, addAction</b>)</p>
124 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
125 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns a message of the type <b>g_new</b> which can be bundled. When sent to the server this message will instantiate this group. If target is nil, it will default to the <b>default_group</b> of the Server specified in <b>*basicNew</b> when this Group was created. The default addAction is <span class="s2">\addToHead</span>. (See <b>*new</b> above for details of addActions.</p>
126 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
127 <p class="p6"><span class="Apple-tab-span"> </span><b>addToHeadMsg(aGroup)</b></p>
128 <p class="p7"><span class="Apple-tab-span"> </span></p>
129 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Returns a message of the type <b>g_new</b> which can be bundled. When sent to the server this message will instantiate this group. If <b>aGroup</b> is a Group it will be added at the head of that group. If it is nil, it will be added at the head of the <b>default_group</b> of this Group's server (as specified when *<b>basicNew</b> was called).</p>
130 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
131 <p class="p6"><span class="Apple-tab-span"> </span><b>addToTailMsg(target)</b></p>
132 <p class="p7"><span class="Apple-tab-span"> </span></p>
133 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Returns a message of the type <b>g_new</b> which can be bundled. When sent to the server this message will instantiate this group. If <b>aGroup</b> is a Group it will be added at the tail of that group. If it is nil, it will be added at the tail of the <b>default_group</b> of this Group's server (as specified when *<b>basicNew</b> was called).</p>
134 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
135 <p class="p6"><span class="Apple-tab-span"> </span><b>addBeforeMsg(aNode</b>)</p>
136 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
137 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns a message of the type <b>g_new</b> which can be bundled. When sent to the server this message will instantiate this group, immediately before <b>aNode</b>.</p>
138 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
139 <p class="p6"><span class="Apple-tab-span"> </span><b>addAfterMsg(aNode</b>)</p>
140 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
141 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns a message of the type <b>g_new</b> which can be bundled. When sent to the server this message will instantiate this group, immediately after <b>aNode</b>.</p>
142 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
143 <p class="p6"><span class="Apple-tab-span"> </span><b>addReplaceMsg(nodeToReplace</b>)</p>
144 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
145 <p class="p6"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Returns a message of the type <b>g_new</b> which can be bundled. When sent to the server this message will instantiate this group, replacing <b>nodeToReplace</b> in the server's node order.</p>
146 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
147 <p class="p12"><b>Control and Introspection</b></p>
148 <p class="p7"><br></p>
149 <p class="p1">For further methods of controlling Groups (set, map, etc.), see the <b>Node</b> help file.</p>
150 <p class="p7"><span class="Apple-tab-span"> </span></p>
151 <p class="p6"><b><span class="Apple-tab-span"> </span>moveNodeToHead(aNode)</b></p>
152 <p class="p6"><b><span class="Apple-tab-span"> </span>moveNodeToHeadMsg(aNode)</b></p>
153 <p class="p7"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span></p>
154 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Move <b>aNode</b> to the head of this group<span class="Apple-tab-span"> </span><b><span class="Apple-tab-span"> </span></b></p>
155 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></p>
156 <p class="p6"><b><span class="Apple-tab-span"> </span>moveNodeToTail(aNode)</b></p>
157 <p class="p6"><b><span class="Apple-tab-span"> </span>moveNodeToTailMsg(aNode)</b></p>
158 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
159 <p class="p6"><b><span class="Apple-tab-span"> </span></b><span class="Apple-tab-span"> </span>Move <b>aNode</b> to the tail of this group<span class="Apple-tab-span"> </span></p>
160 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
161 <p class="p6"><b><span class="Apple-tab-span"> </span>freeAll</b></p>
162 <p class="p6"><b><span class="Apple-tab-span"> </span>freeAllMsg</b></p>
163 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
164 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Free all the nodes in this group, but do not free this group itself.</p>
165 <p class="p7"><br></p>
166 <p class="p6"><b><span class="Apple-tab-span"> </span>deepFree</b></p>
167 <p class="p6"><b><span class="Apple-tab-span"> </span>deepFreeMsg</b></p>
168 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
169 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Free all Synths in the group, and all Synths in any enclosed groups, but do not free this group or any of its enclosed groups.</p>
170 <p class="p7"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
171 <p class="p6"><span class="Apple-tab-span"> </span><b>dumpTree(postControls)</b></p>
172 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
173 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Post a representation of this group's node subtree. (Sends a message of the type <b>g_dumpTree</b>.) If <b>postControls</b> is true, then the current <a href="../UGens/Synth control/Control.html"><span class="s7">Control</span></a> (arg) values for any synths contained in this group will be posted as well. The default is false.</p>
174 <p class="p7"><br></p>
175 <p class="p13">// not working yet<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
176 <p class="p6"><span class="Apple-tab-span"> </span><b>queryTree(action)</b></p>
177 <p class="p7"><b><span class="Apple-tab-span"> </span></b></p>
178 <p class="p6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>Queries the server for a message describing this group's node subtree. (Sends a message of the type <b>g_queryTree</b>.) This reply is passed to the action function as an argument. See <b>g_queryTree</b> in <a href="Server-Command-Reference.html"><span class="s9">Server-Command-Reference</span></a> or the example below for information on how the reply is structured.</p>
179 <p class="p3"><br></p>
180 <p class="p3"><br></p>
181 <p class="p12"><b>Examples</b></p>
182 <p class="p14"><br></p>
183 <p class="p15">(</p>
184 <p class="p16"><span class="s4">s = </span><span class="s10">Server</span><span class="s4">.default; </span>// just to be sure</p>
185 <p class="p15">s.boot;</p>
186 <p class="p15">)</p>
187 <p class="p14"><br></p>
188 <p class="p15">(</p>
189 <p class="p15"><span class="s10">SynthDef</span>(<span class="s11">"help-Group-moto-rev"</span>, { <span class="s10">arg</span> out=0,freq=100,ffreq=120;</p>
190 <p class="p15"><span class="Apple-tab-span"> </span><span class="s10">var</span> x;</p>
191 <p class="p15"><span class="Apple-tab-span"> </span>x = <span class="s10">RLPF</span>.ar(<span class="s10">LFPulse</span>.ar(<span class="s10">SinOsc</span>.kr(0.2, 0, 10, freq), [0,0.1], 0.1),<span class="Apple-converted-space"> </span></p>
192 <p class="p15"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>ffreq, 0.1).clip2(0.4);</p>
193 <p class="p15"><span class="Apple-tab-span"> </span><span class="s10">Out</span>.ar(out, x);</p>
194 <p class="p15">}).add;</p>
195 <p class="p14"><br></p>
196 <p class="p14"><br></p>
197 <p class="p15"><span class="s10">SynthDef</span>(<span class="s11">"help-Group-wah"</span>, { <span class="s10">arg</span> out, rate = 1.5, cfreq = 1400, mfreq = 1200, rq=0.1;</p>
198 <p class="p15"><span class="Apple-tab-span"> </span><span class="s10">var</span> zin, zout, q;</p>
199 <p class="p14"><br></p>
200 <p class="p15"><span class="Apple-tab-span"> </span>zin = <span class="s10">In</span>.ar(out, 2);</p>
201 <p class="p15"><span class="Apple-tab-span"> </span>cfreq = <span class="s10">Lag3</span>.kr(cfreq, 0.1);</p>
202 <p class="p15"><span class="Apple-tab-span"> </span>mfreq = <span class="s10">Lag3</span>.kr(mfreq, 0.1);</p>
203 <p class="p15"><span class="Apple-tab-span"> </span>q <span class="Apple-converted-space">  </span>= <span class="s10">Ramp</span>.kr(rq, 0.1);</p>
204 <p class="p15"><span class="Apple-tab-span"> </span>zout = <span class="s10">RLPF</span>.ar(zin, <span class="s10">LFNoise1</span>.kr(rate, mfreq, cfreq), q, 10).distort<span class="Apple-converted-space"> </span></p>
205 <p class="p15"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>* 0.15;</p>
206 <p class="p14"><br></p>
207 <p class="p16"><span class="s4"><span class="Apple-tab-span"> </span></span>// replace the incoming bus with the effected version</p>
208 <p class="p15"><span class="Apple-tab-span"> </span><span class="s10">ReplaceOut</span>.ar( out , zout );<span class="Apple-converted-space"> </span></p>
209 <p class="p14"><span class="Apple-tab-span"> </span></p>
210 <p class="p15">}).add;</p>
211 <p class="p15">)</p>
212 <p class="p14"><br></p>
213 <p class="p15">g = <span class="s10">Group</span>.new;</p>
214 <p class="p14"><br></p>
215 <p class="p15">(</p>
216 <p class="p15">l = <span class="s10">Array</span>.fill(3,{</p>
217 <p class="p16"><span class="s4"><span class="Apple-tab-span"> </span></span>// random freq for each synth, added to g at the head</p>
218 <p class="p17"><span class="s4"><span class="Apple-tab-span"> </span></span><span class="s10">Synth</span><span class="s4">(</span>"help-Group-moto-rev"<span class="s4">,[</span>"out"<span class="s4">,0,</span>"freq"<span class="s4">,rrand(10,120)],g,</span><span class="s12">\addToHead</span><span class="s4">);</span></p>
219 <p class="p15">});</p>
220 <p class="p15">)</p>
221 <p class="p14"><br></p>
222 <p class="p16">// set all controls that match "ffreq" in all nodes in g to 90</p>
223 <p class="p15">g.set(<span class="s11">"ffreq"</span>,300);</p>
224 <p class="p14"><br></p>
225 <p class="p15">g.set(<span class="s11">"freq"</span>,80);</p>
226 <p class="p14"><br></p>
227 <p class="p16">// since we stored the Synths in an Array, we can also control them individually</p>
228 <p class="p15">(</p>
229 <p class="p18"><span class="s4">r = </span>Routine<span class="s4">({</span></p>
230 <p class="p15"><span class="Apple-tab-span"> </span><span class="s10">inf</span>.do({</p>
231 <p class="p15"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>l.do({ <span class="s10">arg</span> node;</p>
232 <p class="p15"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>node.set(<span class="s11">"freq"</span>,rrand(10,120));</p>
233 <p class="p15"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>1.0.wait;</p>
234 <p class="p15"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>});</p>
235 <p class="p15"><span class="Apple-tab-span"> </span>})</p>
236 <p class="p15">});</p>
237 <p class="p14"><br></p>
238 <p class="p15">r.play;</p>
239 <p class="p15">)</p>
240 <p class="p14"><br></p>
241 <p class="p16">// g is in a group too. Since we didn't specify it's the default group (ID 1) of the default Server</p>
242 <p class="p15">g.group.inspect;</p>
243 <p class="p14"><br></p>
244 <p class="p16">// asking a wah to go order-of-execution after g, in the same group as g.</p>
245 <p class="p15">x = <span class="s10">Synth</span>.after(g,<span class="s11">"help-Group-wah"</span>,[<span class="s11">"out"</span>,0]);<span class="Apple-converted-space"> </span></p>
246 <p class="p14"><br></p>
247 <p class="p16">// now dump my tree to confirm</p>
248 <p class="p15">g.dumpTree;</p>
249 <p class="p14"><br></p>
250 <p class="p15">x.free;</p>
251 <p class="p14"><br></p>
252 <p class="p16">// free all nodes in g, but not g itself</p>
253 <p class="p15">g.freeAll;</p>
254 <p class="p14"><br></p>
255 <p class="p16">// don't forget the Routine is still running...</p>
256 <p class="p15">r.stop;</p>
257 <p class="p14"><br></p>
258 <p class="p16">// oh, and set l to nil so the Synths and Array can be garbage collected</p>
259 <p class="p15">l = <span class="s10">nil</span>;</p>
260 <p class="p14"><br></p>
261 <p class="p16">// and i'm still on the server, its just my children that were freed</p>
262 <p class="p15">g.query;</p>
263 <p class="p14"><br></p>
264 <p class="p16">// don't need the individual synth objects this time</p>
265 <p class="p15">(</p>
266 <p class="p15">3.do({</p>
267 <p class="p16"><span class="s4"><span class="Apple-tab-span"> </span></span>// random freq for each synth, added to g at the head</p>
268 <p class="p17"><span class="s4"><span class="Apple-tab-span"> </span></span><span class="s10">Synth</span><span class="s4">(</span>"help-Group-moto-rev"<span class="s4">,[</span>"out"<span class="s4">,0,</span>"freq"<span class="s4">,rrand(10,1200)],g,</span><span class="s12">\addToHead</span><span class="s4">);</span></p>
269 <p class="p15">});</p>
270 <p class="p15">)</p>
271 <p class="p14"><br></p>
272 <p class="p16">// now query my tree and post a graph of it (duplicates dumpTree)</p>
273 <p class="p16">// msg format is ['/g_querytree.reply', node1-ID, numChildren, defName, child1-ID, numChildren, ...]</p>
274 <p class="p16">//(</p>
275 <p class="p16">//g.queryTree({|msg|<span class="Apple-converted-space"> </span></p>
276 <p class="p16">//<span class="Apple-tab-span"> </span>var i = 1, tabs = 0, dumpFunc;</p>
277 <p class="p16">//<span class="Apple-tab-span"> </span>("NODE TREE Group" + msg[1]).postln;</p>
278 <p class="p16">//<span class="Apple-tab-span"> </span>if(msg[2] &gt; 0, {</p>
279 <p class="p16">//<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>dumpFunc = {|numChildren|</p>
280 <p class="p16">//<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>tabs = tabs + 1;</p>
281 <p class="p16">//<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>numChildren.do({</p>
282 <p class="p16">//<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>i = i + 3;</p>
283 <p class="p16">//<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>tabs.do({ " <span class="Apple-converted-space">  </span>".post });</p>
284 <p class="p16">//<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>msg[i].post;</p>
285 <p class="p16">//<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(" " ++ msg[i + 2]).postln;</p>
286 <p class="p16">//<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>if(msg[i + 1] &gt; 0, { dumpFunc.value(msg[i + 1]) });<span class="Apple-tab-span"> </span></p>
287 <p class="p16">//<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>});</p>
288 <p class="p16">//<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>tabs = tabs - 1;</p>
289 <p class="p16">//<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>};</p>
290 <p class="p16">//<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>dumpFunc.value(msg[2]);</p>
291 <p class="p16">//<span class="Apple-tab-span"> </span>});</p>
292 <p class="p16">//});</p>
293 <p class="p16">//)</p>
294 <p class="p14"><br></p>
295 <p class="p16">// kill me and my children</p>
296 <p class="p15">g.free;</p>
297 <p class="p14"><br></p>
298 <p class="p16">// see, I'm gone</p>
299 <p class="p15">g.query;</p>
300 </body>
301 </html>