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=
"1038.29">
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: 9.0px Monaco
; color: #782727; min-height: 12.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: 12.0px Helvetica
; color: #2b30fa}
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
; min-height: 12.0px}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #bf0909}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #1e22bf}
18 span
.s1
{font: 18.0px Helvetica
}
19 span
.s2
{color: #000000}
20 span
.s3
{color: #1e22bf}
21 span
.s4
{color: #007313}
22 span
.s5
{color: #606060}
23 span
.Apple-tab-span
{white-space:pre
}
27 <p class=
"p1"><span class=
"s1"><b>softVol_
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></span><b>set a nodeproxy's vol conditionally
</b></p>
28 <p class=
"p2"><br></p>
29 <p class=
"p2"><br></p>
30 <p class=
"p1"><b><span class=
"Apple-tab-span"> </span>softVol_(param, val, within =
0.025, pause = true, lastVal, spec)
</b></p>
31 <p class=
"p1"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>val -
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>the volume value to set to
<span class=
"Apple-converted-space"> </span></p>
32 <p class=
"p1"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>within
<span class=
"Apple-converted-space"> <span class=
"Apple-tab-span"> </span></span></b>the normalized range within which the set is accepted - default is
0.025</p>
33 <p class=
"p1"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>pause
<span class=
"Apple-tab-span"> </span></b>a flag whether to pause the nodeproxy when volume is
0.
<span class=
"Apple-converted-space"> </span></p>
34 <p class=
"p1"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>waits for
0.2 seconds for volume to go down first.
</p>
35 <p class=
"p1"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>lastVal
<span class=
"Apple-tab-span"> </span></b>the previous value that the controller has set - can be
<span class=
"Apple-converted-space"> </span></p>
36 <p class=
"p1"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>spec
</b><span class=
"Apple-tab-span"> </span>a ControlSpec can be passed in. if nil, \amp.asSpec is used.
</p>
37 <p class=
"p3"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
38 <p class=
"p2"><br></p>
39 <p class=
"p4"><span class=
"s2"><b>See also
</b><a href=
"softSet.html"><b>softSet
</b></a></span><b>,
</b><span class=
"s2"><b> </b><a href=
"softPut.html"><b>softPut
</b></a><b>.
</b></span></p>
40 <p class=
"p3"><b></b><br></p>
41 <p class=
"p3"><b></b><br></p>
42 <p class=
"p5"><span class=
"s3">Ndef
</span>(
<span class=
"s4">\test
</span>, {
<span class=
"s3">|freq=
200|
</span> Splay.ar(
<span class=
"s3">SinOsc
</span>.ar(freq * Array.rand(
12,
0.95,
1.05))) });
</p>
43 <p class=
"p5"><span class=
"s3">Ndef
</span>(
<span class=
"s4">\test
</span>).play(vol:
0.1);
</p>
44 <p class=
"p6"><br></p>
45 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// example of softSet, softSet which knows lastVal,
</p>
46 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// softVol_ and softVol_ which knows lastVol:
</p>
48 <p class=
"p5">w =
<span class=
"s3">Window
</span>(
<span class=
"s5">"softVol"</span>,
<span class=
"s3">Rect
</span>(
500,
200,
400,
240)).front;
</p>
49 <p class=
"p5">w.view.addFlowLayout;
</p>
50 <p class=
"p8">NdefGui
<span class=
"s2">(
</span>Ndef
<span class=
"s2">(
</span><span class=
"s4">\test
</span><span class=
"s2">),
2, w);
</span></p>
51 <p class=
"p6"><br></p>
52 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// same for volume - not too safe
</p>
53 <p class=
"p5"><span class=
"s3">EZSlider
</span>(w,
340@
30,
<span class=
"s4">\softVol
</span>,
<span class=
"s4">\amp
</span>, {
<span class=
"s3">|sl|
</span><span class=
"Apple-converted-space"> </span></p>
54 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s3">Ndef
</span>(
<span class=
"s4">\test
</span>).softVol_(sl.value,
0.05)
</p>
56 <p class=
"p7"><span class=
"s2"><span class=
"Apple-tab-span"> </span></span>// safer
</p>
57 <p class=
"p5"><span class=
"s3">EZSlider
</span>(w,
340@
30,
<span class=
"s4">\knowLastV
</span>,
<span class=
"s4">\amp
</span>,
<span class=
"s3">Routine
</span> {
<span class=
"s3">|sl|
</span><span class=
"Apple-converted-space"> </span></p>
58 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"s3">var
</span> newVal, lastVal;
<span class=
"Apple-converted-space"> </span></p>
59 <p class=
"p5"><span class=
"Apple-tab-span"> </span>loop {
<span class=
"Apple-converted-space"> </span></p>
60 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>newVal = sl.value;
</p>
61 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s3">Ndef
</span>(
<span class=
"s4">\test
</span>).softVol_(sl.value,
0.05, lastVal: lastVal);
</p>
62 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>lastVal = newVal;
</p>
63 <p class=
"p5"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s4">\dummy
</span>.yield;
</p>
64 <p class=
"p5"><span class=
"Apple-tab-span"> </span>}
</p>
67 <p class=
"p6"><br></p>