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.25">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 13.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: 9.0px Monaco
; min-height: 12.0px}
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 0.0px; font: 14.0px Helvetica
; min-height: 17.0px}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #cd1612}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #cd1612; min-height: 12.0px}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; min-height: 12.0px}
19 p
.p10
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica
}
20 p
.p11
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica
; min-height: 14.0px}
21 p
.p12
{margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica
}
22 p
.p13
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
}
23 p
.p14
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; color: #cd1612}
24 p
.p15
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica
; min-height: 17.0px}
25 p
.p16
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica
}
26 p
.p17
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 11.0px Monaco
}
27 p
.p18
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
28 p
.p19
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #00831b}
29 p
.p20
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #737373}
30 p
.p21
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #0b28c6}
31 span
.s1
{font: 18.0px Helvetica
}
32 span
.s2
{color: #1135f9}
33 span
.s3
{color: #0018b8}
34 span
.s4
{color: #000000}
35 span
.s5
{color: #0b28c6}
36 span
.s6
{color: #00831b}
37 span
.s7
{color: #737373}
38 span
.s8
{font: 12.0px Helvetica
}
39 span
.s9
{color: #0b28c5}
40 span
.Apple-tab-span
{white-space:pre
}
44 <p class=
"p1"><span class=
"s1"><b>ControlSpec
</b></span><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>numerical input specification
</b></p>
45 <p class=
"p2"><br></p>
46 <p class=
"p3"><b>Inherits from:
</b><a href=
"../Core/Object.html"><span class=
"s2"><b>Object
</b></span></a><b> :
</b><a href=
"Spec.html"><span class=
"s3"><b>Spec
</b></span></a></p>
47 <p class=
"p4"><br></p>
48 <p class=
"p3">The original, and most common spec (see
<a href=
"Spec.html"><span class=
"s3">Spec
</span></a> ). A ControlSpec is used by GUI sliders and knobs to specify the range and curve of the controls.
<span class=
"Apple-converted-space"> </span>ControlSpec may be used in many ways to map from linear
0.
.1 range to your desired range and back.
</p>
49 <p class=
"p2"><br></p>
50 <p class=
"p3"><b>See also:
</b> <a href=
"Warp.html"><span class=
"s2">Warp
</span></a>.
</p>
51 <p class=
"p4"><br></p>
52 <p class=
"p2"><br></p>
53 <p class=
"p5"><b>Creation / Class Methods
</b></p>
54 <p class=
"p6"><br></p>
55 <p class=
"p3"><span class=
"Apple-tab-span"> </span>The most common way to create a ControlSpec is by
<span class=
"Apple-converted-space"> </span></p>
56 <p class=
"p2"><br></p>
57 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span>anObject.asSpec
</span>// the object may be an array or a symbol
</p>
58 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
59 <p class=
"p9"><br></p>
60 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span>*new (minval, maxval, warp, step, default, units)
</b></p>
61 <p class=
"p11"><b><span class=
"Apple-tab-span"> </span></b></p>
62 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>minval
</b>- The minimum vlue of the range.
</p>
63 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>maxval
</b>- The maximium value of the range.
</p>
64 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>warp
</b>- a
<a href=
"Warp.html"><span class=
"s2">Warp
</span></a>, a symbol (e.g. \lin or \exponential: Default value is \lin), or something else
<span class=
"Apple-converted-space"> </span>that returns a Warp when sent the message .asWarp. A CurveWarp is defined by a number.
</p>
65 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>step
</b>- The smallest possible increment
</p>
66 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>default
</b>- The default value
</p>
67 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>units
</b>- The units, e.g.
"hz". Used by some gui's as a unit label.
</p>
68 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
69 <p class=
"p13"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>g =
<span class=
"s5">ControlSpec
</span>(
0.01,
2000,
<span class=
"s6">\exp
</span>,
0.1,
220,
<span class=
"s7">"Hz"</span>);
</p>
70 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
71 <p class=
"p14"><span class=
"s4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// or alternatively
</p>
72 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
73 <p class=
"p13"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>[
0.001,
2000,
<span class=
"s6">\exp
</span>,
0.1,
220,
<span class=
"s7">"hz"</span>].asSpec;
</p>
74 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
75 <p class=
"p14"><span class=
"s4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// or add it to the ControlSpec.specs IdentityDictionary:
</p>
76 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
77 <p class=
"p13"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s5">ControlSpec
</span>.specs[
<span class=
"s6">\myFreq
</span>] =
<span class=
"s5">ControlSpec
</span>(
0.01,
2000,
<span class=
"s6">\exp
</span>,
0.01,
440, units:
<span class=
"s7">"Hz"</span>);
</p>
78 <p class=
"p9"><br></p>
79 <p class=
"p15"><br></p>
80 <p class=
"p16"><b>Accessing Instance and Class Variables
</b></p>
81 <p class=
"p15"><br></p>
82 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span>map (value)
</b></p>
83 <p class=
"p11"><b><span class=
"Apple-tab-span"> </span></b></p>
84 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Maps and constrains a
<b>value
</b> between
0 and
1 to the range between minval and maxval.
</p>
85 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
86 <p class=
"p9"><br></p>
87 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span>unmap (value)
</b></p>
88 <p class=
"p11"><b><span class=
"Apple-tab-span"> </span></b></p>
89 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Maps and constrains a
<b>value
</b> between minval and maxval to the range between
0 and
1.
</p>
90 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
91 <p class=
"p13"><span class=
"s8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>g =
<span class=
"s5">ControlSpec
</span>(
0.01,
2000,
<span class=
"s6">\exp
</span>,
0.1,
220,
<span class=
"s7">"Hz"</span>);
</p>
92 <p class=
"p14"><span class=
"s4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>g.map(
0.5);
</span>// convert from [
0.
.1] to [
0.01.
.2000]
</p>
93 <p class=
"p14"><span class=
"s4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>g.unmap(
1000);
</span>// convert from [
0.01.
.2000] to [
0.
.1]
<span class=
"Apple-tab-span"> </span></p>
94 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
95 <p class=
"p14"><span class=
"s4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// fore and back translation should be close to identical:
</p>
96 <p class=
"p13"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>g.unmap(g.map(
0.5));
</p>
97 <p class=
"p11"><b><span class=
"Apple-tab-span"> </span></b></p>
98 <p class=
"p11"><b><span class=
"Apple-tab-span"> </span></b></p>
99 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span>minval
</b></p>
100 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span>minval_ (v)
</b></p>
101 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span>maxval
</b></p>
102 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span>maxval_ (v)
</b></p>
103 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span>warp_(arg1)
</b></p>
104 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span>warp
</b></p>
105 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span>step_(arg1)
</b></p>
106 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span>step
</b></p>
107 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span>default_(arg1)
</b></p>
108 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span>default
</b></p>
109 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span>units_(arg1)
</b></p>
110 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span>units
</b></p>
111 <p class=
"p11"><b><span class=
"Apple-tab-span"> </span></b><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></p>
112 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span>clipLo
</b></p>
113 <p class=
"p11"><b><span class=
"Apple-tab-span"> </span></b><span class=
"Apple-tab-span"> </span></p>
114 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>The lower of maxval and minval.
</p>
115 <p class=
"p11"><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>
116 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span>clipHi
</b></p>
117 <p class=
"p11"><b><span class=
"Apple-tab-span"> </span></b><span class=
"Apple-tab-span"> </span></p>
118 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>The higher of maxval and minval
</p>
119 <p class=
"p11"><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><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></p>
120 <p class=
"p9"><br></p>
121 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span>constrain (value)
</b></p>
122 <p class=
"p11"><b><span class=
"Apple-tab-span"> </span></b></p>
123 <p class=
"p17"><span class=
"s8"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Returns
<span class=
"Apple-converted-space"> </span></span> value.asFloat.clip(clipLo, clipHi).round(step)
<span class=
"s8">.
</span></p>
124 <p class=
"p9"><br></p>
125 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span>range
</b></p>
126 <p class=
"p11"><b><span class=
"Apple-tab-span"> </span></b></p>
127 <p class=
"p17"><span class=
"s8"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Returns
<span class=
"Apple-tab-span"> </span></span>maxval - minval
<span class=
"s8">.
</span></p>
128 <p class=
"p9"><br></p>
129 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span>ratio
</b></p>
130 <p class=
"p11"><b><span class=
"Apple-tab-span"> </span></b></p>
131 <p class=
"p17"><span class=
"s8"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Returns
<span class=
"Apple-tab-span"> </span></span>maxval / minval
<span class=
"s8">.
</span></p>
132 <p class=
"p9"><br></p>
133 <p class=
"p9"><br></p>
134 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span>guessNumberStep
</b></p>
135 <p class=
"p11"><b><span class=
"Apple-tab-span"> </span></b></p>
136 <p class=
"p10"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Used for EZ GUI classes for guessing a sensible
<b>step
</b> if none is specified.
</p>
137 <p class=
"p11"><span class=
"Apple-tab-span"> </span></p>
138 <p class=
"p11"><span class=
"Apple-tab-span"> </span></p>
139 <p class=
"p11"><span class=
"Apple-tab-span"> </span></p>
140 <p class=
"p11"><span class=
"Apple-tab-span"> </span></p>
141 <p class=
"p16"><b>Examples
</b></p>
142 <p class=
"p2"><br></p>
143 <p class=
"p7">// array is used as arguments to ControlSpec.new( minval, maxval, warp, step, default)
</p>
144 <p class=
"p18">[
300,
3000,
<span class=
"s6">\exponential
</span>,
100].asSpec.dump
</p>
145 <p class=
"p18"><span class=
"s5">Instance
</span> of
<span class=
"s5">ControlSpec
</span> {
<span class=
"Apple-converted-space"> </span>(
0313F
<span class=
"s5">C08
</span>, gc=
00, fmt=
00, flg=
00, set=
03)
</p>
146 <p class=
"p18"><span class=
"Apple-converted-space"> </span>instance variables [
6]
</p>
147 <p class=
"p18"><span class=
"Apple-converted-space"> </span>minval :
<span class=
"s5">Integer
</span> 300</p>
148 <p class=
"p18"><span class=
"Apple-converted-space"> </span>maxval :
<span class=
"s5">Integer
</span> 3000</p>
149 <p class=
"p19"><span class=
"s4"><span class=
"Apple-converted-space"> </span>warp :
</span><span class=
"s5">Symbol
</span><span class=
"s4"> </span>'exponential'
</p>
150 <p class=
"p18"><span class=
"Apple-converted-space"> </span>step :
<span class=
"s5">Integer
</span> 100</p>
151 <p class=
"p18"><span class=
"Apple-converted-space"> </span>default :
<span class=
"s5">Integer
</span> 300</p>
153 <p class=
"p4"><br></p>
154 <p class=
"p7">// partially specified ...
</p>
155 <p class=
"p18">[-
48,
48].asSpec.dump
</p>
156 <p class=
"p18"><span class=
"s5">Instance
</span> of
<span class=
"s5">ControlSpec
</span> {
<span class=
"Apple-converted-space"> </span>(
0313F
<span class=
"s5">F18
</span>, gc=
00, fmt=
00, flg=
00, set=
03)
</p>
157 <p class=
"p18"><span class=
"Apple-converted-space"> </span>instance variables [
6]
</p>
158 <p class=
"p18"><span class=
"Apple-converted-space"> </span>minval :
<span class=
"s5">Integer
</span> -
48</p>
159 <p class=
"p18"><span class=
"Apple-converted-space"> </span>maxval :
<span class=
"s5">Integer
</span> 48</p>
160 <p class=
"p18"><span class=
"Apple-converted-space"> </span>warp :
<span class=
"s5">Symbol
</span> <span class=
"s6">'linear'
</span></p>
161 <p class=
"p18"><span class=
"Apple-converted-space"> </span>step :
<span class=
"s5">Float
</span> 0</p>
162 <p class=
"p18"><span class=
"Apple-converted-space"> </span>default :
<span class=
"s5">Integer
</span> -
48</p>
164 <p class=
"p4"><br></p>
165 <p class=
"p7">// a Symbol
</p>
166 <p class=
"p18"><span class=
"s6">\freq
</span>.asSpec.dump
</p>
167 <p class=
"p18"><span class=
"s5">Instance
</span> of
<span class=
"s5">ControlSpec
</span> {
<span class=
"Apple-converted-space"> </span>(
180F4910, gc=
3C, fmt=
00, flg=
00, set=
03)
</p>
168 <p class=
"p18"><span class=
"Apple-converted-space"> </span>instance variables [
8]
</p>
169 <p class=
"p18"><span class=
"Apple-converted-space"> </span>minval :
<span class=
"s5">Integer
</span> 20</p>
170 <p class=
"p18"><span class=
"Apple-converted-space"> </span>maxval :
<span class=
"s5">Integer
</span> 20000</p>
171 <p class=
"p18"><span class=
"Apple-converted-space"> </span>warp : instance of
<span class=
"s5">ExponentialWarp
</span> (
17F
<span class=
"s5">EDB30
</span>, size=
1, set=
1)
</p>
172 <p class=
"p18"><span class=
"Apple-converted-space"> </span>step :
<span class=
"s5">Integer
</span> 0</p>
173 <p class=
"p18"><span class=
"Apple-converted-space"> </span>default :
<span class=
"s5">Integer
</span> 440</p>
174 <p class=
"p18"><span class=
"Apple-converted-space"> </span>units :
<span class=
"s7">" Hz"</span></p>
175 <p class=
"p18"><span class=
"Apple-converted-space"> </span>clipLo :
<span class=
"s5">Integer
</span> 20</p>
176 <p class=
"p18"><span class=
"Apple-converted-space"> </span>clipHi :
<span class=
"s5">Integer
</span> 20000</p>
178 <p class=
"p2"><br></p>
179 <p class=
"p4"><br></p>
180 <p class=
"p7">// nil becomes a default ControlSpec
</p>
181 <p class=
"p18"><span class=
"s5">nil
</span>.asSpec.dump
</p>
182 <p class=
"p18"><span class=
"s5">Instance
</span> of
<span class=
"s5">ControlSpec
</span> {
<span class=
"Apple-converted-space"> </span>(
0313F
<span class=
"s5">F18
</span>, gc=
00, fmt=
00, flg=
00, set=
03)
</p>
183 <p class=
"p18"><span class=
"Apple-converted-space"> </span>instance variables [
6]
</p>
184 <p class=
"p18"><span class=
"Apple-converted-space"> </span>minval :
<span class=
"s5">Float
</span> 0</p>
185 <p class=
"p18"><span class=
"Apple-converted-space"> </span>maxval :
<span class=
"s5">Float
</span> 1</p>
186 <p class=
"p18"><span class=
"Apple-converted-space"> </span>warp :
<span class=
"s5">Symbol
</span> <span class=
"s6">'linear'
</span></p>
187 <p class=
"p18"><span class=
"Apple-converted-space"> </span>step :
<span class=
"s5">Float
</span> 0</p>
188 <p class=
"p18"><span class=
"Apple-converted-space"> </span>default :
<span class=
"s5">Float
</span> 0</p>
190 <p class=
"p4"><br></p>
191 <p class=
"p4"><br></p>
192 <p class=
"p4"><br></p>
193 <p class=
"p4"><br></p>
194 <p class=
"p7">// make a frequency spec with an exponential range from
20 to
20000,
<span class=
"Apple-converted-space"> </span></p>
195 <p class=
"p7">// give it a rounding of
30 (Hz)
</p>
196 <p class=
"p18">a =
<span class=
"s6">\freq
</span>.asSpec;
</p>
197 <p class=
"p18">a.step =
100;
</p>
198 <p class=
"p4"><br></p>
199 <p class=
"p7">// equivalent:
</p>
200 <p class=
"p18">a = [
20,
20000,
<span class=
"s6">'exp'
</span>,
100,
440].asSpec;
</p>
201 <p class=
"p18">a.dump;
</p>
202 <p class=
"p4"><br></p>
203 <p class=
"p7"><span class=
"s4">a.constrain(
800);
</span>// make sure it is in range and round it.
</p>
204 <p class=
"p7"><span class=
"s4">a.constrain(
803);
</span>// make sure it is in range and round it.
<span class=
"Apple-tab-span"> </span></p>
205 <p class=
"p4"><br></p>
206 <p class=
"p18">a.map(
0.5);
</p>
207 <p class=
"p7"><span class=
"s4">a.map(
0.0);
</span>// returns min
</p>
208 <p class=
"p7"><span class=
"s4">a.map(
1.5);
</span>// exceeds the area: clip, returns max
</p>
209 <p class=
"p4"><br></p>
210 <p class=
"p18">a.unmap(
4000);
</p>
211 <p class=
"p18">a.unmap(
22.0);
</p>
212 <p class=
"p4"><br></p>
213 <p class=
"p7">// like in envelopes, a CurveWarp is created by a number:
<span class=
"Apple-tab-span"> </span></p>
214 <p class=
"p4"><br></p>
215 <p class=
"p18">a = [
0,
1, -
4].asSpec;
</p>
216 <p class=
"p18">a.map(
0.5);
</p>
217 <p class=
"p18">a.unmap(
0.99);
</p>
218 <p class=
"p18">a.map((
0.
.10).normalize).plot;
</p>
219 <p class=
"p4"><br></p>
220 <p class=
"p7">// look at different distributions:
</p>
222 <p class=
"p18"><span class=
"s9">var
</span> invals = (
0.
.10).normalize;
</p>
223 <p class=
"p18">(-
4.
.4).do {
<span class=
"s9">|curve|
</span></p>
224 <p class=
"p18"><span class=
"Apple-tab-span"> </span><span class=
"s9">var
</span> a = [
0,
1, curve].asSpec;
</p>
225 <p class=
"p18"><span class=
"Apple-tab-span"> </span>a.map(invals).plot;
</p>
227 <p class=
"p18">);
</p>
228 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
229 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
230 <p class=
"p7">// using spec for sliders:
</p>
232 <p class=
"p18"><span class=
"s5">var
</span> w, c, d;
</p>
233 <p class=
"p18">w =
<span class=
"s5">Window
</span>.new(
<span class=
"s7">"control"</span>,
<span class=
"s5">Rect
</span>(
128,
64,
340,
160));
</p>
234 <p class=
"p18">w.front;
</p>
235 <p class=
"p18">c =
<span class=
"s5">Slider
</span>.new(w,
<span class=
"s5">Rect
</span>(
10,
10,
300,
30));
</p>
236 <p class=
"p18">d =
<span class=
"s5">StaticText
</span>.new(w,
<span class=
"s5">Rect
</span>(
10,
40,
300,
30));
</p>
237 <p class=
"p18">c.action = {
</p>
238 <p class=
"p20"><span class=
"s4"><span class=
"Apple-tab-span"> </span>d.string =
</span>"unmapped value"</p>
239 <p class=
"p18"><span class=
"Apple-tab-span"> </span>+ c.value.round(
0.01)
<span class=
"Apple-converted-space"> </span></p>
240 <p class=
"p20"><span class=
"s4"><span class=
"Apple-tab-span"> </span>+
</span>"......"<span class=
"s4"><span class=
"Apple-converted-space"> </span></span></p>
241 <p class=
"p20"><span class=
"s4"><span class=
"Apple-tab-span"> </span>+
</span>"mapped value"<span class=
"s4"><span class=
"Apple-converted-space"> </span></span></p>
242 <p class=
"p18"><span class=
"Apple-tab-span"> </span>+ a.map(c.value)
</p>
243 <p class=
"p18">};
</p>
245 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
246 <p class=
"p7">// ControlSpec-map can also be used to map ugens
<span class=
"Apple-converted-space"> </span></p>
248 <p class=
"p18"><span class=
"s5">var
</span> spec;
</p>
249 <p class=
"p18">spec = [
100,
18000,
<span class=
"s6">\exp
</span>].asSpec;
</p>
251 <p class=
"p18"><span class=
"Apple-tab-span"> </span><span class=
"s5">var
</span> freq,osc;
</p>
252 <p class=
"p18"><span class=
"Apple-tab-span"> </span>osc =
<span class=
"s5">SinOsc
</span>.kr(
0.1).range(
0,
1);
</p>
253 <p class=
"p18"><span class=
"Apple-tab-span"> </span>freq = spec.map(
<span class=
"Apple-converted-space"> </span>osc );
</p>
254 <p class=
"p4"><span class=
"Apple-tab-span"> </span></p>
255 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span>freq.dump;
</span>// BinaryOpUGen
</p>
256 <p class=
"p4"><br></p>
257 <p class=
"p21"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>SinOsc
<span class=
"s4">.ar(
</span></p>
258 <p class=
"p18"><span class=
"Apple-tab-span"> </span><span class=
"Apple-converted-space"> </span>freq.poll
</p>
259 <p class=
"p18"><span class=
"Apple-tab-span"> </span>)
</p>
260 <p class=
"p18">}.play
</p>
261 <p class=
"p18">)
<span class=
"Apple-tab-span"> </span></p>
262 <p class=
"p4"><br></p>
263 <p class=
"p4"><br></p>
264 <p class=
"p4"><br></p>
265 <p class=
"p4"><br></p>
266 <p class=
"p4"><br></p>
267 <p class=
"p4"><br></p>
268 <p class=
"p4"><br></p>