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=
"949.43">
9 <style type=
"text/css">
10 p
.p1
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
}
11 p
.p2
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; min-height: 14.0px}
12 p
.p3
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; min-height: 12.0px}
13 p
.p4
{margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica
; color: #314bd1}
14 p
.p5
{margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica
}
15 p
.p6
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 9.0px Monaco
; min-height: 12.0px}
16 p
.p7
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica
}
17 p
.p8
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 12.0px Helvetica
; min-height: 14.0px}
18 p
.p9
{margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica
}
19 p
.p10
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica
}
20 p
.p11
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica
; min-height: 17.0px}
21 p
.p12
{margin: 0.0px 0.0px 0.0px 85.0px; text-indent: -85.0px; font: 12.0px Helvetica
; min-height: 14.0px}
22 p
.p13
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #000000; min-height: 12.0px}
23 p
.p14
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #000000}
24 p
.p15
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #bf0000}
25 p
.p16
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #606060}
26 p
.p17
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #0000bf}
27 span
.s1
{font: 18.0px Helvetica
}
28 span
.s2
{color: #314bd1}
29 span
.s3
{color: #000000}
30 span
.s4
{color: #304098}
31 span
.s5
{color: #6f7178}
32 span
.s6
{font: 14.0px Helvetica
}
33 span
.s7
{color: #0000bf}
34 span
.s8
{color: #606060}
35 span
.s9
{color: #007300}
36 span
.Apple-tab-span
{white-space:pre
}
40 <p class=
"p1"><span class=
"s1"><b>SCEnvelopeEdit
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></span><b>an envelope editor view
</b><span class=
"s1"><b><span class=
"Apple-tab-span"> </span></b></span></p>
41 <p class=
"p2"><br></p>
42 <p class=
"p1"><b>Inherits from: Object : SCView :
</b><a href=
"SCEnvelopeView.html"><span class=
"s2"><b>SCEnvelopeView
</b></span></a></p>
43 <p class=
"p3"><br></p>
44 <p class=
"p1">An editable Envelope view.
</p>
45 <p class=
"p2"><br></p>
46 <p class=
"p4"><span class=
"s3"><b>See also:
</b></span><span class=
"s4"> <a href=
"SCEnvelopeView.html"><span class=
"s2">SCEnvelopeView
</span></a></span></p>
47 <p class=
"p2"><br></p>
48 <p class=
"p5"><b>Some Important Issues Regarding SCEnvelopeEdit
</b></p>
49 <p class=
"p2"><br></p>
50 <p class=
"p1">The breakpoints are color coded as follows:
</p>
51 <p class=
"p1"><span class=
"Apple-tab-span"> </span>blue -
<span class=
"Apple-tab-span"> </span>normal
</p>
52 <p class=
"p1"><span class=
"Apple-tab-span"> </span>red -
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>sustain node
</p>
53 <p class=
"p1"><span class=
"Apple-tab-span"> </span>green -
<span class=
"Apple-tab-span"> </span>loop node
</p>
54 <p class=
"p2"><br></p>
55 <p class=
"p5"><b>Creation / Class Methods
</b></p>
56 <p class=
"p6"><br></p>
57 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>*new (parent, bounds, env, pointsPerSegment)
</b></p>
58 <p class=
"p8"><b><span class=
"Apple-tab-span"> </span></b></p>
59 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>parent
</b>- The parent view.
</p>
60 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>bounds
</b>- An instance of
<a href=
"../../Geometry/Rect.html"><span class=
"s5">Rect
</span></a>, or a
<a href=
"../../Geometry/Point.html"><span class=
"s5">Point
</span></a> indicating width@height.
</p>
61 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>env
</b>- The envelope. An instance of
<a href=
"../../Control/Env.html"><span class=
"s2">Env
</span></a>.
</p>
62 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>pointsPerSegment
</b>- The resolution in points per segment. Default value is
10.
</p>
63 <p class=
"p6"><br></p>
64 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>*paletteExample (parent, bounds)
</b></p>
65 <p class=
"p6"><br></p>
66 <p class=
"p10"><b>Accessing Instance and Class Variables
</b></p>
67 <p class=
"p11"><br></p>
68 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>refresh
</b></p>
69 <p class=
"p8"><b><span class=
"Apple-tab-span"> </span></b></p>
70 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>If the Env object is modified directly, this needs to be called to update the GUI.
</p>
71 <p class=
"p8"><br></p>
72 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>maxLevel
</b></p>
73 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>maxLevel_ (level)
</b></p>
74 <p class=
"p8"><b><span class=
"Apple-tab-span"> </span></b></p>
75 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Changes maximum level shown in editor.
</p>
76 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>level
</b>- and Instance of
<a href=
"../../Math/Float.html"><span class=
"s2">Float
</span></a>.
</p>
77 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
78 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>minLevel
</b></p>
79 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>minLevel_ (level)
</b></p>
80 <p class=
"p8"><b><span class=
"Apple-tab-span"> </span></b></p>
81 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Changes minimum level shown in editor.
</p>
82 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>level
</b>- and Instance of
<a href=
"../../Math/Float.html"><span class=
"s2">Float
</span></a>.
</p>
83 <p class=
"p8"><br></p>
84 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>minTime
</b></p>
85 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>minTime_ (sec)
</b></p>
86 <p class=
"p8"><b><span class=
"Apple-tab-span"> </span></b></p>
87 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Changes minimum time (sec) shown in editor. Negative times are okay because Env uses inter-node durations.
</p>
88 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>sec
</b>- An instance of
<a href=
"../../Math/Float.html"><span class=
"s2">Float
</span></a>. Seconds.
</p>
89 <p class=
"p12"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
90 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>maxTime
</b></p>
91 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>maxTime_ (sec)
</b></p>
92 <p class=
"p8"><b><span class=
"Apple-tab-span"> </span></b></p>
93 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Changes maximum time (sec) shown in editor.
</p>
94 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>sec
</b>- An instance of
<a href=
"../../Math/Float.html"><span class=
"s2">Float
</span></a>. Seconds.
</p>
95 <p class=
"p6"><br></p>
96 <p class=
"p10"><b>Subclassing and Internal Methods
</b></p>
97 <p class=
"p7"><span class=
"s6"><span class=
"Apple-tab-span"> </span></span>The following methods are usually not used directly or are called by a primitive. Programmers can still call or override these as needed.
</p>
98 <p class=
"p8"><br></p>
99 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>defaultMauseDownAction (x, y, modifiers, buttonNumber, clickCount)
</b></p>
100 <p class=
"p8"><b><span class=
"Apple-tab-span"> </span></b></p>
101 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>*viewClass
</b></p>
102 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>env_ (e)
</b></p>
103 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>addBreakPoint (level)
</b></p>
104 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>insertAtTime (time, level)
</b></p>
105 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>pointsPerSegment
</b></p>
106 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>env
</b></p>
107 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>initSCEnvelopeEdit (argEnv, argPPS, setMinMax)
</b></p>
108 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>redraw
</b></p>
109 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>updateAll
</b></p>
110 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>updateSegment (segNum)
</b></p>
111 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>clear
</b></p>
112 <p class=
"p6"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
113 <p class=
"p10"><b>Examples
</b></p>
114 <p class=
"p13"><br></p>
116 <p class=
"p15">// make a basic editor
</p>
117 <p class=
"p14">e =
<span class=
"s7">Env
</span>([
1,
2],[
10]);
</p>
118 <p class=
"p14">w =
<span class=
"s7">SCWindow
</span>(
<span class=
"s8">"Env Editor"</span>,
<span class=
"s7">Rect
</span>(
200,
200,
300,
200));
</p>
119 <p class=
"p14">v =
<span class=
"s7">SCEnvelopeEdit
</span>(w, w.view.bounds.moveBy(
20,
20).resizeBy(-
40,-
40), e,
20).resize_(
5);
</p>
120 <p class=
"p14">w.front;
</p>
122 <p class=
"p14">v.addBreakPoint;
</p>
123 <p class=
"p13"><br></p>
124 <p class=
"p14">v.clear;
</p>
125 <p class=
"p14">v.redraw;
</p>
126 <p class=
"p14">v;
</p>
128 <p class=
"p13"><br></p>
129 <p class=
"p15"><span class=
"s3">v.maxLevel_(
2);
<span class=
"Apple-tab-span"> </span></span>// to give more headroom
</p>
130 <p class=
"p15"><span class=
"s3">v.maxTime_(
2);
<span class=
"Apple-tab-span"> </span></span>// to increase release point
</p>
131 <p class=
"p15"><span class=
"s3">v.minTime_(-
1);
<span class=
"Apple-tab-span"> </span></span>// to increase attack time
</p>
132 <p class=
"p13"><br></p>
133 <p class=
"p15"><span class=
"s3">e.curves_ =
</span><span class=
"s9">'sin'
</span><span class=
"s3">;
<span class=
"Apple-tab-span"> </span></span>// env object is changed
</p>
134 <p class=
"p15"><span class=
"s3">v.refresh;
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></span>// must refresh editor
</p>
135 <p class=
"p13"><br></p>
136 <p class=
"p13"><br></p>
137 <p class=
"p13"><br></p>
138 <p class=
"p15">// Controlling a Synth
</p>
139 <p class=
"p13"><br></p>
140 <p class=
"p14">s=
<span class=
"s7">Server
</span>.internal;
</p>
141 <p class=
"p14">s.boot;
</p>
143 <p class=
"p14">e =
<span class=
"s7">Env
</span>([
0,
1,
0.7,
0.9,
0], [
0.03,
0.03,
0.03,
0.03],
<span class=
"s9">'sin'
</span>);
</p>
144 <p class=
"p14">f =
<span class=
"s7">Env
</span>([
0,
1,
0.7,
0.9,
0], [
0.03,
0.03,
0.03,
0.03],
<span class=
"s9">'sin'
</span>);
</p>
145 <p class=
"p14">w =
<span class=
"s7">SCWindow
</span>(
<span class=
"s8">"Shards"</span>,
<span class=
"s7">Rect
</span>(
100,
100,
500,
400));
</p>
146 <p class=
"p14">v =
<span class=
"s7">SCEnvelopeEdit
</span>(w, w.view.bounds.resizeBy(-
20, -
200), e,
10).resize_(
2);
</p>
147 <p class=
"p14"><span class=
"s7">SCStaticText
</span>(w, v.bounds).string_(
<span class=
"s8">" amplitude"</span>).resize_(
2);
</p>
148 <p class=
"p14">x =
<span class=
"s7">SCEnvelopeEdit
</span>(w, v.bounds.moveBy(
0,
200), f,
10).resize_(
2);
</p>
149 <p class=
"p14"><span class=
"s7">SCStaticText
</span>(w, x.bounds).string_(
<span class=
"s8">" frequency"</span>).resize_(
2);
</p>
150 <p class=
"p14">w.front;
</p>
152 <p class=
"p13"><br></p>
154 <p class=
"p16"><span class=
"s7">SynthDef
</span><span class=
"s3">(
</span>"sineBlip"<span class=
"s3">, {
</span></p>
155 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"s7">arg
</span> freq=
440, vol=
0.1, la0, la1, la2, la3, la4, ta0, ta1, ta2, ta3, crva,
</p>
156 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>lf0, lf1, lf2, lf3, lf4, tf0, tf1, tf2, tf3, crvf;
</p>
157 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"s7">var
</span> signal, fenv, aenv;
</p>
158 <p class=
"p14"><span class=
"Apple-tab-span"> </span>fenv =
<span class=
"s7">EnvGen
</span>.ar(
<span class=
"s7">Env
</span>([lf0,lf1,lf2,lf3,lf4],[tf0,tf1,tf2,tf3], crvf));
</p>
159 <p class=
"p14"><span class=
"Apple-tab-span"> </span>aenv =
<span class=
"s7">EnvGen
</span>.ar(
<span class=
"s7">Env
</span>([la0,la1,la2,la3,la4],[ta0,ta1,ta2,ta3], crva), doneAction:
2);
</p>
160 <p class=
"p14"><span class=
"Apple-tab-span"> </span>signal =
<span class=
"s7">SinOsc
</span>.ar([freq, freq*
2] * fenv) * aenv * vol;
</p>
161 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"s7">Out
</span>.ar(
0, signal.dup);
</p>
162 <p class=
"p14">}).send(s);
</p>
164 <p class=
"p13"><br></p>
166 <p class=
"p17">Routine
<span class=
"s3">({
</span></p>
167 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"s7">var
</span> par, indices;
</p>
168 <p class=
"p14"><span class=
"Apple-tab-span"> </span>indices = (
2.
.21);
</p>
169 <p class=
"p14"><span class=
"Apple-tab-span"> </span>loop({
</p>
170 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>par = (indices +++ (v.env.levels ++ v.env.times ++ v.env.curves ++ x.env.levels ++ x.env.times ++ x.env.curves)).flatten;
</p>
171 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>s.sendBundle(s.latency, [
<span class=
"s9">\s_new
</span>,
<span class=
"s8">"sineBlip"</span>, -
1,
1,
1,
<span class=
"s9">\freq
</span>, exprand(
4e3,
11e3)] ++ par);
</p>
172 <p class=
"p14"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>0.04.wait;
</p>
173 <p class=
"p14"><span class=
"Apple-tab-span"> </span>});
</p>
174 <p class=
"p14">}).play;
</p>