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: 9.0px Monaco
; min-height: 12.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: 12.0px Helvetica
; color: #bf0000; min-height: 14.0px}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
16 span
.s1
{color: #0000bf}
17 span
.s2
{color: #007300}
18 span
.Apple-tab-span
{white-space:pre
}
22 <p class=
"p1"><b>LastValue
<span class=
"Apple-converted-space"> <span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span></b></p>
23 <p class=
"p2"><br></p>
24 <p class=
"p3"><b>LastValue.ar(in, diff)
</b></p>
25 <p class=
"p3"><b>LastValue.kr(in, diff)
</b></p>
26 <p class=
"p4"><b></b><br></p>
27 <p class=
"p3">output the last value before the input changed more than a threshhold
</p>
28 <p class=
"p4"><br></p>
29 <p class=
"p4"><br></p>
30 <p class=
"p3"><b><span class=
"Apple-tab-span"> </span>in
<span class=
"Apple-tab-span"> </span></b>input
</p>
31 <p class=
"p3"><b><span class=
"Apple-tab-span"> </span>diff
</b> <span class=
"Apple-tab-span"> </span>difference threshhold
<span class=
"Apple-converted-space"> </span></p>
32 <p class=
"p5"><br></p>
33 <p class=
"p4"><br></p>
34 <p class=
"p6"><span class=
"Apple-tab-span"> </span>d = {
<span class=
"s1">arg
</span> freq=
440;
<span class=
"s1">SinOsc
</span>.ar(
<span class=
"s1">LastValue
</span>.ar(freq,
20),
0,
0.2) }.play;
</p>
35 <p class=
"p4"><br></p>
36 <p class=
"p6"><span class=
"Apple-tab-span"> </span>d.set(
<span class=
"s2">\freq
</span>,
400);
</p>
37 <p class=
"p6"><span class=
"Apple-tab-span"> </span>d.set(
<span class=
"s2">\freq
</span>,
200);
</p>
38 <p class=
"p6"><span class=
"Apple-tab-span"> </span>d.set(
<span class=
"s2">\freq
</span>,
670);
</p>
39 <p class=
"p6"><span class=
"Apple-tab-span"> </span>d.set(
<span class=
"s2">\freq
</span>,
680);
</p>
40 <p class=
"p6"><span class=
"Apple-tab-span"> </span>d.set(
<span class=
"s2">\freq
</span>,
695);
</p>
41 <p class=
"p6"><span class=
"Apple-tab-span"> </span>d.free;
</p>
42 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
43 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
44 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
45 <p class=
"p3"><span class=
"Apple-tab-span"> </span>return the difference between currrent and the last changed
<span class=
"Apple-converted-space"> </span></p>
46 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
47 <p class=
"p6"><span class=
"Apple-tab-span"> </span>(
</p>
48 <p class=
"p6"><span class=
"Apple-tab-span"> </span>d = {
<span class=
"s1">arg
</span> out=
0, val=
1;
</p>
49 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s1">SinOsc
</span>.ar(
</p>
50 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>abs(val -
<span class=
"s1">LastValue
</span>.kr(val)) *
400 +
200,
<span class=
"Apple-converted-space"> </span></p>
51 <p class=
"p6"><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,
0.2</p>
52 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>)
</p>
53 <p class=
"p6"><span class=
"Apple-tab-span"> </span>}.play;
</p>
54 <p class=
"p6"><span class=
"Apple-tab-span"> </span>)
</p>
55 <p class=
"p2"><span class=
"Apple-tab-span"> </span></p>
56 <p class=
"p6"><span class=
"Apple-tab-span"> </span>d.set(
<span class=
"s2">\val
</span>,
3);
</p>
57 <p class=
"p6"><span class=
"Apple-tab-span"> </span>d.set(
<span class=
"s2">\val
</span>,
2);
</p>
58 <p class=
"p6"><span class=
"Apple-tab-span"> </span>d.set(
<span class=
"s2">\val
</span>,
0.2);
</p>
59 <p class=
"p6"><span class=
"Apple-tab-span"> </span>d.set(
<span class=
"s2">\val
</span>,
1);
</p>
60 <p class=
"p6"><span class=
"Apple-tab-span"> </span>d.set(
<span class=
"s2">\val
</span>,
2);
</p>
61 <p class=
"p6"><span class=
"Apple-tab-span"> </span>d.free;
</p>
62 <p class=
"p2"><span class=
"Apple-tab-span"> </span></p>