Include a header file required for build on mac 10.4
[supercollider.git] / Help / Control / OSCpathResponder.html
blob0294d07bac7f2761d39edc34fc0f3cbd55e93886
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.44">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Helvetica}
11 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica; color: #0029b6; min-height: 17.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: 12.0px Helvetica; min-height: 14.0px}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #ad140d}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
17 span.s1 {font: 15.0px Helvetica}
18 span.s2 {color: #002bf8}
19 span.s3 {color: #0024f8}
20 span.s4 {text-decoration: underline}
21 span.s5 {color: #001bb9}
22 span.s6 {color: #2c7014}
23 span.Apple-tab-span {white-space:pre}
24 </style>
25 </head>
26 <body>
27 <p class="p1"><span class="s1"><b>OSCpathResponder<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></span><b>client side responder</b></p>
28 <p class="p2"><br></p>
29 <p class="p3"><b>superclass: OSCresponder</b></p>
30 <p class="p4"><br></p>
31 <p class="p3">Register a function to be called upon receiving a<span class="Apple-converted-space">  </span>command with a specific path.</p>
32 <p class="p4"><br></p>
33 <p class="p3">Other applications sending messages to SuperCollider should distinguish between sending messages to the server or the language. Server messages are documented in the <a href="../ServerArchitecture/Server-Command-Reference.html"><span class="s2">Server-Command-Reference</span></a> and should be sent to the server's port - <b>s.addr.port</b> - which is 57110 by default. Messages sent to the server will not be processed by any OSCresponder in the language.</p>
34 <p class="p4"><br></p>
35 <p class="p3">Messages from external clients that should be processed by OSCresponders must be sent to the language port, <b>57120</b> by default. Use <b>NetAddr.langPort</b> to confirm which port the SuperCollider language is listening on.</p>
36 <p class="p4"><br></p>
37 <p class="p3">See <a href="OSC_communication.html"><span class="s3">OSC_communication</span></a> for more details.</p>
38 <p class="p4"><br></p>
39 <p class="p4"><b><span class="Apple-tab-span"> </span></b></p>
40 <p class="p3"><b><span class="Apple-tab-span"> </span>*new(addr, cmdName, action);</b></p>
41 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
42 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>addr</b></p>
43 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>an instance of NetAddr, usually obtained from your server:<span class="Apple-converted-space">  </span>server-addr</p>
44 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>an address of nil will respond to messages from anywhere.</p>
45 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
46 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>cmdName</b></p>
47 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a command path, such as ['\c_set', bus index]</p>
48 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
49 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>action</b><span class="Apple-converted-space"> </span></p>
50 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a function that will be evaluated when a cmd of that name is received from addr.</p>
51 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>args: time, theResponder, message</p>
52 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>note that OSCresponderNode evaluates its function in the system process.</p>
53 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>in order to access the application process (e.g. for GUI access ) use <b>{ ... }.defer</b>;</p>
54 <p class="p4"><br></p>
55 <p class="p3"><b><span class="s4">Command paths</span></b></p>
56 <p class="p4"><br></p>
57 <p class="p3"><span class="Apple-tab-span"> </span>OSC commands sometimes include additional parameters to specify the right responder.<span class="Apple-converted-space"> </span></p>
58 <p class="p4"><br></p>
59 <p class="p3"><span class="Apple-tab-span"> </span>For example<span class="Apple-converted-space">  </span><b>/tr </b>commands, which are generated<span class="Apple-converted-space">  </span>on the server by the <b>SendTrig </b>Ugen create</p>
60 <p class="p3"><span class="Apple-tab-span"> </span>an OSC packet consisting of:<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 class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>[ /tr,<span class="Apple-converted-space">  </span>nodeID, triggerID, value]</b></p>
61 <p class="p3"><span class="Apple-tab-span"> </span>This array actually specifies the source of value : <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>[</b> <b>/tr,</b> <b>nodeID,</b> <b>triggerID].</b></p>
62 <p class="p3"><span class="Apple-tab-span"> </span>We will refer to that array as a <b>command path.</b></p>
63 <p class="p4"><b><span class="Apple-converted-space"> </span></b></p>
64 <p class="p3"><span class="Apple-tab-span"> </span>To create an OSCpathResponder for a specific trigger, the <b>cmdName </b>parameter is simply replaced by<span class="Apple-converted-space"> </span></p>
65 <p class="p3"><span class="Apple-tab-span"> </span>the complete command path. <span class="Apple-converted-space"> </span></p>
66 <p class="p4"><br></p>
67 <p class="p3"><b><span class="s4">Path defaults</span></b></p>
68 <p class="p4"><br></p>
69 <p class="p3"><span class="Apple-tab-span"> </span>Any element of the command path array can be set to nil to create a responder that will<span class="Apple-converted-space"> </span></p>
70 <p class="p3"><span class="Apple-tab-span"> </span>handle multiple command paths.</p>
71 <p class="p4"><br></p>
72 <p class="p3"><span class="Apple-tab-span"> </span>For example, setting the commandpath = [<b>'/tr', nil, triggerID</b>]<span class="Apple-converted-space">  </span>makes a responder that<span class="Apple-converted-space"> </span></p>
73 <p class="p3"><span class="Apple-tab-span"> </span>responds to /tr messages from any Synth but with a specific triggerID.</p>
74 <p class="p3"><span class="Apple-tab-span"> </span>/tr messages from one Synth but with any triggerID.</p>
75 <p class="p4"><br></p>
76 <p class="p5"><br></p>
77 <p class="p5"><br></p>
78 <p class="p6">//Here is an example:</p>
79 <p class="p5"><br></p>
80 <p class="p7">s.boot;</p>
81 <p class="p5"><br></p>
82 <p class="p7">(</p>
83 <p class="p7"><span class="Apple-tab-span"> </span><span class="s5">var</span> s, commandpath, response, aSynth, nodeID, triggerID;</p>
84 <p class="p7"><span class="Apple-tab-span"> </span>s = <span class="s5">Server</span>.local;</p>
85 <p class="p7"><span class="Apple-tab-span"> </span>s.boot;</p>
86 <p class="p7"><span class="Apple-tab-span"> </span>triggerID = 1;</p>
87 <p class="p7"><span class="Apple-tab-span"> </span>aSynth = { <span class="s5">arg</span> freq = 1, triggerID = 1; <span class="s5">SendTrig</span>.kr(<span class="s5">SinOsc</span>.kr(freq), triggerID, 666); }.play;</p>
88 <p class="p7"><span class="Apple-tab-span"> </span>nodeID = aSynth.nodeID;</p>
89 <p class="p7"><span class="Apple-tab-span"> </span>commandpath = [<span class="s6">'/tr'</span>, nodeID, triggerID];</p>
90 <p class="p7"><span class="Apple-tab-span"> </span>response = { <span class="s5">arg</span> time, responder, message; message.postln };</p>
91 <p class="p5"><br></p>
92 <p class="p7"><span class="Apple-tab-span"> </span>o = <span class="s5">OSCpathResponder</span>(s.addr, commandpath, response);</p>
93 <p class="p7"><span class="Apple-tab-span"> </span>o.add;</p>
94 <p class="p5"><br></p>
95 <p class="p7">)</p>
96 <p class="p5"><br></p>
97 <p class="p6">// switch on and off:</p>
98 <p class="p7">o.remove;</p>
99 <p class="p7">o.add;</p>
100 <p class="p4"><br></p>
101 </body>
102 </html>