1 <!DOCTYPE html PUBLIC
"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8">
5 <meta http-equiv=
"Content-Style-Type" content=
"text/css">
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: 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 0.0px; font: 12.0px Monaco
; min-height: 16.0px}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #a71e12}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #0019b7}
19 span
.s1
{font: 18.0px Helvetica
}
20 span
.s2
{color: #0000ff}
21 span
.s3
{color: #0019b7}
22 span
.s4
{color: #326f17}
23 span
.s5
{color: #606060}
24 span
.s6
{color: #000000}
25 span
.Apple-tab-span
{white-space:pre
}
29 <p class=
"p1"><span class=
"s1"><b>Poll
<span class=
"Apple-tab-span"> </span> <span class=
"Apple-converted-space"> <span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span></b></span><b>print the current output value of a UGen
</b></p>
30 <p class=
"p2"><br></p>
31 <p class=
"p1"><b>Poll.ar(trig, in, label, trigid)
</b></p>
32 <p class=
"p1"><b>Poll.kr(trig, in, label, trigid)
</b></p>
33 <p class=
"p3"><br></p>
34 <p class=
"p4"><b>Usage
</b></p>
35 <p class=
"p3"><br></p>
36 <p class=
"p1"><b><span class=
"Apple-tab-span"> </span>trig
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>a non-positive to positive transition telling Poll to return a value
</p>
37 <p class=
"p1"><b><span class=
"Apple-tab-span"> </span>in
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>the signal you want to poll
</p>
38 <p class=
"p1"><b><span class=
"Apple-tab-span"> </span>label
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>a string or symbol to be printed with the polled value
</p>
39 <p class=
"p1"><b><span class=
"Apple-tab-span"> </span>trigid
<span class=
"Apple-tab-span"> </span></b>if greater then
0, a
<b>'/tr' message
</b> is sent back to the client (similar to
<a href=
"SendTrig.html"><span class=
"s2">SendTrig
</span></a>)
</p>
40 <p class=
"p3"><br></p>
41 <p class=
"p3"><br></p>
42 <p class=
"p1"><b>Poll returns its in signal (and is therefore transparent).
<span class=
"Apple-converted-space"> </span></b></p>
43 <p class=
"p3"><br></p>
44 <p class=
"p1"><b>WARNING: Printing values from the Server in intensive for the CPU. Poll should be used for debugging purposes.
</b></p>
45 <p class=
"p5"><br></p>
46 <p class=
"p6"><br></p>
47 <p class=
"p7">// examples:
</p>
48 <p class=
"p6"><br></p>
49 <p class=
"p8">s.boot;
</p>
50 <p class=
"p6"><br></p>
51 <p class=
"p8">{
<span class=
"s3">Poll
</span>.kr(
<span class=
"s3">Impulse
</span>.kr(
10),
<span class=
"s3">Line
</span>.kr(
0,
1,
1),
<span class=
"s4">\test
</span>) }.play(s);
</p>
52 <p class=
"p6"><br></p>
53 <p class=
"p7">// multichannel expansion:
</p>
54 <p class=
"p6"><br></p>
55 <p class=
"p8">{
<span class=
"s3">Poll
</span>.kr(
<span class=
"s3">Impulse
</span>.kr([
10,
5]),
<span class=
"s3">Line
</span>.kr(
0, [
1,
5], [
1,
2]), [
<span class=
"s4">\test
</span>,
<span class=
"s4">\test2
</span>]) }.play(s);
</p>
56 <p class=
"p6"><br></p>
57 <p class=
"p6"><br></p>
58 <p class=
"p6"><br></p>
59 <p class=
"p7">// using the poll message:
</p>
60 <p class=
"p6"><br></p>
61 <p class=
"p8">{
<span class=
"s3">SinOsc
</span>.ar(
375,
0,
1).poll(
<span class=
"s3">Impulse
</span>.ar(
20),
<span class=
"s4">\test2
</span>) }.play(s);
</p>
62 <p class=
"p6"><br></p>
63 <p class=
"p7">// if no arguments are given, the poll is done every
0.1 sec.
</p>
64 <p class=
"p8">{
<span class=
"Apple-converted-space"> </span><span class=
"s3">Line
</span>.kr(
0,
1,
1).poll }.play(s);
</p>
65 <p class=
"p6"><br></p>
66 <p class=
"p6"><br></p>
67 <p class=
"p7">// send a '/tr' message back to the client. This can be useful if the server runs on another
</p>
68 <p class=
"p7">// computer than the client, i.e. the post messages by the server cannot be read locally.
</p>
69 <p class=
"p6"><br></p>
70 <p class=
"p8">o =
<span class=
"s3">OSCresponderNode
</span>(s.addr,
<span class=
"s4">'/tr'
</span>, {
<span class=
"s3">arg
</span> time, resp, msg;
</p>
71 <p class=
"p8"><span class=
"Apple-tab-span"> </span>msg.postln;
</p>
72 <p class=
"p8"><span class=
"Apple-tab-span"> </span>}).add
</p>
73 <p class=
"p6"><br></p>
74 <p class=
"p8">{
<span class=
"s3">Poll
</span>.ar(
<span class=
"s3">Impulse
</span>.ar(
5),
<span class=
"s3">Line
</span>.ar(
0,
1,
1),
<span class=
"s4">\test2
</span>,
1234)}.play(s);
</p>
75 <p class=
"p8">{
<span class=
"s3">SinOsc
</span>.ar(
220,
0,
1).poll(
<span class=
"s3">Impulse
</span>.ar(
15),
<span class=
"s5">"test"</span>,
1234)}.play(s);
</p>
76 <p class=
"p6"><span class=
"Apple-tab-span"> </span></p>
77 <p class=
"p8">o.remove;
</p>
78 <p class=
"p8">s.quit;
</p>
79 <p class=
"p6"><br></p>
80 <p class=
"p6"><br></p>
81 <p class=
"p6"><br></p>
82 <p class=
"p6"><br></p>
83 <p class=
"p7">// This example will kill the server (by outputting NaN).
</p>
84 <p class=
"p7">// Poll.ar will help us spot why it's happening.
</p>
85 <p class=
"p7">// Warning: You may need to reboot your server after running this.
</p>
88 <p class=
"p8"><span class=
"s3">var
</span> cutoff, son;
</p>
89 <p class=
"p8">cutoff =
<span class=
"s3">LFPar
</span>.kr(
0.2,
0,
500,
500);
</p>
90 <p class=
"p8">son =
<span class=
"s3">LPF
</span>.ar(
<span class=
"s3">WhiteNoise
</span>.ar, cutoff);
</p>
91 <p class=
"p6"><br></p>
92 <p class=
"p7">// Using Poll to debug by spitting out a value if the output hits NaN
</p>
93 <p class=
"p8"><span class=
"s3">Poll
</span>.ar(if((son
<=
0)||(son
>=
0),
0,
1), cutoff,
<span class=
"s5">"Cutoff value which causes NaN:"</span>);
</p>
94 <p class=
"p6"><br></p>
95 <p class=
"p8">son;
</p>
96 <p class=
"p6"><br></p>
97 <p class=
"p8">}.play(s);
</p>
99 <p class=
"p6"><br></p>
100 <p class=
"p6"><br></p>
101 <p class=
"p7">// This example polls when someone hits the trigger
</p>
103 <p class=
"p9"><span class=
"s6">x = {
</span>|t_poll=
0|
</p>
104 <p class=
"p8"><span class=
"s3">var
</span> minfreq, maxfreq, son;
</p>
105 <p class=
"p8">minfreq =
<span class=
"s3">LFNoise2
</span>.ar(
0.25,
100,
110);
</p>
106 <p class=
"p8">maxfreq =
<span class=
"s3">LFNoise2
</span>.ar(
0.25,
200,
220);
</p>
107 <p class=
"p6"><br></p>
108 <p class=
"p8">son =
<span class=
"s3">Gendy1
</span>.ar(minfreq: minfreq, maxfreq: maxfreq, mul:
0.1);
</p>
109 <p class=
"p6"><br></p>
110 <p class=
"p8"><span class=
"s3">Poll
</span>.kr(t_poll, [minfreq, maxfreq], [
<span class=
"s5">"minfreq",
"maxfreq"</span>]);
</p>
111 <p class=
"p6"><br></p>
112 <p class=
"p8">son;
</p>
113 <p class=
"p6"><br></p>
114 <p class=
"p8">}.play(s);
</p>
116 <p class=
"p6"><br></p>
117 <p class=
"p7"><span class=
"s6">x.set(
</span><span class=
"s4">\t_poll
</span><span class=
"s6">,
1);
</span>// Hit this whenever you want to know what the parameters are
</p>
118 <p class=
"p6"><br></p>
119 <p class=
"p6"><br></p>