Include a header file required for build on mac 10.4
[supercollider.git] / Help / GUI / Cocoa-GUI / SCLevelIndicator.html
blob6b2c2d9a2931d8e3274dce35e72a6036acaba4eb
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta http-equiv="Content-Style-Type" content="text/css">
6 <title></title>
7 <meta name="Generator" content="Cocoa HTML Writer">
8 <meta name="CocoaVersion" content="949.43">
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: 12.0px Helvetica; min-height: 14.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; min-height: 12.0px}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #001bec}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica}
15 p.p6 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco; min-height: 12.0px}
16 p.p7 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica}
17 p.p8 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica; min-height: 14.0px}
18 p.p9 {margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica}
19 p.p10 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco}
20 p.p11 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco}
21 p.p12 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica}
22 p.p13 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #9f2423}
23 p.p14 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #606060}
24 span.s1 {font: 18.0px Helvetica}
25 span.s2 {color: #0049f3}
26 span.s3 {color: #000000}
27 span.s4 {text-decoration: underline}
28 span.s5 {color: #6f7178}
29 span.s6 {color: #0016bd}
30 span.s7 {color: #003cf7}
31 span.s8 {color: #0032b5}
32 span.s9 {color: #0020bb}
33 span.s10 {color: #3c6d00}
34 span.s11 {color: #9f2423}
35 span.Apple-tab-span {white-space:pre}
36 </style>
37 </head>
38 <body>
39 <p class="p1"><span class="s1"><b>SCLevelIndicator<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b></span><b>a level indicator GUI widget</b><span class="s1"><b><span class="Apple-tab-span"> </span></b></span></p>
40 <p class="p2"><br></p>
41 <p class="p1"><b>Inherits from: </b><a href="../../Core/Object.html"><span class="s2"><b>Object</b></span></a><b> : </b><a href="SCView.html"><span class="s2"><b>SCView</b></span></a></p>
42 <p class="p3"><br></p>
43 <p class="p1">A level indicator view, suitable for use as a level or peak meter, etc.</p>
44 <p class="p2"><br></p>
45 <p class="p4"><span class="s3"><b>See also:</b> <a href="SCRangeSlider.html"><span class="s4">SCRangeSlider</span></a></span></p>
46 <p class="p2"><br></p>
47 <p class="p5"><b>Creation / Class Methods</b></p>
48 <p class="p6"><br></p>
49 <p class="p7"><b><span class="Apple-tab-span"> </span>*new (parent, bounds)</b></p>
50 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
51 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>parent </b>- The parent view.</p>
52 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>bounds </b>- An instance of <a href="../../Geometry/Rect.html"><span class="s5">Rect</span></a>, or a <a href="../../Geometry/Point.html"><span class="s5">Point</span></a> indicating width@height.</p>
53 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
54 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
55 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w = <span class="s6">Window</span>.new.front;</p>
56 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a = <span class="s6">SCLevelIndicator</span>(w, <span class="s6">Rect</span>(10, 10, 20, 160));</p>
57 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
58 <p class="p6"><br></p>
59 <p class="p6"><br></p>
60 <p class="p12"><b>Accessing Instance and Class Variables</b></p>
61 <p class="p8"><span class="Apple-tab-span"> </span></p>
62 <p class="p7"><b><span class="Apple-tab-span"> </span>value</b></p>
63 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
64 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Gets the current level of the view.</p>
65 <p class="p6"><br></p>
66 <p class="p6"><br></p>
67 <p class="p7"><b><span class="Apple-tab-span"> </span>value_ (val)</b></p>
68 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
69 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Sets the current level of the view</p>
70 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>val </b>- A <a href="../../Math/Float.html"><span class="s7">Float</span></a> between 0 and 1.</p>
71 <p class="p6"><br></p>
72 <p class="p6"><br></p>
73 <p class="p7"><b><span class="Apple-tab-span"> </span>valueAction_ (val)</b></p>
74 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
75 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>As value but calls the action function. Currently not used.</p>
76 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>val </b>- A <a href="../../Math/Float.html"><span class="s7">Float</span></a> between 0 and 1.</p>
77 <p class="p6"><br></p>
78 <p class="p6"><br></p>
79 <p class="p7"><b><span class="Apple-tab-span"> </span>warning_ (val)</b></p>
80 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
81 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Styles 0 and 2 (see below) implement a warning display. If critical is &gt; <b>warning</b> the view will turn yellow if <b>value</b> is &gt;= to <b>val</b>. If critical is &lt;= <b>warning</b> the view will turn yellow if <b>value</b> is &lt;= to <b>val</b>. If <b>drawsPeak</b> is true warning will be displayed based on <b>peakLevel </b>rather than <b>value</b>.</p>
82 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>val </b>- A <a href="../../Math/Float.html"><span class="s7">Float</span></a> between 0 and 1.</p>
83 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
84 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
85 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w = <span class="s6">Window</span>.new.front;</p>
86 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a = <span class="s6">SCLevelIndicator</span>(w, <span class="s6">Rect</span>(10, 10, 20, 160));</p>
87 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.value = 0.5;</p>
88 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
89 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.warning = 0.6; a.critical = 0.9;</p>
90 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.value = 0.7;</p>
91 <p class="p6"><br></p>
92 <p class="p6"><br></p>
93 <p class="p7"><b><span class="Apple-tab-span"> </span>critical_ (val)</b></p>
94 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
95 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Styles 0 and 2 (see below) implement a critical display. If critical is &gt; <b>warning</b> the view will turn red if <b>value</b> is &gt;= to <b>val</b>. If critical is &lt;= <b>warning</b> the view will turn yellow if <b>value</b> is &lt;= to <b>val</b>. If <b>drawsPeak</b> is true critical will be displayed based on <b>peakLevel </b>rather than <b>value</b>.</p>
96 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>val </b>- A <a href="../../Math/Float.html"><span class="s7">Float</span></a> between 0 and 1.</p>
97 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
98 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
99 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w = <span class="s6">Window</span>.new.front;</p>
100 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a = <span class="s6">SCLevelIndicator</span>(w, <span class="s6">Rect</span>(10, 10, 20, 160));</p>
101 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.style = 2;</p>
102 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.numSteps = 10;</p>
103 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.value = 0.5;</p>
104 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
105 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.warning = 0.6; a.critical = 0.9;</p>
106 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.value = 1;</p>
107 <p class="p6"><br></p>
108 <p class="p6"><br></p>
109 <p class="p7"><b><span class="Apple-tab-span"> </span>style_ (val)</b></p>
110 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
111 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Sets the style of the view</p>
112 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>val </b>- An <a href="../../Math/Integer.html"><span class="s7">Integer</span></a> from 0 to 3. 0 = colored bar; 1 = graduated black lines; 2 = LED style (see <b>numSteps_</b>); 3 = LED style with custom image (see <b>image_</b>).</p>
113 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
114 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
115 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w = <span class="s8">Window</span>.new.front;</p>
116 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w.addFlowLayout;</p>
117 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>4.do({|i|</p>
118 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a = <span class="s8">SCLevelIndicator</span>(w, <span class="s8">Rect</span>(0, 0, 20, 200));</p>
119 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.style = i;</p>
120 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.numSteps = 10;</p>
121 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.value = 0.5;</p>
122 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>});</p>
123 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
124 <p class="p6"><br></p>
125 <p class="p6"><br></p>
126 <p class="p7"><b><span class="Apple-tab-span"> </span>numSteps_ (val)</b></p>
127 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
128 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>The number of steps used in styles 2 and 3. (See <b>style_</b>)</p>
129 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>val </b>- A positive <a href="../../Math/Integer.html"><span class="s7">Integer</span></a>.</p>
130 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
131 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
132 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w = <span class="s8">Window</span>.new.front;</p>
133 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a = <span class="s8">SCLevelIndicator</span>(w, <span class="s8">Rect</span>(10, 10, 200, 20));</p>
134 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.style = 2;</p>
135 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.value = 1;</p>
136 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
137 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.numSteps = 10;</p>
138 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.numSteps = 20;</p>
139 <p class="p6"><br></p>
140 <p class="p6"><br></p>
141 <p class="p7"><b><span class="Apple-tab-span"> </span>image_ (image)</b></p>
142 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
143 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Sets the image used in style 3. See below for an example.</p>
144 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>image </b>- An <a href="SCImage/SCImage.html"><span class="s7">SCImage</span></a>. The default image is the SC cube.</p>
145 <p class="p6"><br></p>
146 <p class="p6"><br></p>
147 <p class="p7"><b><span class="Apple-tab-span"> </span>numTicks_ (ticks)</b></p>
148 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
149 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>The number of ticks to display in the view's scale.</p>
150 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>ticks </b>- An <a href="../../Math/Integer.html"><span class="s7">Integer</span></a> &gt;= 0.</p>
151 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
152 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
153 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w = <span class="s8">Window</span>.new.front;</p>
154 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w.view.background = Color.black;</p>
155 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a = <span class="s8">SCLevelIndicator</span>(w, <span class="s8">Rect</span>(10, 10, 300, 30));</p>
156 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.numTicks = 11;</p>
157 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.value = 0.5;</p>
158 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
159 <p class="p6"><br></p>
160 <p class="p6"><br></p>
161 <p class="p7"><b><span class="Apple-tab-span"> </span>numMajorTicks_ (ticks)</b></p>
162 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
163 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>The number of ticks in the view's scale which will be larger.</p>
164 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>ticks </b>- An <a href="../../Math/Integer.html"><span class="s7">Integer</span></a> &gt;= 0.</p>
165 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
166 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
167 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w = <span class="s8">Window</span>.new.front;</p>
168 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w.view.background = Color.black;</p>
169 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a = <span class="s8">SCLevelIndicator</span>(w, <span class="s8">Rect</span>(10, 10, 300, 30));</p>
170 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.numTicks = 11;</p>
171 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.numMajorTicks = 3;</p>
172 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.value = 0.5;</p>
173 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
174 <p class="p6"><br></p>
175 <p class="p6"><br></p>
176 <p class="p7"><b><span class="Apple-tab-span"> </span>drawsPeak_ (bool)</b></p>
177 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
178 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Determines whether the view draws a separate peak display. This can be useful for displaying both peak and RMS values. If <b>drawsPeak</b> is true <b>warning</b> and <b>critical </b>(see above) will be displayed based on <b>peakLevel </b>rather than <b>value</b> in styles 0 and 2.</p>
179 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>bool </b>- A <a href="../../Core/Boolean.html"><span class="s7">Boolean</span></a>. The default is false.</p>
180 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
181 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
182 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w = <span class="s9">Window</span>.new.front;</p>
183 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a = <span class="s9">SCLevelIndicator</span>(w, <span class="s9">Rect</span>(10, 10, 300, 30));</p>
184 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.drawsPeak = <span class="s9">true</span>;</p>
185 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.style = 1;</p>
186 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.value = 0.5;</p>
187 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.peakLevel = 0.6;</p>
188 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
189 <p class="p6"><br></p>
190 <p class="p6"><br></p>
191 <p class="p7"><b><span class="Apple-tab-span"> </span>peakLevel_ (val)</b></p>
192 <p class="p8"><b><span class="Apple-tab-span"> </span></b></p>
193 <p class="p7"><b><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></b>Sets the level of the peak display. (See <b>drawsPeak_</b>)</p>
194 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><b>val </b>- A <a href="../../Math/Float.html"><span class="s7">Float</span></a> between 0 and 1.</p>
195 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
196 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
197 <p class="p10"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>w = <span class="s9">Window</span>.new.front;</p>
198 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a = <span class="s9">SCLevelIndicator</span>(w, <span class="s9">Rect</span>(10, 10, 20, 160));</p>
199 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.drawsPeak = <span class="s9">true</span>;</p>
200 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.peakLevel = 0.6)</p>
201 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
202 <p class="p6"><br></p>
203 <p class="p6"><br></p>
204 <p class="p12"><b>Examples</b></p>
205 <p class="p3"><br></p>
206 <p class="p3"><br></p>
207 <p class="p11">s.boot;</p>
208 <p class="p3"><br></p>
209 <p class="p13">// something to meter</p>
210 <p class="p11">(</p>
211 <p class="p14"><span class="s3">b = </span><span class="s9">Buffer</span><span class="s3">.read(s, </span>"sounds/a11wlk01.wav"<span class="s3">);<span class="Apple-tab-span"> </span></span></p>
212 <p class="p11">x = { <span class="s9">var</span> colum, noise, imp, delimp, mul = 1;</p>
213 <p class="p11"><span class="Apple-tab-span"> </span>imp = <span class="s9">Impulse</span>.kr(10);</p>
214 <p class="p11"><span class="Apple-tab-span"> </span>delimp = <span class="s9">Delay1</span>.kr(imp);</p>
215 <p class="p11"><span class="Apple-tab-span"> </span>colum = <span class="s9">PlayBuf</span>.ar(1, b, <span class="s9">BufRateScale</span>.kr(b), loop: 1) * mul;</p>
216 <p class="p13"><span class="s3"><span class="Apple-tab-span"> </span></span>// measure rms and Peak</p>
217 <p class="p11"><span class="Apple-tab-span"> </span><span class="s9">SendReply</span>.kr(imp, <span class="s10">'/levels'</span>, [<span class="s9">Amplitude</span>.kr(colum), <span class="s9">K2A</span>.ar(<span class="s9">Peak</span>.ar(colum, delimp).lag(0, 3))]);</p>
218 <p class="p11"><span class="Apple-tab-span"> </span>colum;</p>
219 <p class="p11">}.play;</p>
220 <p class="p11">)</p>
221 <p class="p3"><br></p>
222 <p class="p13">// a window and responder</p>
223 <p class="p13">// default style is coloured / solid</p>
224 <p class="p11">(</p>
225 <p class="p11">w = <span class="s9">Window</span>.new.front;</p>
226 <p class="p11">a = <span class="s9">SCLevelIndicator</span>(w, <span class="s9">Rect</span>(10, 10, 20, 160));</p>
227 <p class="p11">o = <span class="s9">OSCresponder</span>(s.addr, <span class="s10">'/levels'</span>, {<span class="s9">arg</span> time, resp, msg;</p>
228 <p class="p11"><span class="Apple-tab-span"> </span>{</p>
229 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.value = msg[3].ampdb.linlin(-40, 0, 0, 1);</p>
230 <p class="p11"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.peakLevel = msg[4].ampdb.linlin(-40, 0, 0, 1);</p>
231 <p class="p11"><span class="Apple-tab-span"> </span>}.defer;</p>
232 <p class="p11">}).add;</p>
233 <p class="p11">w.onClose = {o.remove; x.free};</p>
234 <p class="p11">)</p>
235 <p class="p3"><br></p>
236 <p class="p13">// styles 0 and 2 support warning and critical levels</p>
237 <p class="p11">(</p>
238 <p class="p11">a.warning = -6.dbamp;</p>
239 <p class="p11">a.critical = -3.dbamp;</p>
240 <p class="p11">)</p>
241 <p class="p3"><br></p>
242 <p class="p13">// optionally show peak level</p>
243 <p class="p11">(</p>
244 <p class="p11">a.warning = 0;</p>
245 <p class="p11">a.critical = 0;</p>
246 <p class="p11">a.drawsPeak = <span class="s9">true</span>;</p>
247 <p class="p11">)</p>
248 <p class="p3"><br></p>
249 <p class="p13">// style 1 is black bars</p>
250 <p class="p11">a.style = 1</p>
251 <p class="p3"><br></p>
252 <p class="p13">// looks good with a background</p>
253 <p class="p11">a.background = <span class="s9">Gradient</span>(<span class="s9">Color</span>.red, <span class="s9">Color</span>.green, <span class="s10">\v</span>);</p>
254 <p class="p3"><br></p>
255 <p class="p13">// all styles can have ticks</p>
256 <p class="p11">(</p>
257 <p class="p11">a.background = <span class="s9">Color</span>.clear;</p>
258 <p class="p11">a.numTicks = 11; <span class="s11">// includes 0;</span></p>
259 <p class="p11">a.numMajorTicks = 3;<span class="Apple-tab-span"> </span></p>
260 <p class="p11">)</p>
261 <p class="p3"><br></p>
262 <p class="p13">// style 2 is LED</p>
263 <p class="p11">(</p>
264 <p class="p11">a.drawsPeak = <span class="s9">false</span>;</p>
265 <p class="p11">a.style = 2;</p>
266 <p class="p11">a.numSteps = 10;</p>
267 <p class="p11">a.numTicks = 0;</p>
268 <p class="p11">)</p>
269 <p class="p3"><br></p>
270 <p class="p13">// style 3 is as 2, but with images</p>
271 <p class="p13"><span class="s3">a.style = 3; </span>// use default image</p>
272 <p class="p3"><br></p>
273 <p class="p13">// make a custom image</p>
274 <p class="p11">(</p>
275 <p class="p11">j = <span class="s9">SCImage</span>.new(20,20);</p>
276 <p class="p11">j.draw({ <span class="s9">arg</span> image;</p>
277 <p class="p11"><span class="s9">var</span> lozenge;</p>
278 <p class="p11">lozenge = <span class="s9">Rect</span>(3, 3, 16, 16);</p>
279 <p class="p11"><span class="s9">Pen</span>.addOval(lozenge);</p>
280 <p class="p11"><span class="s9">Pen</span>.fillAxialGradient(1@1, 19@19, <span class="s9">Color</span>.new255(255, 165, 0), <span class="s9">Color</span>.new255(238, 232, 170));</p>
281 <p class="p11"><span class="s9">Pen</span>.width = 1;</p>
282 <p class="p11"><span class="s9">Pen</span>.strokeColor = <span class="s9">Color</span>.blue;</p>
283 <p class="p11"><span class="s9">Pen</span>.strokeOval(lozenge);</p>
284 <p class="p11">});</p>
285 <p class="p11">a.image = j;</p>
286 <p class="p11">)</p>
287 <p class="p3"><br></p>
288 <p class="p13">// be inspired</p>
289 <p class="p14"><span class="s3">j = </span><span class="s9">SCImage</span><span class="s3">.openURL(</span>"http://tinyurl.com/7lj55f"<span class="s3">);</span></p>
290 <p class="p3"><br></p>
291 <p class="p11">(</p>
292 <p class="p11">a.bounds = <span class="s9">Rect</span>(10, 10, 380, 80);</p>
293 <p class="p11">a.numSteps = 5;</p>
294 <p class="p11">a.image = j;</p>
295 <p class="p11">)</p>
296 <p class="p3"><br></p>
297 </body>
298 </html>