<!doctype html><html lang='en'><head><title>Sweep | SuperCollider 3.9.3 Help</title> <link rel='stylesheet' href='./../scdoc.css' type='text/css' /> <link rel='stylesheet' href='./../frontend.css' type='text/css' /> <link rel='stylesheet' href='./../custom.css' type='text/css' /> <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /> <script> var helpRoot = './..'; var scdoc_title = 'Sweep'; var scdoc_sc_version = '3.9.3'; </script> <script src='./../scdoc.js' type='text/javascript'></script> <script src='./../docmap.js' type='text/javascript'></script> <script src='./../prettify.js' type='text/javascript'></script> <script src='./../lang-sc.js' type='text/javascript'></script> </head> <body onload='fixTOC();prettyPrint()'> <div id='toc'> <div id='toctitle'>Sweep:</div> <span class='toc_search'>Filter: <input id='toc_search'></span><ul class='toc'><li class='toc1'><a href='#description'>Description</a></li> <ul class='toc'></ul><li class='toc1'><a href='#classmethods'>Class methods</a></li> <ul class='toc'><li class='toc3'><a href='#*ar'>ar</a> <a href='#*kr'>kr</a> </li> <li class='toc2'><a href='#Inherited%20class%20methods'>Inherited class methods</a></li> </ul><li class='toc1'><a href='#instancemethods'>Instance methods</a></li> <ul class='toc'><li class='toc2'><a href='#Inherited%20instance%20methods'>Inherited instance methods</a></li> </ul><li class='toc1'><a href='#examples'>Examples</a></li> <ul class='toc'></ul></ul></div><div class='contents'> <div id='menubar'></div> <div class='header'> <div id='label'> <span id='folder'>Classes</span> | <span id='categories'><a href='./../Browse.html#UGens'>UGens</a> > <a href='./../Browse.html#UGens>Triggers'>Triggers</a></span> </div><h1>Sweep<span id='superclasses'> : <a href="../Classes/UGen.html">UGen</a> : <a href="../Classes/AbstractFunction.html">AbstractFunction</a> : <a href="../Classes/Object.html">Object</a></span> </h1> <div id='summary'>Triggered linear ramp</div> </div> <div class='subheader'> <div id='filename'>Source: <a href='file:///Applications/SuperCollider.app/Contents/Resources/SCClassLibrary/Common/Audio/Trig.sc' title='/Applications/SuperCollider.app/Contents/Resources/SCClassLibrary/Common/Audio/Trig.sc'>Trig.sc</a></div></div> <h2><a class='anchor' name='description'>Description</a></h2> <p>Starts a linear raise by rate/sec from zero when trig input crosses from non-positive to positive. <p>When rate == 1, Sweep may be used to get a continually-updating measurement of the time (in seconds) since the last trigger.<h2><a class='anchor' name='classmethods'>Class Methods</a></h2> <h3 class='method-code'><span class='method-prefix'>Sweep.</span><a class='method-name' name='*ar' href='./../Overviews/Methods.html#ar'>ar</a>(<span class='argstr'>trig: 0</span>, <span class='argstr'>rate: 1</span>)</h3> <h3 class='method-code'><span class='method-prefix'>Sweep.</span><a class='method-name' name='*kr' href='./../Overviews/Methods.html#kr'>kr</a>(<span class='argstr'>trig: 0</span>, <span class='argstr'>rate: 1</span>)</h3> <div class='method'> <p><h4>Arguments:</h4> <table class='arguments'> <tr><td class='argumentname'>trig<td class='argumentdesc'> <p>triggers when trig input crosses from non-positive to positive.<tr><td class='argumentname'>rate<td class='argumentdesc'> <p>rate/sec raise rate</table></div><h3><a class='anchor' name='Inherited%20class%20methods'>Inherited class methods</a></h3> <div id='inheritedclassmets'></div><h2><a class='anchor' name='instancemethods'>Instance Methods</a></h2> <h3><a class='anchor' name='Inherited%20instance%20methods'>Inherited instance methods</a></h3> <div id='inheritedinstmets'></div><h2><a class='anchor' name='examples'>Examples</a></h2> <pre class='code prettyprint lang-sc'>// using sweep to modulate sine frequency ( { var trig; trig = Impulse.kr(MouseX.kr(0.5, 20, 1)); SinOsc.ar(Sweep.kr(trig, 700) + 500, 0, 0.2) }.play; ) // using sweep to index into a buffer b = Buffer.read(s, Platform.resourceDir +/+ "sounds/a11wlk01.wav"); ( { var trig; trig = Impulse.kr(MouseX.kr(0.5, 10, 1)); BufRd.ar(1, b, Sweep.ar(trig, BufSampleRate.ir(0))) }.play; ) // backwards, variable offset ( { var trig, pos, rate; trig = Impulse.kr(MouseX.kr(0.5, 10, 1)); rate = BufSampleRate.ir(0); pos = Sweep.ar(trig, rate.neg) + (BufFrames.ir(0) * LFNoise0.kr(0.2)); BufRd.ar(1, b, pos) }.play; ) // raising rate ( { var trig, rate; trig = Impulse.kr(MouseX.kr(0.5, 10, 1)); rate = Sweep.kr(trig, 2) + 0.5; BufRd.ar(1, b, Sweep.ar(trig, BufSampleRate.ir(0) * rate)) }.play; ) b.free</pre> <p>Sweep can be used as a resettable <a href="./../Classes/Phasor.html">Phasor</a> or <a href="./../Classes/Line.html">Line</a> - one that can start, pause, resume and stop. To get a resettable <a href="./../Classes/XLine.html">XLine</a> behavior change the <code class='code prettyprint lang-sc'>linlin</code> to <code class='code prettyprint lang-sc'>linexp</code> in the SynthDef below.<pre class='code prettyprint lang-sc'>( SynthDef(\lineReset, { |out, start= 0, end= 1, dur= 1, t_trig= 1, run= 1| var phasor = Sweep.ar(t_trig, run / dur).linlin(0, 1, start, end, \minmax); phasor.poll; Out.ar(out, SinOsc.ar(phasor, 0, 0.2)); }).add; ) a = Synth(\lineReset, [\start, 400, \end, 800, \dur, 2]) a.set(\t_trig, 1) a.set(\run, 0) a.set(\run, 1) a.set(\t_trig, 1) a.free //shorter duration and downwards... a= Synth(\lineReset, [\start, 1000, \end, 500, \dur, 0.5]) a.set(\t_trig, 1) a.set(\run, 0) a.set(\run, 1) a.set(\t_trig, 1) a.free</pre> <p><div class='doclink'>helpfile source: <a href='file:///Applications/SuperCollider.app/Contents/Resources/HelpSource/Classes/Sweep.schelp'>/Applications/SuperCollider.app/Contents/Resources/HelpSource/Classes/Sweep.schelp</a><br>link::Classes/Sweep::<br></div></div></body></html>