1class:: Poll 2categories:: UGens>Info 3summary:: Print the current output value of a UGen 4related:: Classes/SendTrig, Classes/OSCFunc 5 6description:: 7 8Print the current output value of a UGen, useful for debugging SynthDefs. 9 10WARNING:: Printing values from the Server in intensive for the CPU. Poll should be used for debugging purposes.:: 11 12classmethods:: 13private:: categories, new, new1 14 15method:: ar, kr 16argument::trig 17a non-positive to positive transition telling Poll to return a value 18argument::in 19the signal you want to poll 20argument::label 21a string or symbol to be printed with the polled value 22argument::trigid 23if greater then 0, a '/tr' message is sent back to the client (similar to SendTrig) 24 25returns:: its in signal (and is therefore transparent). 26 27instancemethods:: 28private:: checkInputs, init 29 30examples:: 31code:: 32s.boot; 33 34{ Poll.kr(Impulse.kr(10), Line.kr(0, 1, 1), \test) }.play(s); 35 36// multichannel expansion: 37 38{ Poll.kr(Impulse.kr([10, 5]), Line.kr(0, [1, 5], [1, 2]), [\test, \test2]) }.play(s); 39 40 41 42// using the poll message: 43 44{ SinOsc.ar(375, 0, 1).poll(Impulse.ar(20), \test2) }.play(s); 45 46// if no arguments are given, the poll is done every 0.1 sec. 47{ Line.kr(0, 1, 1).poll }.play(s); 48 49 50// send a '/tr' message back to the client. This can be useful if the server runs on another 51// computer than the client, i.e. the post messages by the server cannot be read locally. 52 53o = OSCFunc({arg msg; msg.postln;}, '/tr', s.addr); 54 55{Poll.ar(Impulse.ar(5), Line.ar(0, 1, 1), \test2, 1234)}.play(s); 56{SinOsc.ar(220, 0, 1).poll(Impulse.ar(15), "test", 1234)}.play(s); 57 58o.free; 59s.quit; 60 61 62 63 64// This example will kill the server (by outputting NaN). 65// Poll.ar will help us spot why it's happening. 66// Warning: You may need to reboot your server after running this. 67( 68{ 69var cutoff, son; 70cutoff = LFPar.kr(0.2, 0, 500, 500); 71son = LPF.ar(WhiteNoise.ar, cutoff); 72 73// Using Poll to debug by spitting out a value if the output hits NaN 74Poll.ar(if((son<=0)||(son>=0), 0, 1), cutoff, "Cutoff value which causes NaN:"); 75 76son; 77 78}.play(s); 79) 80 81 82// This example polls when someone hits the trigger 83( 84x = {|t_poll=0| 85var minfreq, maxfreq, son; 86minfreq = LFNoise2.ar(0.25, 100, 110); 87maxfreq = LFNoise2.ar(0.25, 200, 220); 88 89son = Gendy1.ar(minfreq: minfreq, maxfreq: maxfreq, mul: 0.1); 90 91Poll.kr(t_poll, [minfreq, maxfreq], ["minfreq", "maxfreq"]); 92 93son; 94 95}.play(s); 96) 97 98x.set(\t_poll, 1); // Hit this whenever you want to know what the parameters are 99:: 100 101