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.35">
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: 14.0px Helvetica
}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #ad140d}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #606060}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #ad140d; min-height: 12.0px}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #cd1612}
19 p
.p10
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; color: #0000ee}
20 span
.s1
{font: 18.0px Helvetica
}
21 span
.s2
{color: #001bb9}
22 span
.s3
{text-decoration: underline
}
23 span
.s4
{color: #000000}
24 span
.s5
{color: #606060}
25 span
.s6
{font: 9.0px Monaco
}
26 span
.s7
{font: 12.0px Helvetica
}
27 span
.s8
{color: #ad140d}
28 span
.s9
{color: #1738f5}
29 span
.s10
{color: #1135f9}
30 span
.s11
{color: #0a25b9}
31 span
.s12
{color: #0b28c5}
32 span
.s13
{color: #0b28c6}
33 span
.s14
{font: 12.0px Helvetica
; color: #000000}
34 span
.Apple-tab-span
{white-space:pre
}
38 <p class=
"p1"><span class=
"s1"><b>SimpleNumber
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></span><b>one dimensional value
</b></p>
39 <p class=
"p2"><br></p>
40 <p class=
"p1"><b>superclass: Number
</b></p>
41 <p class=
"p2"><br></p>
42 <p class=
"p1">Represents numbers which can be represented by a single one dimensional value.
</p>
43 <p class=
"p2"><br></p>
44 <p class=
"p1">Most of the Unary and Binary operations are also implemented by
<a href=
"../UGens/Algebraic/UnaryOpUGen.html"><span class=
"s2">UnaryOpUGen
</span></a></p>
45 <p class=
"p1">and
<a href=
"../UGens/Algebraic/BinaryOpUGen.html"><span class=
"s2">BinaryOpUGen
</span></a>, so you can get more examples by looking at the help for those.
</p>
46 <p class=
"p2"><br></p>
47 <p class=
"p2"><br></p>
48 <p class=
"p3"><b>Unary Operations
</b></p>
49 <p class=
"p2"><br></p>
50 <p class=
"p1"><b>neg
</b></p>
51 <p class=
"p2"><br></p>
52 <p class=
"p1">negation
</p>
53 <p class=
"p2"><br></p>
54 <p class=
"p1"><b>bitNot
</b></p>
55 <p class=
"p2"><br></p>
56 <p class=
"p1">ones complement
</p>
57 <p class=
"p2"><br></p>
58 <p class=
"p1"><b>abs
</b></p>
59 <p class=
"p2"><br></p>
60 <p class=
"p1">absolute value.
</p>
61 <p class=
"p2"><br></p>
62 <p class=
"p1"><b>ceil
</b></p>
63 <p class=
"p2"><br></p>
64 <p class=
"p1">next larger integer.
</p>
65 <p class=
"p2"><br></p>
66 <p class=
"p1"><b>floor
</b></p>
67 <p class=
"p2"><br></p>
68 <p class=
"p1">next smaller integer
</p>
69 <p class=
"p2"><br></p>
70 <p class=
"p1"><b>frac
</b></p>
71 <p class=
"p2"><br></p>
72 <p class=
"p1">fractional part.
</p>
73 <p class=
"p2"><br></p>
74 <p class=
"p1"><b>sign
</b></p>
75 <p class=
"p2"><br></p>
76 <p class=
"p1">Answer -
1 if negative, +
1 if positive or
0 if zero.
</p>
77 <p class=
"p2"><br></p>
78 <p class=
"p1"><b>squared
</b></p>
79 <p class=
"p2"><br></p>
80 <p class=
"p1">The square of the number.
</p>
81 <p class=
"p2"><br></p>
82 <p class=
"p1"><b>cubed
</b></p>
83 <p class=
"p2"><br></p>
84 <p class=
"p1">The cube of the number.
</p>
85 <p class=
"p2"><br></p>
86 <p class=
"p1"><b>sqrt
</b></p>
87 <p class=
"p2"><br></p>
88 <p class=
"p1">The square root of the number.
</p>
89 <p class=
"p2"><br></p>
90 <p class=
"p1"><b>exp
</b></p>
91 <p class=
"p2"><br></p>
92 <p class=
"p1">e to the power of the receiver.
</p>
93 <p class=
"p2"><br></p>
94 <p class=
"p1"><b>reciprocal
</b></p>
95 <p class=
"p2"><br></p>
96 <p class=
"p1">1 / this
</p>
97 <p class=
"p2"><br></p>
98 <p class=
"p1"><b>midicps
</b></p>
99 <p class=
"p2"><br></p>
100 <p class=
"p1">Convert MIDI note to cycles per second
</p>
101 <p class=
"p2"><br></p>
102 <p class=
"p1"><b>cpsmidi
</b></p>
103 <p class=
"p2"><br></p>
104 <p class=
"p1">Convert cycles per second to MIDI note.
</p>
105 <p class=
"p2"><br></p>
106 <p class=
"p1"><b>midiratio
</b></p>
107 <p class=
"p2"><br></p>
108 <p class=
"p1">Convert an interval in semitones to a ratio.
</p>
109 <p class=
"p2"><br></p>
110 <p class=
"p1"><b>ratiomidi
</b></p>
111 <p class=
"p2"><br></p>
112 <p class=
"p1">Convert a ratio to an interval in semitones.
</p>
113 <p class=
"p2"><br></p>
114 <p class=
"p1"><b>ampdb
</b></p>
115 <p class=
"p2"><br></p>
116 <p class=
"p1">Convert a linear amplitude to decibels.
</p>
117 <p class=
"p2"><br></p>
118 <p class=
"p1"><b>dbamp
</b></p>
119 <p class=
"p2"><br></p>
120 <p class=
"p1">Convert a decibels to a linear amplitude.
</p>
121 <p class=
"p2"><br></p>
122 <p class=
"p1"><b>octcps
</b></p>
123 <p class=
"p2"><br></p>
124 <p class=
"p1">Convert decimal octaves to cycles per second.
</p>
125 <p class=
"p2"><br></p>
126 <p class=
"p1"><b>cpsoct
</b></p>
127 <p class=
"p2"><br></p>
128 <p class=
"p1">Convert cycles per second to decimal octaves.
</p>
129 <p class=
"p2"><br></p>
130 <p class=
"p1"><b>log
</b></p>
131 <p class=
"p2"><br></p>
132 <p class=
"p1">Base e logarithm.
</p>
133 <p class=
"p2"><br></p>
134 <p class=
"p1"><b>log2
</b></p>
135 <p class=
"p2"><br></p>
136 <p class=
"p1">Base
2 logarithm.
</p>
137 <p class=
"p2"><br></p>
138 <p class=
"p1"><b>log10
</b></p>
139 <p class=
"p2"><br></p>
140 <p class=
"p1">Base
10 logarithm.
</p>
141 <p class=
"p2"><br></p>
142 <p class=
"p1"><b>sin
</b></p>
143 <p class=
"p2"><br></p>
144 <p class=
"p1">Sine.
</p>
145 <p class=
"p2"><br></p>
146 <p class=
"p1"><b>cos
</b></p>
147 <p class=
"p2"><br></p>
148 <p class=
"p1">Cosine.
</p>
149 <p class=
"p2"><br></p>
150 <p class=
"p1"><b>tan
</b></p>
151 <p class=
"p2"><br></p>
152 <p class=
"p1">Tangent.
</p>
153 <p class=
"p2"><br></p>
154 <p class=
"p1"><b>asin
</b></p>
155 <p class=
"p2"><br></p>
156 <p class=
"p1">Arcsine.
</p>
157 <p class=
"p2"><br></p>
158 <p class=
"p1"><b>acos
</b></p>
159 <p class=
"p2"><br></p>
160 <p class=
"p1">Arccosine.
</p>
161 <p class=
"p2"><br></p>
162 <p class=
"p1"><b>atan
</b></p>
163 <p class=
"p2"><br></p>
164 <p class=
"p1">Arctangent.
</p>
165 <p class=
"p2"><br></p>
166 <p class=
"p1"><b>sinh
</b></p>
167 <p class=
"p2"><br></p>
168 <p class=
"p1">Hyperbolic sine.
</p>
169 <p class=
"p2"><br></p>
170 <p class=
"p1"><b>cosh
</b></p>
171 <p class=
"p2"><br></p>
172 <p class=
"p1">Hyperbolic cosine.
</p>
173 <p class=
"p2"><br></p>
174 <p class=
"p1"><b>tanh
</b></p>
175 <p class=
"p2"><br></p>
176 <p class=
"p1">Hyperbolic tangent.
</p>
177 <p class=
"p2"><br></p>
178 <p class=
"p1"><b>rand
</b></p>
179 <p class=
"p2"><br></p>
180 <p class=
"p1">Random number from zero up to the receiver, exclusive.
</p>
181 <p class=
"p2"><br></p>
182 <p class=
"p1"><b>rand2
</b></p>
183 <p class=
"p2"><br></p>
184 <p class=
"p1">Random number from -this to +this.
</p>
185 <p class=
"p2"><br></p>
186 <p class=
"p1"><b>linrand
</b></p>
187 <p class=
"p2"><br></p>
188 <p class=
"p1">Linearly distributed random number from zero to this.
</p>
189 <p class=
"p2"><br></p>
190 <p class=
"p1"><b>bilinrand
</b></p>
191 <p class=
"p2"><br></p>
192 <p class=
"p1">Bilateral linearly distributed random number from -this to +this.
</p>
193 <p class=
"p2"><br></p>
194 <p class=
"p1"><b>sum3rand
</b></p>
195 <p class=
"p2"><br></p>
196 <p class=
"p1">A random number
<span class=
"Apple-converted-space"> </span>from -this to +this that is the result of summing three uniform random generators
</p>
197 <p class=
"p1">to yield a bell-like distribution. This was suggested by Larry Polansky as a poor man's gaussian.
</p>
198 <p class=
"p2"><br></p>
199 <p class=
"p1"><b>distort
</b></p>
200 <p class=
"p2"><br></p>
201 <p class=
"p1">a nonlinear distortion function.
</p>
202 <p class=
"p2"><br></p>
203 <p class=
"p1"><b>softclip
</b></p>
204 <p class=
"p2"><br></p>
205 <p class=
"p1">Distortion with a perfectly linear region from -
0.5 to +
0.5</p>
206 <p class=
"p2"><br></p>
207 <p class=
"p1"><b>scurve
</b></p>
208 <p class=
"p2"><br></p>
209 <p class=
"p1">Map receiver in the onto an S-curve.
</p>
210 <p class=
"p2"><br></p>
211 <p class=
"p4">((
0.
.100) /
100 ).collect(_.scurve).plot
</p>
212 <p class=
"p5"><br></p>
213 <p class=
"p1"><b>ramp
</b></p>
214 <p class=
"p2"><br></p>
215 <p class=
"p1">Map receiver onto a ramp starting at
0.
</p>
216 <p class=
"p2"><br></p>
217 <p class=
"p4">((-
100.
.100) /
100 ).collect(_.ramp).plot
</p>
218 <p class=
"p2"><br></p>
219 <p class=
"p1"><b>coin
</b></p>
220 <p class=
"p2"><br></p>
221 <p class=
"p1">Answers a Boolean which is the result of a random test whose probability of success in a range from
<span class=
"Apple-converted-space"> </span></p>
222 <p class=
"p1">zero to one is
<span class=
"s3">this
</span>.
</p>
223 <p class=
"p2"><br></p>
224 <p class=
"p1"><b>even
</b></p>
225 <p class=
"p2"><br></p>
226 <p class=
"p1">Answer if the number is even.
</p>
227 <p class=
"p2"><br></p>
228 <p class=
"p1"><b>odd
</b></p>
229 <p class=
"p2"><br></p>
230 <p class=
"p1">Answer if the number is odd.
</p>
231 <p class=
"p2"><br></p>
232 <p class=
"p1"><b>isPositive
</b></p>
233 <p class=
"p2"><br></p>
234 <p class=
"p1">Answer if the number is
>=
0.
</p>
235 <p class=
"p2"><br></p>
236 <p class=
"p1"><b>isNegative
</b></p>
237 <p class=
"p2"><br></p>
238 <p class=
"p1">Answer if the number is
< 0.
</p>
239 <p class=
"p2"><br></p>
240 <p class=
"p1"><b>isStrictlyPositive
</b></p>
241 <p class=
"p2"><br></p>
242 <p class=
"p1">Answer if the number is
> 0.
</p>
243 <p class=
"p2"><br></p>
244 <p class=
"p1"><b>booleanValue
</b></p>
245 <p class=
"p2"><br></p>
246 <p class=
"p1">return true, if strictly positive (
> 0), otherwise false (see
<a href=
"../Core/Boolean.html"><span class=
"s2">Boolean
</span></a>)
</p>
247 <p class=
"p2"><br></p>
248 <p class=
"p1"><b>isValidUGenInput
</b></p>
249 <p class=
"p2"><br></p>
250 <p class=
"p1">return false if receiver cannot be used in UGen.
</p>
251 <p class=
"p2"><br></p>
252 <p class=
"p1"><b>magnitude
</b></p>
253 <p class=
"p2"><br></p>
254 <p class=
"p1">returns abolute value (see
<a href=
"Polar.html"><span class=
"s2">Polar
</span></a>,
<a href=
"Complex.html"><span class=
"s2">Complex
</span></a>)
</p>
255 <p class=
"p2"><br></p>
256 <p class=
"p1"><b>angle
</b></p>
257 <p class=
"p2"><br></p>
258 <p class=
"p1">returns angle of receiver conceived as
<a href=
"Polar.html"><span class=
"s2">Polar
</span></a> or
<a href=
"Complex.html"><span class=
"s2">Complex
</span></a><span class=
"s2"> </span>number.
</p>
259 <p class=
"p2"><br></p>
260 <p class=
"p1"><b>wait
</b></p>
261 <p class=
"p1"><span class=
"Apple-tab-span"> </span>within a routine, yield the number so that the clock can wait for this many beats.
</p>
262 <p class=
"p1"><span class=
"Apple-tab-span"> </span>(see
<a href=
"../Core/Kernel/Routine.html"><span class=
"s2">Routine
</span></a>)
</p>
263 <p class=
"p2"><span class=
"Apple-tab-span"> </span></p>
264 <p class=
"p6"><span class=
"s4"><span class=
"Apple-tab-span"> </span></span>// create a routine by a function fork
</p>
265 <p class=
"p4"><span class=
"Apple-tab-span"> </span>(
</p>
266 <p class=
"p4"><span class=
"Apple-tab-span"> </span>fork {
</p>
267 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>1.wait;
</p>
268 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>"I did wait"<span class=
"s4">.postln;
</span></p>
269 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>1.0.rand.wait;
</p>
270 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>"No you didn't"<span class=
"s4">.postln;
</span></p>
271 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>2.wait;
</p>
272 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(
1..).do {
<span class=
"s2">|i|
</span><span class=
"Apple-converted-space"> </span></p>
273 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s5">"yes I did"</span>.postln;
<span class=
"Apple-converted-space"> </span></p>
274 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>i.asFloat.rand.wait;
<span class=
"Apple-converted-space"> </span></p>
275 <p class=
"p7"><span class=
"s4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>"no you didn't"<span class=
"s4">.postln;
<span class=
"Apple-converted-space"> </span></span></p>
276 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>i.wait
<span class=
"Apple-converted-space"> </span></p>
277 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>}
</p>
278 <p class=
"p4"><span class=
"Apple-tab-span"> </span>}
</p>
279 <p class=
"p4"><span class=
"Apple-tab-span"> </span>)
</p>
280 <p class=
"p5"><br></p>
281 <p class=
"p1"><b>waitUntil
</b></p>
282 <p class=
"p1"><span class=
"Apple-tab-span"> </span>like wait, only specify a time (measured in beats of the current thread's clock)
</p>
283 <p class=
"p1"><span class=
"Apple-tab-span"> </span>(see
<a href=
"../Core/Kernel/Routine.html"><span class=
"s2">Routine
</span></a>)
</p>
284 <p class=
"p2"><br></p>
285 <p class=
"p1"><b>sleep
</b></p>
286 <p class=
"p1"><span class=
"Apple-tab-span"> </span>make the current thread sleep, until woken up by re-scheduling. (see
<a href=
"../Core/Kernel/Routine.html"><span class=
"s2">Routine
</span></a>)
</p>
287 <p class=
"p2"><span class=
"Apple-tab-span"> </span><span class=
"s6"><span class=
"Apple-tab-span"> </span></span></p>
288 <p class=
"p2"><br></p>
289 <p class=
"p3"><b>Binary Operations
</b></p>
290 <p class=
"p2"><br></p>
291 <p class=
"p1"><b>+ aNumber
</b></p>
292 <p class=
"p2"><br></p>
293 <p class=
"p1">Addition
</p>
294 <p class=
"p2"><br></p>
295 <p class=
"p1"><b>- aNumber
</b></p>
296 <p class=
"p2"><br></p>
297 <p class=
"p1">Subtraction
</p>
298 <p class=
"p2"><br></p>
299 <p class=
"p1"><b>* aNumber
</b></p>
300 <p class=
"p2"><br></p>
301 <p class=
"p1">Multiplication
</p>
302 <p class=
"p2"><br></p>
303 <p class=
"p1"><b>/ aNumber
</b></p>
304 <p class=
"p2"><br></p>
305 <p class=
"p1">Division
</p>
306 <p class=
"p2"><br></p>
307 <p class=
"p1"><b>% aNumber
</b></p>
308 <p class=
"p2"><br></p>
309 <p class=
"p1">Modulo
</p>
310 <p class=
"p2"><br></p>
311 <p class=
"p1"><b>div(aNumber)
</b></p>
312 <p class=
"p2"><br></p>
313 <p class=
"p1">Integer Division
</p>
314 <p class=
"p2"><br></p>
315 <p class=
"p1"><b>** aNumber
</b></p>
316 <p class=
"p2"><br></p>
317 <p class=
"p1">Exponentiation
</p>
318 <p class=
"p2"><br></p>
319 <p class=
"p1"><b>min(aNumber)
</b></p>
320 <p class=
"p2"><br></p>
321 <p class=
"p1">Minimum
</p>
322 <p class=
"p2"><br></p>
323 <p class=
"p1"><b>max(aNumber)
</b></p>
324 <p class=
"p2"><br></p>
325 <p class=
"p1">Maximum
</p>
326 <p class=
"p2"><br></p>
327 <p class=
"p1"><b>& aNumber
</b></p>
328 <p class=
"p2"><br></p>
329 <p class=
"p1">Bitwise And
</p>
330 <p class=
"p2"><br></p>
331 <p class=
"p1"><b>| aNumber
</b></p>
332 <p class=
"p2"><br></p>
333 <p class=
"p1">Bitwise Or
</p>
334 <p class=
"p2"><br></p>
335 <p class=
"p1"><b>bitXor(aNumber)
</b></p>
336 <p class=
"p2"><br></p>
337 <p class=
"p1">Bitwise Exclusive Or
</p>
338 <p class=
"p2"><br></p>
339 <p class=
"p1"><b>bitHammingDistance(aNumber)
</b></p>
340 <p class=
"p2"><br></p>
341 <p class=
"p1">Binary Hamming distance, or the count of bits that are not the same in the two numbers
</p>
342 <p class=
"p2"><br></p>
343 <p class=
"p1"><b>bitTest(aNumber)
</b></p>
344 <p class=
"p2"><br></p>
345 <p class=
"p1">Returns true if bit at index aNumber is set.
</p>
346 <p class=
"p2"><br></p>
347 <p class=
"p1"><b>lcm(aNumber)
</b></p>
348 <p class=
"p2"><br></p>
349 <p class=
"p1">Least common multiple
</p>
350 <p class=
"p2"><br></p>
351 <p class=
"p1"><b>gcd(aNumber)
</b></p>
352 <p class=
"p2"><br></p>
353 <p class=
"p1">Greatest common divisor
</p>
354 <p class=
"p2"><br></p>
355 <p class=
"p1"><b>round(aNumber)
</b></p>
356 <p class=
"p2"><br></p>
357 <p class=
"p1">Round to multiple of aNumber
</p>
358 <p class=
"p2"><br></p>
359 <p class=
"p1"><b>trunc(aNumber)
</b></p>
360 <p class=
"p2"><br></p>
361 <p class=
"p1">Truncate to multiple of aNumber
</p>
362 <p class=
"p2"><br></p>
363 <p class=
"p1"><b>atan2(aNumber)
</b></p>
364 <p class=
"p2"><br></p>
365 <p class=
"p1">Arctangent of (this/aNumber)
</p>
366 <p class=
"p2"><br></p>
367 <p class=
"p1"><b>hypot(aNumber)
</b></p>
368 <p class=
"p2"><br></p>
369 <p class=
"p1">Square root of the sum of the squares.
</p>
370 <p class=
"p2"><br></p>
371 <p class=
"p1"><b><< aNumber
</b></p>
372 <p class=
"p2"><br></p>
373 <p class=
"p1">Binary shift left.
</p>
374 <p class=
"p2"><br></p>
375 <p class=
"p1"><b>>> aNumber
</b></p>
376 <p class=
"p2"><br></p>
377 <p class=
"p1">Binary shift right.
</p>
378 <p class=
"p2"><br></p>
379 <p class=
"p1"><b>+
>> aNumber
</b></p>
380 <p class=
"p2"><br></p>
381 <p class=
"p1">Unsigned binary shift right.
</p>
382 <p class=
"p2"><br></p>
383 <p class=
"p1"><b>fill(aNumber)
</b></p>
384 <p class=
"p2"><br></p>
385 <p class=
"p1"><b>ring1(aNumber)
</b></p>
386 <p class=
"p2"><br></p>
387 <p class=
"p1">(a * b) + a
</p>
388 <p class=
"p2"><br></p>
389 <p class=
"p1"><b>ring2(aNumber)
</b></p>
390 <p class=
"p2"><br></p>
391 <p class=
"p1">((a*b) + a + b)
</p>
392 <p class=
"p2"><br></p>
393 <p class=
"p1"><b>ring3(aNumber)
</b></p>
394 <p class=
"p2"><br></p>
395 <p class=
"p1">(a*a *b)
</p>
396 <p class=
"p2"><br></p>
397 <p class=
"p1"><b>ring4(aNumber)
</b></p>
398 <p class=
"p2"><br></p>
399 <p class=
"p1">((a*a *b) - (a*b*b))
</p>
400 <p class=
"p2"><br></p>
401 <p class=
"p1"><b>difsqr(aNumber)
</b></p>
402 <p class=
"p2"><br></p>
403 <p class=
"p1">(a*a) - (b*b)
</p>
404 <p class=
"p2"><br></p>
405 <p class=
"p1"><b>sumsqr(aNumber)
</b></p>
406 <p class=
"p2"><br></p>
407 <p class=
"p1">(a*a) + (b*b)
</p>
408 <p class=
"p2"><br></p>
409 <p class=
"p1"><b>sqrdif(aNumber)
</b></p>
410 <p class=
"p2"><br></p>
411 <p class=
"p1">(a - b)**
2</p>
412 <p class=
"p2"><br></p>
413 <p class=
"p1"><b>sqrsum(aNumber)
</b></p>
414 <p class=
"p2"><br></p>
415 <p class=
"p1">(a + b)**
2</p>
416 <p class=
"p2"><br></p>
417 <p class=
"p1"><b>absdif(aNumber)
</b></p>
418 <p class=
"p2"><br></p>
419 <p class=
"p1">(a - b).abs
</p>
420 <p class=
"p2"><br></p>
421 <p class=
"p1"><b>amclip(aNumber)
</b></p>
422 <p class=
"p2"><br></p>
423 <p class=
"p1">0<span class=
"Apple-converted-space"> </span>when
<span class=
"Apple-converted-space"> </span>b
<=
0,
<span class=
"Apple-converted-space"> </span>a*b
<span class=
"Apple-converted-space"> </span>when
<span class=
"Apple-converted-space"> </span>b
> 0</p>
424 <p class=
"p2"><br></p>
425 <p class=
"p1"><b>scaleneg(aNumber)
</b></p>
426 <p class=
"p2"><br></p>
427 <p class=
"p1">a*b when a
< 0, otherwise a.
</p>
428 <p class=
"p2"><br></p>
429 <p class=
"p1"><b>clip2(aNumber)
</b></p>
430 <p class=
"p2"><br></p>
431 <p class=
"p1">clips receiver to +/- aNumber
</p>
432 <p class=
"p2"><br></p>
433 <p class=
"p1"><b>excess(aNumber)
</b></p>
434 <p class=
"p2"><br></p>
435 <p class=
"p1">Returns the difference of the receiver and its clipped form: (a - clip2(a,b)).
</p>
436 <p class=
"p2"><br></p>
437 <p class=
"p1"><b><! aNumber
</b></p>
438 <p class=
"p2"><br></p>
439 <p class=
"p1">Return the receiver. aNumber is ignored.
</p>
440 <p class=
"p2"><br></p>
441 <p class=
"p1"><b>asFraction(denominator, fasterBetter)
</b></p>
442 <p class=
"p2"><br></p>
443 <p class=
"p1">Return an array of denominator and divisor of the nearest and smallest fraction
</p>
444 <p class=
"p2"><br></p>
445 <p class=
"p1"><b>rrand(aNumber)
</b></p>
446 <p class=
"p2"><br></p>
447 <p class=
"p1">Returns a random number in the interval ]a, b[. If both a and b are Integer then the result will be an Integer.
</p>
448 <p class=
"p2"><br></p>
449 <p class=
"p1"><b>exprand(aNumber)
</b></p>
450 <p class=
"p2"><br></p>
451 <p class=
"p1">Returns an exponentially distributed random number in the interval ]a, b[. Always returns a Float.
</p>
452 <p class=
"p2"><br></p>
453 <p class=
"p1"><b>gauss(standardDeviation)
</b></p>
454 <p class=
"p2"><br></p>
455 <p class=
"p1">Returns a gaussian distributed random number. Always returns a Float.
</p>
456 <p class=
"p2"><span class=
"Apple-tab-span"> </span></p>
457 <p class=
"p4">(
0.
.1000).collect { |num| gauss(
0.0, num) }.plot;
</p>
458 <p class=
"p2"><br></p>
459 <p class=
"p2"><br></p>
460 <p class=
"p1"><b>nextTimeOnGrid(clock)
</b></p>
461 <p class=
"p2"><br></p>
462 <p class=
"p1">Return the next possible multiple of the clock's beats.
</p>
463 <p class=
"p2"><br></p>
464 <p class=
"p2"><br></p>
465 <p class=
"p2"><br></p>
466 <p class=
"p3"><b>N-ary Operations
</b></p>
467 <p class=
"p2"><br></p>
468 <p class=
"p2"><br></p>
469 <p class=
"p1"><b>degreeToKey(scale, stepsPerOctave)
</b></p>
470 <p class=
"p2"><br></p>
471 <p class=
"p1"><span class=
"Apple-tab-span"> </span>the value is truncated to an integer and used as an index into an octave repeating table of note values.
</p>
472 <p class=
"p1"><span class=
"Apple-tab-span"> </span>Indices wrap around the table and shift octaves as they do
</p>
473 <p class=
"p1"><span class=
"Apple-tab-span"> </span>stepsPerOctave is
12 by default
</p>
474 <p class=
"p2"><span class=
"Apple-tab-span"> </span></p>
475 <p class=
"p4"><span class=
"s7"><span class=
"Apple-tab-span"> </span></span>(
</p>
476 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>l = [
0,
1,
5,
9,
11];
<span class=
"s8">// pentatonic scale
</span></p>
477 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(
1,
2.
.15).collect {
<span class=
"s2">|i|
</span> i.degreeToKey(l,
12) }
</p>
478 <p class=
"p4"><span class=
"Apple-tab-span"> </span>)
</p>
479 <p class=
"p2"><br></p>
480 <p class=
"p2"><br></p>
481 <p class=
"p1"><b>keyToDegree(scale, stepsPerOctave)
</b></p>
482 <p class=
"p2"><br></p>
483 <p class=
"p1"><span class=
"Apple-tab-span"> </span>inverse of degreeToKey.
</p>
484 <p class=
"p1"><span class=
"Apple-tab-span"> </span>stepsPerOctave is
12 by default
</p>
485 <p class=
"p2"><span class=
"Apple-tab-span"> </span></p>
486 <p class=
"p4"><span class=
"s7"><span class=
"Apple-tab-span"> </span></span>(
</p>
487 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>l = [
0,
1,
5,
9,
11];
<span class=
"s8">// pentatonic scale
</span></p>
488 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(
60,
61.
.75).collect {
<span class=
"s2">|i|
</span> i.keyToDegree(l,
12) }
</p>
489 <p class=
"p4"><span class=
"Apple-tab-span"> </span>)
</p>
490 <p class=
"p4"><span class=
"Apple-tab-span"> </span>(
</p>
491 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>l = [
0,
1,
5,
9,
11];
<span class=
"s8">// pentatonic scale
</span></p>
492 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(
60,
61.
.75).postln.collect {
<span class=
"s2">|i|
</span> i.keyToDegree(l,
12).degreeToKey(l) }
</p>
493 <p class=
"p4"><span class=
"Apple-tab-span"> </span>)
</p>
494 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
495 <p class=
"p1"><b>nearestInList(list)
</b></p>
496 <p class=
"p2"><br></p>
497 <p class=
"p1"><span class=
"Apple-tab-span"> </span>returns the value in the collection closest to this
</p>
498 <p class=
"p2"><span class=
"Apple-tab-span"> </span></p>
499 <p class=
"p4"><span class=
"s7"><span class=
"Apple-tab-span"> </span></span>(
</p>
500 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>l = [
0,
0.5,
0.9,
1];
</p>
501 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(
0,
0.05.
.1).collect { |i| i.nearestInList(l) }
</p>
502 <p class=
"p4"><span class=
"Apple-tab-span"> </span>)
</p>
503 <p class=
"p2"><br></p>
504 <p class=
"p2"><br></p>
505 <p class=
"p1"><b>nearestInScale(scale, stepsPerOctave)
</b></p>
506 <p class=
"p2"><br></p>
507 <p class=
"p1"><span class=
"Apple-tab-span"> </span>returns the value in the collection closest to this, assuming an octave repeating table of note values.
</p>
508 <p class=
"p1"><span class=
"Apple-tab-span"> </span>stepsPerOctave is
12 by default
</p>
509 <p class=
"p2"><span class=
"Apple-tab-span"> </span></p>
510 <p class=
"p4"><span class=
"s7"><span class=
"Apple-tab-span"> </span></span>(
</p>
511 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>l = [
0,
1,
5,
9,
11];
<span class=
"s8">// pentatonic scale
</span></p>
512 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(
60,
61.
.76).collect { |i| i.nearestInScale(l,
12) }
</p>
513 <p class=
"p4"><span class=
"Apple-tab-span"> </span>)
</p>
514 <p class=
"p2"><span class=
"Apple-tab-span"> </span></p>
515 <p class=
"p1"><b>partition(parts, min)
</b></p>
516 <p class=
"p2"><br></p>
517 <p class=
"p1"><span class=
"Apple-tab-span"> </span>randomly partition a number into parts of at least min size.
</p>
518 <p class=
"p2"><br></p>
519 <p class=
"p4"><span class=
"s7"><span class=
"Apple-tab-span"> </span></span>75.partition(
8,
3);
</p>
520 <p class=
"p4"><span class=
"Apple-tab-span"> </span>75.partition(
75,
1);
</p>
521 <p class=
"p2"><br></p>
522 <p class=
"p2"><br></p>
523 <p class=
"p1"><b>asTimeString(precision, maxDays =
365, dropDaysIfPossible = true)
</b></p>
524 <p class=
"p2"><br></p>
525 <p class=
"p1"><span class=
"Apple-tab-span"> </span>returns a string corresponding to the days:hours:minutes:seconds
<span class=
"Apple-converted-space"> </span></p>
526 <p class=
"p1"><span class=
"Apple-tab-span"> </span>based on the receiver as number of seconds.
</p>
527 <p class=
"p1"><span class=
"Apple-tab-span"> </span><b>precision
</b> is
0.001 (ms) by default
</p>
528 <p class=
"p1"><span class=
"Apple-tab-span"> </span>this format is inspired by ISO
8601 time interval display (truncated representation)
</p>
529 <p class=
"p1"><span class=
"Apple-tab-span"> </span>returns string
"ddd:hh:mm:ss:ttt" where t is milliseconds
</p>
530 <p class=
"p1"><span class=
"Apple-tab-span"> </span>see
<a href=
"../Collections/String.html"><span class=
"s9">String
</span></a>:asSecs for complement
</p>
531 <p class=
"p2"><span class=
"Apple-tab-span"> </span></p>
532 <p class=
"p4"><span class=
"s7"><span class=
"Apple-tab-span"> </span></span>(
</p>
533 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">var
</span> start =
<span class=
"s2">Main
</span>.elapsedTime;
</p>
534 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>fork { loop { (
<span class=
"s2">Main
</span>.elapsedTime - start).asTimeString.postln;
0.05.wait } };
</p>
535 <p class=
"p4"><span class=
"Apple-tab-span"> </span>)
</p>
536 <p class=
"p5"><br></p>
537 <p class=
"p1"><b>equalWithPrecision(that, precision)
</b></p>
538 <p class=
"p2"><br></p>
539 <p class=
"p1"><span class=
"Apple-tab-span"> </span>return true if receiver is closer to
<b>that
</b> than
<b>precision
</b>. (default for precision:
0.0001)
</p>
540 <p class=
"p2"><span class=
"Apple-tab-span"> </span></p>
541 <p class=
"p4"><span class=
"s7"><span class=
"Apple-tab-span"> </span></span>3.1.equalWithPrecision(
3.0,
0.05);
<span class=
"s8">// false
</span></p>
542 <p class=
"p4"><span class=
"Apple-tab-span"> </span>3.1.equalWithPrecision(
3.0,
0.1);
<span class=
"s8">// false
</span></p>
543 <p class=
"p4"><span class=
"Apple-tab-span"> </span>3.1.equalWithPrecision(
3.0,
0.11);
<span class=
"s8">// true
</span></p>
544 <p class=
"p5"><br></p>
545 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
546 <p class=
"p1"><b>quantize(quantum, tolerance, strength)
</b></p>
547 <p class=
"p2"><b><span class=
"Apple-tab-span"> </span></b></p>
548 <p class=
"p1"><b><span class=
"Apple-tab-span"> </span></b>round the receiver to the
<b>quantum
</b> (default:
1.0) allowing for a
<b>tolerance
</b> (default:
0.05).
</p>
549 <p class=
"p1"><span class=
"Apple-tab-span"> </span>How much the value is allowed to differ in the tolerance range is determined by
<b>strength
</b> (default:
1.0).
</p>
550 <p class=
"p2"><br></p>
551 <p class=
"p4"><span class=
"Apple-tab-span"> </span>((
0.
.10) /
10).collect {
<span class=
"s2">|num|
</span> num.quantize(
1,
0.3,
0.5) }.postcs.plot;
</p>
552 <p class=
"p4"><span class=
"Apple-tab-span"> </span>((
0.
.10) /
10).collect {
<span class=
"s2">|num|
</span> num.quantize(
1,
0.6,
0.5) }.postcs.plot;
</p>
553 <p class=
"p4"><span class=
"Apple-tab-span"> </span>((
0.
.10) /
10).collect {
<span class=
"s2">|num|
</span> num.quantize(
1,
1.0,
0.5) }.postcs.plot;
</p>
554 <p class=
"p2"><br></p>
555 <p class=
"p2"><br></p>
556 <p class=
"p1"><b>linlin(inMin, inMax, outMin, outMax, clip)
</b></p>
557 <p class=
"p5"><br></p>
558 <p class=
"p1"><span class=
"s6"><span class=
"Apple-tab-span"> </span></span>map the receiver from an assumed linear input range (inMin..inMax)
</p>
559 <p class=
"p1"><span class=
"Apple-tab-span"> </span>to a linear output range (outMin..outMax). If the input exceeds the assumed input range.
<span class=
"Apple-converted-space"> </span></p>
560 <p class=
"p1"><span class=
"Apple-tab-span"> </span>If the input exceeds the input range, the following behaviours are specified by the
<b>clip
</b> argument:
<span class=
"Apple-converted-space"> </span></p>
561 <p class=
"p1"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>nil
</b> (don't clip),
<b>\max
</b> (clip ceiling),
<b>\min
</b>, (clip floor),
<b>\minmax
</b> (clip both - this is default).
</p>
562 <p class=
"p2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
563 <p class=
"p4"><span class=
"Apple-tab-span"> </span>(
0.
.10).collect {
<span class=
"s2">|num|
</span> num.linlin(
0,
10, -
4.3,
100) };
<span class=
"Apple-converted-space"> </span></p>
564 <p class=
"p4"><span class=
"Apple-tab-span"> </span>(
0.
.10).linlin(
0,
10, -
4.3,
100);
<span class=
"s8">// equivalent.
</span></p>
565 <p class=
"p5"><br></p>
566 <p class=
"p2"><br></p>
567 <p class=
"p1"><b>linexp(inMin, inMax, outMin, outMax, clip)
</b></p>
568 <p class=
"p5"><br></p>
569 <p class=
"p1"><span class=
"s6"><span class=
"Apple-tab-span"> </span></span>map the receiver from an assumed linear input range (inMin..inMax)
</p>
570 <p class=
"p1"><span class=
"Apple-tab-span"> </span>to an exponential output range (outMin..outMax).
</p>
571 <p class=
"p1"><span class=
"Apple-tab-span"> </span>The output range must not include zero.
<span class=
"Apple-converted-space"> </span></p>
572 <p class=
"p1"><span class=
"Apple-tab-span"> </span>If the input exceeds the input range, the following behaviours are specified by the
<b>clip
</b> argument:
<span class=
"Apple-converted-space"> </span></p>
573 <p class=
"p1"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>nil
</b> (don't clip),
<b>\max
</b> (clip ceiling),
<b>\min
</b>, (clip floor),
<b>\minmax
</b> (clip both - this is default).
</p>
574 <p class=
"p2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
575 <p class=
"p4"><span class=
"s7"><span class=
"Apple-tab-span"> </span></span>(
0.
.10).collect {
<span class=
"s2">|num|
</span> num.linexp(
0,
10,
4.3,
100) };
<span class=
"Apple-converted-space"> </span></p>
576 <p class=
"p4"><span class=
"Apple-tab-span"> </span>(
0.
.10).linexp(
0,
10,
4.3,
100);
<span class=
"s8">// equivalent.
</span></p>
577 <p class=
"p2"><b><span class=
"Apple-tab-span"> </span></b></p>
578 <p class=
"p1"><b>explin(inMin, inMax, outMin, outMax, clip)
</b></p>
579 <p class=
"p5"><br></p>
580 <p class=
"p1"><span class=
"s6"><span class=
"Apple-tab-span"> </span></span>map the receiver from an assumed exponential input range (inMin..inMax)
</p>
581 <p class=
"p1"><span class=
"Apple-tab-span"> </span>to a linear output range (outMin..outMax). If the input exceeds the assumed input range.
</p>
582 <p class=
"p1"><span class=
"Apple-tab-span"> </span>The input range must not include zero.
<span class=
"Apple-converted-space"> </span></p>
583 <p class=
"p1"><span class=
"Apple-tab-span"> </span>If the input exceeds the input range, the following behaviours are specified by the
<b>clip
</b> argument:
<span class=
"Apple-converted-space"> </span></p>
584 <p class=
"p1"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>nil
</b> (don't clip),
<b>\max
</b> (clip ceiling),
<b>\min
</b>, (clip floor),
<b>\minmax
</b> (clip both - this is default).
<span class=
"s6"><span class=
"Apple-tab-span"> </span></span></p>
585 <p class=
"p5"><br></p>
586 <p class=
"p4"><span class=
"Apple-tab-span"> </span>(
1.
.10).collect {
<span class=
"s2">|num|
</span> num.explin(
0.1,
10, -
4.3,
100) };
<span class=
"Apple-converted-space"> </span></p>
587 <p class=
"p4"><span class=
"Apple-tab-span"> </span>(
1.
.10).explin(
0.1,
10, -
4.3,
100);
<span class=
"s8">// equivalent.
</span></p>
588 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
589 <p class=
"p5"><br></p>
590 <p class=
"p1"><b>expexp(inMin, inMax, outMin, outMax, clip)
</b></p>
591 <p class=
"p5"><br></p>
592 <p class=
"p1"><span class=
"s6"><span class=
"Apple-tab-span"> </span></span>map the receiver from an assumed exponential input range (inMin..inMax)
</p>
593 <p class=
"p1"><span class=
"Apple-tab-span"> </span>to an exponential output range (outMin..outMax). If the input exceeds the assumed input range.
</p>
594 <p class=
"p1"><span class=
"Apple-tab-span"> </span>Both input range and output range must not include zero.
<span class=
"Apple-converted-space"> </span></p>
595 <p class=
"p1"><span class=
"Apple-tab-span"> </span>If the input exceeds the input range, the following behaviours are specified by the
<b>clip
</b> argument:
<span class=
"Apple-converted-space"> </span></p>
596 <p class=
"p1"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>nil
</b> (don't clip),
<b>\max
</b> (clip ceiling),
<b>\min
</b>, (clip floor),
<b>\minmax
</b> (clip both - this is default).
</p>
597 <p class=
"p2"><br></p>
598 <p class=
"p4"><span class=
"Apple-tab-span"> </span>(
1.
.10).collect {
<span class=
"s2">|num|
</span> num.expexp(
0.1,
10,
4.3,
100) };
<span class=
"Apple-converted-space"> </span></p>
599 <p class=
"p4"><span class=
"Apple-tab-span"> </span>(
1.
.10).expexp(
0.1,
10,
4.3,
100);
<span class=
"s8">// equivalent.
</span></p>
600 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
601 <p class=
"p1"><b>lincurve(inMin, inMax, outMin, outMax, curve, clip)
</b></p>
602 <p class=
"p5"><br></p>
603 <p class=
"p1"><span class=
"s6"><span class=
"Apple-tab-span"> </span></span>map the receiver from an assumed linear input range (inMin..inMax)
</p>
604 <p class=
"p1"><span class=
"Apple-tab-span"> </span>to an exponential curve output range (outMin..outMax). A
<b>curve
</b> is like the curve parameter in
<a href=
"../Control/Env.html"><span class=
"s10">Env
</span></a></p>
605 <p class=
"p1"><span class=
"Apple-tab-span"> </span>Unlike with linexp, the output range may include zero.
<span class=
"Apple-converted-space"> </span></p>
606 <p class=
"p1"><span class=
"Apple-tab-span"> </span>If the input exceeds the input range, the following behaviours are specified by the
<b>clip
</b> argument:
<span class=
"Apple-converted-space"> </span></p>
607 <p class=
"p1"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>nil
</b> (don't clip),
<b>\max
</b> (clip ceiling),
<b>\min
</b>, (clip floor),
<b>\minmax
</b> (clip both - this is default).
</p>
608 <p class=
"p2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
609 <p class=
"p4"><span class=
"s7"><span class=
"Apple-tab-span"> </span></span>(
0.
.10).collect {
<span class=
"s11">|num|
</span> num.lincurve(
0,
10, -
4.3,
100, -
3) };
<span class=
"Apple-converted-space"> </span></p>
610 <p class=
"p4"><span class=
"Apple-tab-span"> </span>(
0.
.10).lincurve(
0,
10, -
4.3,
100, -
3);
<span class=
"s8">// equivalent.
</span></p>
611 <p class=
"p9"><span class=
"s8"><span class=
"Apple-tab-span"> </span></span>// different curves:
</p>
612 <p class=
"p4"><span class=
"Apple-tab-span"> </span>(
</p>
613 <p class=
"p4"><span class=
"Apple-tab-span"> </span>(-
4.
.4).do {
<span class=
"s12">|val|
</span></p>
614 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(
0.
.100).collect(
<span class=
"s12">_
</span>.lincurve(
0,
100,
0,
1, val)).plot
</p>
615 <p class=
"p4"><span class=
"Apple-tab-span"> </span>}
</p>
616 <p class=
"p4"><span class=
"Apple-tab-span"> </span>)
</p>
617 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
618 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
619 <p class=
"p1"><b>curvelin(inMin, inMax, outMin, outMax, curve, clip)
</b></p>
620 <p class=
"p5"><br></p>
621 <p class=
"p1"><span class=
"s6"><span class=
"Apple-tab-span"> </span></span>map the receiver from an assumed curve-exponential input range (inMin..inMax)
</p>
622 <p class=
"p1"><span class=
"Apple-tab-span"> </span>to a linear output range (outMin..outMax). If the input exceeds the assumed input range.
</p>
623 <p class=
"p1"><span class=
"Apple-tab-span"> </span>A
<b> curve
</b> is
<span class=
"Apple-converted-space"> </span>like the curve parameter in
<a href=
"../Control/Env.html"><span class=
"s10">Env
</span></a><span class=
"s10">.
</span></p>
624 <p class=
"p1"><span class=
"Apple-tab-span"> </span>Unlike with explin, the input range may include zero.
<span class=
"Apple-converted-space"> </span></p>
625 <p class=
"p1"><span class=
"Apple-tab-span"> </span>If the input exceeds the input range, the following behaviours are specified by the
<b>clip
</b> argument:
<span class=
"Apple-converted-space"> </span></p>
626 <p class=
"p1"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>nil
</b> (don't clip),
<b>\max
</b> (clip ceiling),
<b>\min
</b>, (clip floor),
<b>\minmax
</b> (clip both - this is default).
<span class=
"s6"><span class=
"Apple-tab-span"> </span></span></p>
627 <p class=
"p5"><br></p>
628 <p class=
"p4"><span class=
"Apple-tab-span"> </span>(
1.
.10).collect {
<span class=
"s11">|num|
</span> num.curvelin(
0,
10, -
4.3,
100, -
3) };
<span class=
"Apple-converted-space"> </span></p>
629 <p class=
"p4"><span class=
"Apple-tab-span"> </span>(
1.
.10).curvelin(
0,
10, -
4.3,
100, -
3);
<span class=
"s8">// equivalent.
</span></p>
630 <p class=
"p9"><span class=
"s8"><span class=
"Apple-tab-span"> </span></span>// different curves:
</p>
631 <p class=
"p4"><span class=
"Apple-tab-span"> </span>(
</p>
632 <p class=
"p4"><span class=
"Apple-tab-span"> </span>(-
4.
.4).do {
<span class=
"s13">|val|
</span></p>
633 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(
0.
.100).collect(
<span class=
"s13">_
</span>.curvelin(
0,
100,
0,
1, val)).plot
</p>
634 <p class=
"p4"><span class=
"Apple-tab-span"> </span>}
</p>
635 <p class=
"p4"><span class=
"Apple-tab-span"> </span>)
</p>
636 <p class=
"p8"><br></p>
637 <p class=
"p8"><span class=
"Apple-tab-span"> </span></p>
638 <p class=
"p1"><b>bilin(inCenter, inMin, inMax, outCenter, outMin, outMax, clip)
</b></p>
639 <p class=
"p5"><br></p>
640 <p class=
"p1"><span class=
"s6"><span class=
"Apple-tab-span"> </span></span>map the receiver from two assumed linear input ranges (inMin..inCenter) and (inCenter..inMax)
</p>
641 <p class=
"p1"><span class=
"Apple-tab-span"> </span>to two linear output ranges (outMin..outCenter) and (outCenter..outMax).
</p>
642 <p class=
"p1"><span class=
"Apple-tab-span"> </span>If the input exceeds the input range, the following behaviours are specified by the
<b>clip
</b> argument:
<span class=
"Apple-converted-space"> </span></p>
643 <p class=
"p1"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>nil
</b> (don't clip),
<b>\max
</b> (clip ceiling),
<b>\min
</b>, (clip floor),
<b>\minmax
</b> (clip both - this is default).
</p>
644 <p class=
"p2"><br></p>
645 <p class=
"p2"><br></p>
646 <p class=
"p4"><span class=
"s7"><span class=
"Apple-tab-span"> </span></span>(
</p>
647 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>var center =
0.5, ctlCenter;
</p>
648 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>w =
<span class=
"s2">Window
</span>(
"bilin", Rect(
100,
100,
200,
100)).front;
</p>
649 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>a =
<span class=
"s2">Slider
</span>(w,
<span class=
"s2">Rect
</span>(
20,
20,
150,
20)).value_(
0.5);
</p>
650 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>b =
<span class=
"s2">Slider
</span>(w,
<span class=
"s2">Rect
</span>(
20,
45,
150,
20)).value_(
0.5);
</p>
651 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>b.action = { center = b.value };
</p>
652 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>a.mouseDownAction = { ctlCenter = a.value };
</p>
653 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>a.action = {
<span class=
"Apple-converted-space"> </span></p>
654 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>b.value = a.value.bilin(ctlCenter,
0,
1, center,
0,
1);
</p>
655 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>};
</p>
656 <p class=
"p4"><span class=
"Apple-tab-span"> </span>)
</p>
657 <p class=
"p2"><br></p>
658 <p class=
"p1"><b>biexp(inCenter, inMin, inMax, outCenter, outMin, outMax, clip)
</b></p>
659 <p class=
"p5"><br></p>
660 <p class=
"p1"><span class=
"s6"><span class=
"Apple-tab-span"> </span></span>map the receiver from two assumed exponential input ranges (inMin..inCenter) and (inCenter..inMax)
</p>
661 <p class=
"p1"><span class=
"Apple-tab-span"> </span>to two linear output ranges (outMin..outCenter) and (outCenter..outMax).
</p>
662 <p class=
"p1"><span class=
"Apple-tab-span"> </span>The input range must not include zero.
<span class=
"Apple-converted-space"> </span></p>
663 <p class=
"p1"><span class=
"Apple-tab-span"> </span>If the input exceeds the input range, the following behaviours are specified by the
<b>clip
</b> argument:
<span class=
"Apple-converted-space"> </span></p>
664 <p class=
"p1"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>nil
</b> (don't clip),
<b>\max
</b> (clip ceiling),
<b>\min
</b>, (clip floor),
<b>\minmax
</b> (clip both - this is default).
<span class=
"Apple-tab-span"> </span></p>
665 <p class=
"p2"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
666 <p class=
"p6"><span class=
"s14"><span class=
"Apple-tab-span"> </span></span>// doesn't properly work yet.
</p>
667 <p class=
"p4"><span class=
"Apple-tab-span"> </span>(
</p>
668 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"s2">var
</span> center =
0.5, ctlCenter;
</p>
669 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>w =
<span class=
"s2">Window
</span>(
<span class=
"s5">"biexp"</span>,
<span class=
"s2">Rect
</span>(
100,
100,
200,
100)).front;
</p>
670 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>a =
<span class=
"s2">Slider
</span>(w,
<span class=
"s2">Rect
</span>(
20,
20,
150,
20)).value_(
0.5);
</p>
671 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>b =
<span class=
"s2">Slider
</span>(w,
<span class=
"s2">Rect
</span>(
20,
45,
150,
20)).value_(
0.5);
</p>
672 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>b.action = { center = b.value };
</p>
673 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>a.mouseDownAction = { ctlCenter = a.value +
0.05 };
</p>
674 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>a.action = {
</p>
675 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>b.value = (a.value +
0.1).biexp(ctlCenter,
0.1,
1.1, center,
0,
1);
</p>
676 <p class=
"p4"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>};
</p>
677 <p class=
"p4"><span class=
"Apple-tab-span"> </span>)
</p>
678 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
679 <p class=
"p1"><b>lcurve(a, m, n, tau)
</b></p>
680 <p class=
"p2"><br></p>
681 <p class=
"p1"><span class=
"Apple-tab-span"> </span>map the receiver onto an L-curve, using the formula: a * (m * exp(x) * rTau +
1) / (n * exp(x) * rTau +
1).
</p>
682 <p class=
"p1"><span class=
"Apple-tab-span"> </span>This is used for smoothing values and limiting them to a range. Defalt values:
<b>a =
1; m =
0; tau =
1</b>.
</p>
683 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
684 <p class=
"p4"><span class=
"Apple-tab-span"> </span>(
0.
.1000).normalize(-
10,
10).collect {
<span class=
"s2">|num|
</span> num.lcurve }.plot;
<span class=
"s7"><span class=
"Apple-tab-span"> </span></span></p>
685 <p class=
"p2"><span class=
"Apple-tab-span"> </span></p>
686 <p class=
"p5"><br></p>
687 <p class=
"p1"><b>gaussCurve(a, b, c)
</b></p>
688 <p class=
"p2"><br></p>
689 <p class=
"p1"><span class=
"Apple-tab-span"> </span>map the receiver onto a gauss function, using the formula: a * (exp(squared(this - b) / (-
2.0 * squared(c))))
<span class=
"Apple-tab-span"> </span>Defalt values:
<b>a =
1; b =
0; c =
1</b></p>
690 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
691 <p class=
"p4"><span class=
"Apple-tab-span"> </span>(
0.
.1000).normalize(-
10,
10).collect {
<span class=
"s2">|num|
</span> num.gaussCurve }.plot;
</p>
692 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
693 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
694 <p class=
"p1"><b>series(second, last)
</b></p>
695 <p class=
"p2"><br></p>
696 <p class=
"p1"><span class=
"Apple-tab-span"> </span>return an artithmetic series from
<b>this
</b> over
<b>second
</b> to
<b>last
</b>. This is used in the shortcuts:
</p>
697 <p class=
"p1"><span class=
"Apple-tab-span"> </span>(
0.
.100) or (
1,
3 ..
17). if
<b>second
</b> is nil, it is one magnitude step towards last (
1 or -
1).
</p>
698 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
699 <p class=
"p4"><span class=
"Apple-tab-span"> </span>series(
5,
7,
10);
</p>
700 <p class=
"p4"><span class=
"Apple-tab-span"> </span>series(
5, nil,
10);
</p>
701 <p class=
"p4"><span class=
"Apple-tab-span"> </span>(
5,
7 ..
10)
<span class=
"Apple-tab-span"> </span></p>
702 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
703 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
704 <p class=
"p1"><b>seriesIter(second, last)
</b></p>
705 <p class=
"p2"><br></p>
706 <p class=
"p1"><span class=
"Apple-tab-span"> </span>return a
<a href=
"../Core/Kernel/Routine.html"><span class=
"s2">Routine
</span></a> that iterates over the numbers from
<b>this
</b> to
<b>last
</b>.
<span class=
"Apple-converted-space"> </span></p>
707 <p class=
"p1"><span class=
"Apple-tab-span"> </span>Since this is a lazy operation,
<b>last
</b> may be
<b>inf
</b>, generating an endless series
<span class=
"Apple-converted-space"> </span></p>
708 <p class=
"p10"><span class=
"s4"><span class=
"Apple-tab-span"> </span>(see also:
<a href=
"../Language/ListComprehensions.html"><span class=
"s7">ListComprehensions
</span></a>)
</span></p>
709 <p class=
"p5"><span class=
"Apple-tab-span"> </span></p>
710 <p class=
"p4"><span class=
"Apple-tab-span"> </span>r = seriesIter(
0,
5);
</p>
711 <p class=
"p4"><span class=
"Apple-tab-span"> </span>r.nextN(
8);
<span class=
"Apple-tab-span"> </span></p>
712 <p class=
"p4"><span class=
"Apple-tab-span"> </span>r.nextN(
8);
<span class=
"Apple-tab-span"> </span></p>
713 <p class=
"p5"><br></p>