SCDoc: Use proper static string constants instead of comparing string literals.
[supercollider.git] / Help / Control / Env.html
blob790973cc931080a5656a9697c0752e051862ed22
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: 18.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}
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: 14.0px Helvetica}
16 p.p7 {margin: 0.0px 0.0px 0.0px 56.0px; text-indent: -56.0px; font: 12.0px Helvetica}
17 p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px}
18 p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #ae1a19}
19 p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #ae1a19; min-height: 12.0px}
20 p.p11 {margin: 0.0px 0.0px 0.0px 28.0px; text-indent: -28.0px; font: 12.0px Helvetica}
21 p.p12 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #0016bd}
22 p.p13 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #2b7000}
23 p.p14 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco; color: #606060; min-height: 12.0px}
24 p.p15 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica}
25 p.p16 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica; min-height: 14.0px}
26 p.p17 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco}
27 p.p18 {margin: 0.0px 0.0px 0.0px 28.0px; text-indent: -28.0px; font: 9.0px Monaco}
28 p.p19 {margin: 0.0px 0.0px 0.0px 28.0px; text-indent: -28.0px; font: 9.0px Monaco; min-height: 12.0px}
29 p.p20 {margin: 0.0px 0.0px 0.0px 28.0px; text-indent: -28.0px; font: 12.0px Helvetica; min-height: 14.0px}
30 p.p21 {margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Monaco; min-height: 16.0px}
31 p.p22 {margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica}
32 span.s1 {font: 12.0px Helvetica}
33 span.s2 {color: #0016bd}
34 span.s3 {color: #000000}
35 span.s4 {font: 12.0px Monaco; color: #000000}
36 span.s5 {color: #2b7000}
37 span.s6 {font: 12.0px Helvetica; color: #000000}
38 span.s7 {font: 9.0px Monaco}
39 span.s8 {color: #ae1a19}
40 span.s9 {font: 12.0px Monaco}
41 span.s10 {font: 12.0px Monaco; color: #ae1a19}
42 span.s11 {font: 9.0px Monaco; color: #0016bd}
43 span.Apple-tab-span {white-space:pre}
44 </style>
45 </head>
46 <body>
47 <p class="p1"><b>Env<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></b><span class="s1"><b>envelope</b></span></p>
48 <p class="p2"><br></p>
49 <p class="p3"><b>superclass: Object</b></p>
50 <p class="p2"><br></p>
51 <p class="p3">An Env is a specification for a segmented envelope. Envs can be used both server-side, by an <a href="../UGens/Synth control/Envelopes/EnvGen.html"><span class="s2">EnvGen</span></a><b> </b>within a SynthDef, and clientside, with methods such as <b>at</b> and <b>asStream</b>, below. An Env can have any number of segments which can stop at a particular value or loop several segments when sustaining. It can have several shapes for its segments.</p>
52 <p class="p2"><span class="Apple-tab-span"> </span></p>
53 <p class="p4"><span class="s2">Env</span>.new([0,1,0.9,0], [0.1,0.5, 1],[-5,0,-5]).plot;</p>
54 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s1"><span class="Apple-tab-span"> </span></span></p>
55 <p class="p3">The envelope is conceived as a sequence of <i>nodes</i> (not to be confused with a synthesis-<a href="../ServerArchitecture/Node.html"><span class="s2">Node</span></a>) each of which has two parameters: a target level and a time duration from the previous node. The two parameters for each node are kept in separate arrays as explained below.<span class="Apple-converted-space"> </span></p>
56 <p class="p2"><br></p>
57 <p class="p3">NOTE: In some other computer music systems and situations we deal with control points or breakpoints. If these control points have associated x positions (say in an envelope GUI, see <a href="../GUI/Cocoa-GUI/SCEnvelopeView.html"><span class="s2">SCEnvelopeView</span></a>) they must be converted to time differences between points to be used as nodes in a Env object.<span class="Apple-converted-space"> </span></p>
58 <p class="p2"><span class="Apple-tab-span"> </span></p>
59 <p class="p6"><b>Class Methods</b></p>
60 <p class="p2"><br></p>
61 <p class="p3">*<b>new(levels, times, curves, releaseNode, loopNode)</b></p>
62 <p class="p2"><br></p>
63 <p class="p3"><span class="Apple-tab-span"> </span>Create a new envelope specification.</p>
64 <p class="p3"><span class="Apple-tab-span"> </span><b>levels</b> - an array of levels. The first level is the initial value of the envelope.</p>
65 <p class="p7"><span class="Apple-tab-span"> </span><b>times</b> - an array of durations of segments in seconds. There should be one fewer duration than there are levels.</p>
66 <p class="p3"><span class="Apple-tab-span"> </span><b>curve</b> - this parameter determines the shape of the envelope segments.</p>
67 <p class="p3"><span class="Apple-tab-span"> </span>The possible values are:</p>
68 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>'step' - flat segments</p>
69 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>'linear' - linear segments, the default</p>
70 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>'exponential' - natural exponential growth and decay. In this case, the levels must all be nonzero</p>
71 <p class="p3"><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>and the have the same sign.</p>
72 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>'sine' - sinusoidal S shaped segments.</p>
73 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>'welch' - sinusoidal segments shaped like the sides of a Welch window.</p>
74 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a Float - a curvature value for all segments.</p>
75 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>An Array of Floats - curvature values for each segments.</p>
76 <p class="p3"><span class="Apple-tab-span"> </span><b>releaseNode</b> - an Integer or nil. The envelope will sustain at the release node until released.</p>
77 <p class="p3"><span class="Apple-tab-span"> </span><b>loopNode</b> - an Integer or nil. If not nil the output will loop through those nodes startign at the loop node to the node immediately preceeding the release node, before back to the loop node, and so on. Note that the envelope only transitions to the release node when released. Examples are below. The loop is escaped when a gate signal is sent, when the output transitions to the release node, as described below.</p>
78 <p class="p2"><br></p>
79 <p class="p8"><br></p>
80 <p class="p9"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>s.boot; <span class="Apple-tab-span"> </span></span>//.test below will run a synthesis example<span class="Apple-converted-space"> </span></p>
81 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>// to demonstrate the envelope, so the Server must be on</p>
82 <p class="p10"><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>
83 <p class="p9"><span class="s4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// different shaped segments: .plot graphs the Env <span class="Apple-converted-space"> </span></p>
84 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.new([0,1, 0.3, 0.8, 0], [2, 3, 1, 4],<span class="s5">'linear'</span>).test.plot;</p>
85 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.new([0.001, 1, 0.3, 0.8, 0.001], [2, 3, 1, 4],<span class="s5">'exponential'</span>).test.plot;</p>
86 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.new([0, 1, 0.3, 0.8, 0], [2, 3, 1, 4],<span class="s5">'sine'</span>).test.plot;</p>
87 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.new([0.001, 1, 0.3, 0.8, 0.001],[2,3,1,4],<span class="s5">'welch'</span>).test.plot;</p>
88 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.new([0, 1, 0.3, 0.8, 0], [2, 3, 1, 4],<span class="s5">'step'</span>).test.plot;</p>
89 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.new([0, 1, 0.3, 0.8, 0], [2, 3, 1, 4], -2).test.plot;</p>
90 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.new([0, 1, 0.3, 0.8, 0], [2, 3, 1, 4], 2).test.plot;</p>
91 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.new([0, 1, 0.3, 0.8, 0], [2, 3, 1, 4], [0, 3, -3, -1]).test.plot;</p>
92 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
93 <p class="p3">If a release node is given, and the gate input of the EnvGen is set to zero, it outputs the nodes after the release node:</p>
94 <p class="p2"><span class="Apple-tab-span"> </span></p>
95 <p class="p9"><span class="s6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// release node is node 1; takes 0.5 seconds to go from 0 to 1,<span class="Apple-converted-space"> </span></p>
96 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>// sustains at level of 1, then released after three seconds<span class="Apple-converted-space"> </span></p>
97 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>// (test causes the release after three seconds, given the argument 3),<span class="Apple-converted-space"> </span></p>
98 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>// taking 2 seconds to finish</p>
99 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.new([0,1,0],[0.5,2],<span class="s5">'linear'</span>,1).test(3).plot</p>
100 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
101 <p class="p9"><span class="s6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// more complex examples</p>
102 <p class="p9"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// release node is node 2; releases after 5 sec</p>
103 <p class="p4"><span class="s1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">Env</span>.new([0.001,1,0.3,0.8,0.001],[2,3,1,4] * 0.2, 2, 2).test(5).plot;</p>
104 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.new([0.001,1,0.3,0.8,0.5,0.8,0],[2,3,1,2,2,1] * 0.2, 2, 2).test(5).plot;</p>
105 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
106 <p class="p9"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// early release: goes straight onto the release node after 0.1 seconds<span class="Apple-converted-space"> </span></p>
107 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.new([0.001,1,0.3,0.8,0.5,0.8,0],[2,3,1,2,2,1] * 0.2, 2, 2).test(0.1).plot;<span class="Apple-converted-space"> </span></p>
108 <p class="p2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
109 <p class="p3">If a loop node is given, the EnvGen outputs the nodes between the loop node and the release node (not including the release node itself) until it is released:</p>
110 <p class="p2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
111 <p class="p9"><span class="s6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// release node is node 2, loop node is node 0: so loops around nodes 0 (lvl 1, dur 0.5)<span class="Apple-converted-space"> </span></p>
112 <p class="p9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>// and 1 (lvl 0.1, dur 0.5) <span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>//until released after 3.5 seconds</p>
113 <p class="p4"><span class="s1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">Env</span>.new([0,1,0.1,0],[0.5,0.5,2], <span class="s5">'lin'</span>, 2, 0).test(3.5).plot;<span class="Apple-converted-space"> </span></p>
114 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
115 <p class="p9"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// this just sustains at node 0, because there is no other node to loop around!</p>
116 <p class="p4"><span class="s1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">Env</span>.new([0,1,0],[0.5,2], <span class="s5">'lin'</span>, 1, 0).test(3.5).plot;<span class="Apple-converted-space"> </span></p>
117 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
118 <p class="p9"><span class="s6"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// more complex example: release node is node 3, loop node is node 1</p>
119 <p class="p4"><span class="s1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">Env</span>.new([0.001,1,0.3,0.8,0.5,0.8,0],[2,1,1,2,3,1] * 0.1, <span class="s5">'lin'</span>, 3, 1).test(3).plot;<span class="Apple-converted-space"> </span></p>
120 <p class="p2"><br></p>
121 <p class="p3"><b>Note:</b></p>
122 <p class="p2"><span class="Apple-tab-span"> </span></p>
123 <p class="p3">The starting level for an envelope segment is always the level you are at right now. For example when the gate is released and you jump to the release segment, the level does not jump to the level at the beginning of the release segment, it changes from<span class="Apple-converted-space">  </span>whatever the current level is to the goal level of the release segment over the specified duration of the release segment.</p>
124 <p class="p2"><br></p>
125 <p class="p3">There is an extra level at the beginning of the envelope to set the initial level. After that each node is a goal level and a duration, so node zero has duration equal to times[0] and goal level equal to levels[1].</p>
126 <p class="p2"><span class="Apple-tab-span"> </span></p>
127 <p class="p3">The loop jumps back to the loop node. The endpoint of that segment is the goal level for that segment and the duration of<span class="Apple-converted-space">  </span>that segment will be the time over which the level changed from the current level to the goal level.</p>
128 <p class="p8"><br></p>
129 <p class="p3">*<b>newClear(numSegments)</b></p>
130 <p class="p2"><br></p>
131 <p class="p11"><span class="Apple-tab-span"> </span>Creates a new envelope specification with <b>numSegments</b> for filling in later. This can be useful when passing Env parameters as args to a <a href="../ServerArchitecture/Synth.html"><span class="s2">Synth</span></a>. Note that the maximum number of segments is fixed and cannot be changed once embedded in a <a href="../ServerArchitecture/SynthDef.html"><span class="s2">SynthDef</span></a>. Trying to set an Env with more segments than then this may result in other args being unexpectedly set.</p>
132 <p class="p2"><span class="Apple-tab-span"> </span></p>
133 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s7">(</span></p>
134 <p class="p12"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>SynthDef<span class="s3">(</span><span class="s5">\help_Env_newClear</span><span class="s3">, { </span>|i_outbus=0, t_gate|</p>
135 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">var</span> env, envctl;</p>
136 <p class="p9"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// make an empty 4 segment envelope</p>
137 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>env = <span class="s2">Env</span>.newClear(4);</p>
138 <p class="p9"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// create a control argument array</p>
139 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>envctl = <span class="s2">Control</span>.names([<span class="s5">\env</span>]).kr( env.asArray );</p>
140 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Out</span>.ar(i_outbus, <span class="s2">SinOsc</span>.ar(<span class="s2">EnvGen</span>.kr(envctl, t_gate), 0, 0.3));</p>
141 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>}).send(s);</p>
142 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
143 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
144 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>s.bind {</p>
145 <p class="p9"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// must not have more segments than the env above</p>
146 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>e = <span class="s2">Env</span>([700,900,900,800], [1,1,1], <span class="s5">\exp</span>); <span class="s8">// 3 segments</span></p>
147 <p class="p13"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>x = </span><span class="s2">Synth</span><span class="s3">(</span>\help_Env_newClear<span class="s3">, [</span>\t_gate<span class="s3">, 1]);</span></p>
148 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>x.setn(<span class="s5">\env</span>, e.asArray);</p>
149 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>};</p>
150 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
151 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
152 <p class="p9"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// reset then play again</p>
153 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>e = <span class="s2">Env</span>([800,300,400,500,200], [1,1,1,1], <span class="s5">\exp</span>); <span class="s8">// 4 segments</span></p>
154 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>x.setn(<span class="s5">\env</span>, e.asArray);</p>
155 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>x.set(<span class="s5">\t_gate</span>, 1);</p>
156 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
157 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>x.free;</p>
158 <p class="p14"><br></p>
159 <p class="p14"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
160 <p class="p6"><b>Standard Shape Envelope Creation Methods</b></p>
161 <p class="p2"><br></p>
162 <p class="p3">The following class methods create some frequently used envelope shapes based on supplied durations.</p>
163 <p class="p2"><span class="Apple-tab-span"> </span></p>
164 <p class="p3">*<b>linen(attackTime, sustainTime, releaseTime, level, curve)</b></p>
165 <p class="p2"><span class="Apple-converted-space"> </span></p>
166 <p class="p3"><span class="Apple-tab-span"> </span>Creates a new envelope specification which has a trapezoidal shape.</p>
167 <p class="p3"><span class="Apple-tab-span"> </span><b>attackTime</b> - the duration of the attack portion.</p>
168 <p class="p3"><span class="Apple-tab-span"> </span><b>sustainTime</b> - the duration of the sustain portion.</p>
169 <p class="p3"><span class="Apple-tab-span"> </span><b>releaseTime</b> - the duration of the release portion.</p>
170 <p class="p3"><span class="Apple-tab-span"> </span><b>level</b> - the level of the sustain portion.</p>
171 <p class="p3"><span class="Apple-tab-span"> </span><b>curve</b> - the curvature of the envelope.</p>
172 <p class="p2"><br></p>
173 <p class="p4"><span class="s1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>s.boot;</p>
174 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.linen(1, 2, 3, 0.6).test.plot;</p>
175 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.linen(0.1, 0.2, 0.1, 0.6).test.plot;</p>
176 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.linen(1, 2, 3, 0.6, <span class="s5">'sine'</span>).test.plot;</p>
177 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.linen(1, 2, 3, 0.6, <span class="s5">'welch'</span>).test.plot;</p>
178 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.linen(1, 2, 3, 0.6, -3).test.plot;</p>
179 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.linen(1, 2, 3, 0.6, -3).test.plot;</p>
180 <p class="p8"><span class="Apple-tab-span"> </span></p>
181 <p class="p2"><br></p>
182 <p class="p3">*<b>triangle(duration, level)</b></p>
183 <p class="p2"><span class="Apple-converted-space"> </span></p>
184 <p class="p3"><span class="Apple-tab-span"> </span>Creates a new envelope specification which has a triangle shape.</p>
185 <p class="p3"><span class="Apple-tab-span"> </span><b>duration</b> - the duration of the envelope.</p>
186 <p class="p3"><span class="Apple-tab-span"> </span><b>level</b> - the peak level of the envelope.</p>
187 <p class="p2"><span class="Apple-tab-span"> </span><span class="Apple-converted-space"> </span></p>
188 <p class="p4"><span class="s1"><span class="Apple-tab-span"> </span></span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.triangle(1, 1).test.plot;</p>
189 <p class="p2"><br></p>
190 <p class="p2"><br></p>
191 <p class="p3">*<b>sine(duration, level)</b></p>
192 <p class="p2"><span class="Apple-converted-space"> </span></p>
193 <p class="p3"><span class="Apple-tab-span"> </span>Creates a new envelope specification which has a hanning window shape.</p>
194 <p class="p3"><span class="Apple-tab-span"> </span><b>duration</b> - the duration of the envelope.</p>
195 <p class="p3"><span class="Apple-tab-span"> </span><b>level</b> - the peak level of the envelope.</p>
196 <p class="p2"><span class="Apple-tab-span"> </span><span class="Apple-converted-space"> </span></p>
197 <p class="p4"><span class="s1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">Env</span>.sine(1,1).test.plot;</p>
198 <p class="p2"><span class="Apple-tab-span"> </span></p>
199 <p class="p2"><span class="s8"><span class="Apple-tab-span"> </span></span><span class="Apple-tab-span"> </span></p>
200 <p class="p3">*<b>perc(attackTime, releaseTime, peakLevel, curve)</b></p>
201 <p class="p2"><span class="Apple-converted-space"> </span></p>
202 <p class="p3"><span class="Apple-tab-span"> </span>Creates a new envelope specification which (usually) has a percussive shape.</p>
203 <p class="p3"><span class="Apple-tab-span"> </span><b>attackTime</b> - the duration of the attack portion.</p>
204 <p class="p3"><span class="Apple-tab-span"> </span><b>releaseTime</b> - the duration of the release portion.</p>
205 <p class="p3"><span class="Apple-tab-span"> </span><b>peakLevel</b> - the peak level of the envelope.</p>
206 <p class="p3"><span class="Apple-tab-span"> </span><b>curve</b> - the curvature of the envelope.</p>
207 <p class="p2"><span class="Apple-tab-span"> </span><span class="Apple-converted-space"> </span></p>
208 <p class="p4"><span class="s9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">Env</span>.perc(0.05, 1, 1, -4).test.plot;</p>
209 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.perc(0.001, 1, 1, -4).test.plot;<span class="Apple-tab-span"> </span><span class="s8">// sharper attack</span></p>
210 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.perc(0.001, 1, 1, -8).test.plot;<span class="Apple-tab-span"> </span><span class="s8">// change curvature</span></p>
211 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.perc(1, 0.01, 1, 4).test.plot;<span class="Apple-tab-span"> </span><span class="s8">// reverse envelope</span></p>
212 <p class="p8"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
213 <p class="p2"><br></p>
214 <p class="p6"><b>Sustained Envelope Creation Methods</b></p>
215 <p class="p2"><br></p>
216 <p class="p3">The following methods create some frequently used envelope shapes which have a sustain segment.</p>
217 <p class="p2"><br></p>
218 <p class="p3">*<b>adsr(attackTime, decayTime, sustainLevel,<span class="Apple-converted-space">  </span>releaseTime, peakLevel, curve)</b></p>
219 <p class="p2"><b><span class="Apple-tab-span"> </span></b><span class="Apple-converted-space"> </span></p>
220 <p class="p11"><span class="Apple-tab-span"> </span>Creates a new envelope specification which is shaped like traditional analog attack-decay-sustain-release (adsr) envelopes.</p>
221 <p class="p3"><span class="Apple-tab-span"> </span><b>attackTime</b> - the duration of the attack portion.</p>
222 <p class="p3"><span class="Apple-tab-span"> </span><b>decayTime</b> - the duration of the decay portion.</p>
223 <p class="p3"><span class="Apple-tab-span"> </span><b>sustainLevel</b> - the level of the sustain portion as a ratio of the peak level.</p>
224 <p class="p3"><span class="Apple-tab-span"> </span><b>releaseTime</b> - the duration of the release portion.</p>
225 <p class="p3"><span class="Apple-tab-span"> </span><b>peakLevel</b> - the peak level of the envelope.</p>
226 <p class="p3"><span class="Apple-tab-span"> </span><b>curve</b> - the curvature of the envelope.</p>
227 <p class="p2"><span class="Apple-tab-span"> </span><span class="Apple-converted-space"> </span></p>
228 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.adsr(0.02, 0.2, 0.25, 1, 1, -4).test(2).plot;</p>
229 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.adsr(0.001, 0.2, 0.25, 1, 1, -4).test(2).plot;<span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
230 <p class="p9"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>//release after 0.45 sec</p>
231 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.adsr(0.001, 0.2, 0.25, 1, 1, -4).test(0.45).plot;</p>
232 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s10"><span class="Apple-tab-span"> </span></span></p>
233 <p class="p3">*<b>dadsr(delayTime, attackTime, decayTime, sustainLevel,<span class="Apple-converted-space">  </span>releaseTime, peakLevel, curve)</b></p>
234 <p class="p2"><br></p>
235 <p class="p15"><span class="Apple-tab-span"> </span>As <b>*adsr</b> above, but with it's onset delayed by <b>delayTime</b> in seconds. The default delay is 0.1.</p>
236 <p class="p16"><span class="Apple-tab-span"> </span></p>
237 <p class="p3">*<b>asr(attackTime, sustainLevel,<span class="Apple-converted-space">  </span>releaseTime, curve)</b></p>
238 <p class="p2"><span class="Apple-converted-space"> </span></p>
239 <p class="p11"><span class="Apple-tab-span"> </span>Creates a new envelope specification which is shaped like traditional analog attack-sustain-release (asr) envelopes.</p>
240 <p class="p3"><span class="Apple-tab-span"> </span><b>attackTime</b> - the duration of the attack portion.</p>
241 <p class="p3"><span class="Apple-tab-span"> </span><b>sustainLevel</b> - the level of the sustain portion as a ratio of the peak level.</p>
242 <p class="p3"><span class="Apple-tab-span"> </span><b>releaseTime</b> - the duration of the release portion.</p>
243 <p class="p3"><span class="Apple-tab-span"> </span><b>curve</b> - the curvature of the envelope.</p>
244 <p class="p2"><span class="Apple-tab-span"> </span><span class="Apple-converted-space"> </span></p>
245 <p class="p2"><span class="Apple-tab-span"> </span></p>
246 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.asr(0.02, 0.5, 1, -4).test(2).plot;</p>
247 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.asr(0.001, 0.5, 1, -4).test(2).plot; <span class="s8">// sharper attack</span></p>
248 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.asr(0.02, 0.5, 1, <span class="s5">'linear'</span>).test(2).plot; <span class="s8">// linear segments</span></p>
249 <p class="p2"><span class="Apple-tab-span"> </span></p>
250 <p class="p3">*<b>cutoff(releaseTime, level, curve)</b></p>
251 <p class="p2"><span class="Apple-converted-space"> </span></p>
252 <p class="p15"><span class="Apple-tab-span"> </span>Creates a new envelope specification which has no attack segment. It simply sustains at the peak level until released. Useful if you only need a fadeout, and more versatile than <a href="../UGens/Synth control/Envelopes/Line.html"><span class="s2">Line</span></a>.</p>
253 <p class="p3"><span class="Apple-tab-span"> </span><b>releaseTime</b> - the duration of the release portion.</p>
254 <p class="p3"><span class="Apple-tab-span"> </span><b>level</b> - the peak level of the envelope.</p>
255 <p class="p3"><span class="Apple-tab-span"> </span><b>curve</b> - the curvature of the envelope.</p>
256 <p class="p2"><span class="Apple-tab-span"> </span></p>
257 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.cutoff(1, 1).test(2).plot;</p>
258 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.cutoff(1, 1, 4).test(2).plot;</p>
259 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Env</span>.cutoff(1, 1, <span class="s5">'sine'</span>).test(2).plot;</p>
260 <p class="p2"><br></p>
261 <p class="p2"><br></p>
262 <p class="p6"><b>Instance Methods</b></p>
263 <p class="p2"><span class="Apple-tab-span"> </span></p>
264 <p class="p3"><b>blend(anotherEnv, blendFraction)</b></p>
265 <p class="p2"><br></p>
266 <p class="p3"><span class="Apple-tab-span"> </span>Blend two envelopes. Returns a new Env.</p>
267 <p class="p3"><span class="Apple-tab-span"> </span><b>anotherEnv</b> - an Env.</p>
268 <p class="p3"><span class="Apple-tab-span"> </span><b>blendFraction</b> - a number from zero to one.</p>
269 <p class="p2"><span class="Apple-tab-span"> </span></p>
270 <p class="p4"><span class="s9"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>a = <span class="s2">Env</span>([0, 0.2, 1, 0.2, 0.2, 0], [0.5, 0.01, 0.01, 0.3, 0.2]).test.plot;</p>
271 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>b = <span class="s2">Env</span>([0, 0.4, 1, 0.2, 0.5, 0], [0.05, 0.4, 0.01, 0.1, 0.4]).test.plot;</p>
272 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
273 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
274 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">Task</span>({</p>
275 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>f = (0, 0.2 .. 1);</p>
276 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>f.do { <span class="s2">|u|</span></p>
277 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>blend(a, b, u).test.plot;</p>
278 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>2.wait;</p>
279 <p class="p4"><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="s2">Window</span>.allWindows.pop.close; <span class="s8">// close last opened window</span></p>
280 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>}</p>
281 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>}).play(<span class="s2">AppClock</span>);</p>
282 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
283 <p class="p5"><br></p>
284 <p class="p9"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// in a SynthDef</p>
285 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
286 <p class="p12"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>SynthDef<span class="s3">(</span><span class="s5">\help_EnvBlend</span><span class="s3">, { </span>| fact = 0 |<span class="s3"> </span></p>
287 <p class="p4"><span class="s1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">Out</span>.ar(0, <span class="s2">EnvGen</span>.kr(<span class="s2">Env</span>.perc.blend(<span class="s2">Env</span>.sine, fact), 1.0, doneAction: 2</p>
288 <p class="p4"><span class="s1"><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>* <span class="s2">SinOsc</span>.ar(440,0,0.1)</p>
289 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s7"></span></p>
290 <p class="p4"><span class="s1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>}).send(s));</p>
291 <p class="p2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
292 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
293 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{</p>
294 <p class="p4"><span class="s1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>f = (0, 0.1..1);</p>
295 <p class="p4"><span class="s1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>f.do({<span class="s2">|fact|</span> <span class="s2">Synth</span>(<span class="s5">\help_EnvBlend</span>, [<span class="s5">\fact</span>, fact.postln]); 1.wait;});</p>
296 <p class="p2"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
297 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>}.fork;)</p>
298 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
299 <p class="p3"><b>delay(delay)</b></p>
300 <p class="p2"><br></p>
301 <p class="p11"><span class="Apple-tab-span"> </span>Returns a new Env based on the receiver in which the start value will be held for <b>delay</b> number of seconds.</p>
302 <p class="p15"><span class="Apple-tab-span"> </span><b>delay</b> - The amount of time to delay the start of the envelope.</p>
303 <p class="p16"><span class="Apple-tab-span"> </span></p>
304 <p class="p17"><span class="s1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>a = <span class="s2">Env</span>.perc(0.05, 1, 1, -4);</p>
305 <p class="p17"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>b = a.delay(2);</p>
306 <p class="p17"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.test.plot;</p>
307 <p class="p17"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>b.test.plot;</p>
308 <p class="p16"><br></p>
309 <p class="p18"><span class="s1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>a = <span class="s2">Env</span>([0.5, 1, 0], [1, 1]).plot;</p>
310 <p class="p18"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.delay(1).plot;</p>
311 <p class="p19"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
312 <p class="p11"><b>circle(timeFromLastToFirst, curve)</b></p>
313 <p class="p20"><br></p>
314 <p class="p11"><b><span class="Apple-tab-span"> </span></b>circle from end to beginning over the time specified, with the curve specified.<span class="Apple-converted-space"> </span></p>
315 <p class="p20"><span class="Apple-tab-span"> </span></p>
316 <p class="p18"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
317 <p class="p18"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{ <span class="s2">SinOsc</span>.ar(</p>
318 <p class="p18"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">EnvGen</span>.kr(</p>
319 <p class="p18"><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="s2">Env</span>([6000, 700, 100], [1, 1], [<span class="s5">'exp'</span>, <span class="s5">'lin'</span>]).circle.postcs)</p>
320 <p class="p18"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>) * 0.1<span class="Apple-converted-space"> </span></p>
321 <p class="p18"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>+ <span class="s2">Impulse</span>.ar(1)<span class="Apple-converted-space"> </span></p>
322 <p class="p18"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>}.play;</p>
323 <p class="p18"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
324 <p class="p19"><span class="Apple-tab-span"> </span></p>
325 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
326 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{ <span class="s2">SinOsc</span>.ar(</p>
327 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">EnvGen</span>.kr(</p>
328 <p class="p4"><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="s2">Env</span>([6000, 700, 100], [1, 1], [<span class="s5">'exp'</span>, <span class="s5">'lin'</span>]).circle(1).postcs,<span class="Apple-converted-space"> </span></p>
329 <p class="p4"><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="s2">MouseX</span>.kr &gt; 0.5)</p>
330 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>) * 0.1<span class="Apple-converted-space"> </span></p>
331 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>+ <span class="s2">Impulse</span>.ar(1) }.play;</p>
332 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
333 <p class="p21"><br></p>
334 <p class="p3"><b>test(releaseTime)</b></p>
335 <p class="p2"><br></p>
336 <p class="p3"><span class="Apple-tab-span"> </span>Test the envelope on the default <a href="../ServerArchitecture/Server.html"><span class="s2">Server</span></a> with a <a href="../UGens/Oscillators/SinOsc.html"><span class="s2">SinOsc</span></a>.</p>
337 <p class="p15"><span class="Apple-tab-span"> </span><b>releaseTime</b> - If this is a sustaining envelope, it will be released after this much time in seconds. The default is 3 seconds.</p>
338 <p class="p21"><span class="Apple-tab-span"> </span></p>
339 <p class="p3"><b>plot(size, bounds, minval, maxval, parent)</b></p>
340 <p class="p2"><br></p>
341 <p class="p3"><span class="Apple-tab-span"> </span>Plot this envelope's shape in a window.</p>
342 <p class="p15"><span class="Apple-tab-span"> </span><b>size</b> - The size of the plot. The default is 400.</p>
343 <p class="p15"><span class="Apple-tab-span"> </span><b>bounds </b>- the size of the plot window.</p>
344 <p class="p22"><span class="Apple-tab-span"> </span><b>minval</b> - the minimum value in the plot. Defaults to the lowest value in the data.</p>
345 <p class="p22"><span class="Apple-tab-span"> </span><b>maxval</b> - the maximum value in the plot. Defaults to the highest value in the data.</p>
346 <p class="p22"><span class="Apple-tab-span"> </span><b>parent</b> - a window to place the plot in. If nil, one will be created for you</p>
347 <p class="p8"><span class="Apple-tab-span"> </span></p>
348 <p class="p3"><b>asSignal(length)</b></p>
349 <p class="p2"><br></p>
350 <p class="p3"><span class="Apple-tab-span"> </span>Returns a Signal of size <b>length</b> created by sampling this Env at <b>length</b> number of intervals.</p>
351 <p class="p2"><span class="Apple-tab-span"> </span></p>
352 <p class="p3"><b>asArray</b></p>
353 <p class="p2"><br></p>
354 <p class="p11"><span class="Apple-tab-span"> </span>Converts the Env to an Array in a specially ordered format. This allows for Env parameters to be settable arguments in a <a href="../ServerArchitecture/SynthDef.html"><span class="s2">SynthDef</span></a>. See example above under *<b>newClear</b>.</p>
355 <p class="p20"><span class="Apple-tab-span"> </span></p>
356 <p class="p3"><b>isSustained</b></p>
357 <p class="p2"><br></p>
358 <p class="p11"><span class="Apple-tab-span"> </span>Returns true if this is a sustaining envelope, false otherwise.</p>
359 <p class="p20"><span class="Apple-tab-span"> </span></p>
360 <p class="p3"><b>range(lo, hi)</b></p>
361 <p class="p3"><b>exprange(lo, hi)</b></p>
362 <p class="p2"><br></p>
363 <p class="p3"><span class="Apple-tab-span"> </span>Returns a copy of the Env whose levels have been mapped onto the given linear or exponential range.</p>
364 <p class="p2"><span class="Apple-tab-span"> </span></p>
365 <p class="p4"><span class="s1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>a = <span class="s2">Env</span>.adsr;</p>
366 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.levels;</p>
367 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.range(42, 45).levels;</p>
368 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>a.exprange(42, 45).levels;</p>
369 <p class="p5"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></p>
370 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>(</p>
371 <p class="p9"><span class="s3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span>// Mapping an Env to an exponential frequency range:</p>
372 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{</p>
373 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s2">SinOsc</span>.ar(<span class="s2">EnvGen</span>.ar(<span class="s2">Env</span>.perc(0.01, 0.2).exprange(40, 10000), doneAction: 2)</p>
374 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>, 0, 0.1).dup;</p>
375 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>}.play(s)</p>
376 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
377 <p class="p2"><br></p>
378 <p class="p2"><span class="Apple-tab-span"> </span></p>
379 <p class="p6"><b>Client-side Access and Stream Support</b></p>
380 <p class="p8"><br></p>
381 <p class="p3">Sustain and loop settings have no effect in the methods below.</p>
382 <p class="p2"><span class="Apple-converted-space"> </span></p>
383 <p class="p3"><b>at(time)</b></p>
384 <p class="p2"><br></p>
385 <p class="p3"><span class="Apple-tab-span"> </span>Returns the value of the Env at <b>time</b>.</p>
386 <p class="p2"><span class="Apple-tab-span"> </span></p>
387 <p class="p4"><span class="s1"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span></span><span class="s2">Env</span>.triangle(1, 1).at(0.5);</p>
388 <p class="p8"><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>
389 <p class="p3"><b>embedInStream</b></p>
390 <p class="p2"><br></p>
391 <p class="p3"><span class="Apple-tab-span"> </span>Embeds this Env within an enclosing <a href="../Streams-Patterns-Events/Stream.html"><span class="s2">Stream</span></a>. Timing is derived from <span class="s11">thisThread</span><span class="s7">.beats</span>.</p>
392 <p class="p8"><br></p>
393 <p class="p3"><b>asStream</b></p>
394 <p class="p2"><br></p>
395 <p class="p3"><span class="Apple-tab-span"> </span>Creates a Routine and embeds the Env in it. This allows the Env to function as a <a href="../Streams-Patterns-Events/Stream.html"><span class="s2">Stream</span></a>.</p>
396 <p class="p2"><span class="Apple-tab-span"> </span></p>
397 <p class="p3"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="s7">(</span></p>
398 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>{</p>
399 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>e = <span class="s2">Env</span>.sine.asStream;</p>
400 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>5.do({</p>
401 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>e.next.postln;</p>
402 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>0.25.wait;</p>
403 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>})}.fork</p>
404 <p class="p4"><span class="Apple-tab-span"> </span><span class="Apple-tab-span"> </span>)</p>
405 </body>
406 </html>