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: 18.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.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 Monaco
; min-height: 16.0px}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #ad1d13}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #2b6f11}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
18 span
.s1
{text-decoration: underline
; color: #002ee1}
19 span
.s2
{color: #000000}
20 span
.s3
{color: #0019ba}
21 span
.s4
{color: #2b6f11}
22 span
.Apple-tab-span
{white-space:pre
}
26 <p class=
"p1"><b>Lag3UD
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>exponential lag
</b></p>
27 <p class=
"p2"><br></p>
28 <p class=
"p3"><b>Lag3UD.ar(in, lagTimeU, lagTimeD, mul, add))
</b></p>
29 <p class=
"p3"><b>Lag3UD.kr(in, lagTimeU, lagTimeD, mul, add))
</b></p>
30 <p class=
"p2"><br></p>
31 <p class=
"p2"><br></p>
32 <p class=
"p3">Lag3UD is equivalent to LagUD.kr(LagUD.kr(LagUD.kr(in, timeU, timeD), timeU, timeD), timeU, timeD), thus resulting in a smoother transition. This saves on CPU as you only have to calculate the decay factor once instead of three times. See
<b>LagUD
</b> for more details.
</p>
34 See also
<a href=
"Lag3.html"><span class=
"s1">Lag3
</span></a></p>
35 <p class=
"p3"><b>in
</b> - input signal
</p>
36 <p class=
"p3"><b>lagTimeU
</b> -
60 dB lag time in seconds for the upgoing signal.
</p>
37 <p class=
"p3"><b>lagTimeD
</b> -
60 dB lag time in seconds for the downgoing signal.
</p>
38 <p class=
"p4"><br></p>
40 <p class=
"p6">// used to lag pitch
</p>
41 <p class=
"p7"><span class=
"s2"><span class=
"Apple-converted-space"> </span></span><span class=
"s3">SynthDef
</span><span class=
"s2">(
</span>\lag3ud_help
<span class=
"s2">,
</span></p>
42 <p class=
"p8"><span class=
"Apple-converted-space"> </span></p>
43 <p class=
"p5"><span class=
"Apple-tab-span"> </span>{
<span class=
"s3">arg
</span> freq=
300,lagup=
1, lagdown=
5;
</p>
44 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">Out
</span>.ar(
0,
</p>
45 <p class=
"p6"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span><span class=
"s3">SinOsc
</span><span class=
"s2">.ar(
</span>// sine wave
</p>
46 <p class=
"p6"><span class=
"s2"><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><span class=
"s3">Lag3UD
</span><span class=
"s2">.kr(
</span>// lag the frequency
</p>
47 <p class=
"p5"><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>freq,
</p>
48 <p class=
"p5"><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>lagup,
</p>
49 <p class=
"p5"><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>lagdown
</p>
50 <p class=
"p5"><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>
51 <p class=
"p6"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0,
</span>// phase
</p>
52 <p class=
"p6"><span class=
"s2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0.2 </span>// sine amplitude
</p>
53 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>)
</p>
54 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>);
</p>
55 <p class=
"p5"><span class=
"Apple-tab-span"> </span>}).send(s);
</p>
57 <p class=
"p8"><br></p>
58 <p class=
"p6"><span class=
"s2">x =
</span><span class=
"s3">Synth
</span><span class=
"s2">.new(
</span><span class=
"s4">\lag3ud_help
</span><span class=
"s2"> );
</span>// create the synth
</p>
59 <p class=
"p8"><span class=
"Apple-converted-space"> </span></p>
60 <p class=
"p6"><span class=
"s2">x.set(
</span><span class=
"s4">\freq
</span><span class=
"s2">,
500 );
</span>// set the frequency to a higher value (takes
1 second)
</p>
61 <p class=
"p6"><span class=
"s2">x.set(
</span><span class=
"s4">\freq
</span><span class=
"s2">,
100 );
</span>// set the frequency to a lower value (takes
5 seconds)
</p>
62 <p class=
"p5">x.free;
</p>