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.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: 9.0px Monaco
; min-height: 12.0px}
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: 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 85.0px; text-indent: -85.0px; font: 12.0px Helvetica
; min-height: 14.0px}
20 p
.p11
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #000000}
21 p
.p12
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #606060}
22 p
.p13
{margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica
; min-height: 17.0px}
23 p
.p14
{margin: 0.0px 0.0px 0.0px 57.0px; text-indent: -57.0px; font: 14.0px Helvetica
}
24 p
.p15
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #000000; min-height: 12.0px}
25 p
.p16
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #bf0000}
26 p
.p17
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #007300}
27 p
.p18
{margin: 0.0px 0.0px 0.0px 0.0px; font: 9.0px Monaco
; color: #0000bf}
28 span
.s1
{font: 18.0px Helvetica
}
29 span
.s2
{color: #0000ff}
30 span
.s3
{color: #1235e8}
31 span
.s4
{text-decoration: underline
}
32 span
.s5
{color: #56682c}
33 span
.s6
{color: #6f7178}
34 span
.s7
{color: #000000}
35 span
.s8
{color: #0000bf}
36 span
.s9
{color: #606060}
37 span
.s10
{font: 14.0px Helvetica
}
38 span
.s11
{color: #007300}
39 span
.s12
{color: #bf0000}
40 span
.Apple-tab-span
{white-space:pre
}
44 <p class=
"p1"><span class=
"s1"><b>SCQuartzComposerView
<span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b></span><b>view for rendering Quartz Composer Compositions
</b><span class=
"s1"><b><span class=
"Apple-tab-span"> </span></b></span></p>
45 <p class=
"p2"><br></p>
46 <p class=
"p1"><b>Inherits from:
</b><a href=
"../../../Core/Object.html"><span class=
"s2"><b>Object
</b></span></a><b> :
</b><a href=
"../SCView.html"><span class=
"s2"><b>SCView
</b></span></a></p>
47 <p class=
"p3"><br></p>
48 <p class=
"p1">SCQuartzComposerView allows for the rendering of Quartz Composer Compositions within the standard OSX SC GUI system. Quartz Composer is a visual programming environment for processing and rendering graphical data, which is distributed free of charge as part of Apple's XCode Development Tools. QC is highly optimised to work with the OSX graphics system, and in general should be more efficient than
<a href=
"../../Main-GUI/Pen.html"><span class=
"s3">Pen
</span></a>. For more information on QC see:
<span class=
"s4">http://developer.apple.com/documentation/GraphicsImaging/Conceptual/QuartzComposer/index.html
</span></p>
49 <p class=
"p3"><br></p>
50 <p class=
"p1">You can access input and output ports using the methods
<b>setInputValue
</b>,
<b>getInputValue
</b> and
<b>getOutputValue
</b>, or (do to a slight of hand in the implementation, using the port keys as getters and setters directly. The following two lines of code are thus equivalent:
</p>
51 <p class=
"p2"><br></p>
52 <p class=
"p4">myQCView.setInputValue(
<span class=
"s5">\valueIn
</span>,
1);
</p>
53 <p class=
"p4">myQCView.valueIn =
1;
</p>
54 <p class=
"p3"><br></p>
55 <p class=
"p3"><br></p>
56 <p class=
"p5"><b>Creation / Class Methods
</b></p>
57 <p class=
"p6"><br></p>
58 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>*new (parent, bounds)
</b></p>
59 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
60 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>parent
</b>-
</span>The parent view.
</p>
61 <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=
"s6">Rect
</span></a>,
</span>or
</span>a
<a href=
"../../../Geometry/Point.html"><span class=
"s6">Point
</span></a> indicating width@height.
</p>
62 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
63 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>(
</p>
64 <p class=
"p12"><span class=
"s7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>w =
</span><span class=
"s8">SCWindow
</span><span class=
"s7">(
</span>"Simple QC Test"<span class=
"s7">).front;
</span></p>
65 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>b =
<span class=
"s8">SCButton
</span>(w,
<span class=
"s8">Rect
</span>(
0,
0,
150,
20))
</p>
66 <p class=
"p12"><span class=
"s7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>.states_([[
</span>"pick another QC file"<span class=
"s7">]])
</span></p>
67 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>.action_({
<span class=
"s8">File
</span>.openDialog(
<span class=
"s9">""</span>, {
<span class=
"s8">|path|
</span> m.path_(path) }) });
</p>
68 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>m =
<span class=
"s8">SCQuartzComposerView
</span>(w,
<span class=
"s8">Rect
</span>(
0,
20,
400,
260));
</p>
69 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>m.path =
<span class=
"s8">Document
</span>.current.path.dirname ++
<span class=
"s9">"/Cells.qtz"</span>;
</p>
70 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>)
</p>
71 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>m.start;
</p>
72 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>m.stop;
</p>
73 <p class=
"p3"><br></p>
74 <p class=
"p5"><b>Instance Methods
</b></p>
75 <p class=
"p13"><b></b><br></p>
76 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>path
</b></p>
77 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>path_ (argpath)
</b></p>
78 <p class=
"p8"><b><span class=
"Apple-tab-span"> </span></b></p>
79 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Returns the path of the currently loaded composition as a
<a href=
"../../../Collections/String.html"><span class=
"s2">String
</span></a>, or loads a new QC composition from the file at the location specified by the String
<b>argpath
</b>.
</p>
80 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>argpath
</b>- A file path as a
<a href=
"../../../Collections/String.html"><span class=
"s2">String
</span></a>.
</p>
81 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
82 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>inputKeys
</b></p>
83 <p class=
"p8"><b><span class=
"Apple-tab-span"> </span></b></p>
84 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span></b><span class=
"Apple-tab-span"> </span>Returns an Array of Symbols corresponding to the keys of the currently loaded composition's input ports.
</p>
85 <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>
86 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>outputKeys
</b></p>
87 <p class=
"p8"><b><span class=
"Apple-tab-span"> </span></b><span class=
"Apple-tab-span"> </span></p>
88 <p class=
"p7"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span>Returns an Array of Symbols corresponding to the keys of the currently loaded composition's output ports.
<span class=
"Apple-tab-span"> </span></p>
89 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
90 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>start
</b></p>
91 <p class=
"p8"><b><span class=
"Apple-tab-span"> </span></b></p>
92 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Start rendering the loaded composition.
</p>
93 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
94 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>stop
</b></p>
95 <p class=
"p8"><b><span class=
"Apple-tab-span"> </span></b></p>
96 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Stop rendering the loaded composition.
</p>
97 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
98 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>setInputValue (key, value)
</b></p>
99 <p class=
"p8"><b><span class=
"Apple-tab-span"> </span></b></p>
100 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Set the value of an input port at key.
</span></p>
101 <p class=
"p8"><br></p>
102 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>key
</b>- A String or Symbol matching the port's key.
</p>
103 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>value
</b>- The type of value must correspond to the type of the port, but Floats, Integers, and Booleans are converted if needed. (true =
1, false =
0)
</p>
104 <p class=
"p8"><br></p>
105 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>getInputValue (key)
</b></p>
106 <p class=
"p8"><b><span class=
"Apple-tab-span"> </span></b></p>
107 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Get the current value of an input port. The type of object returned will correspond to the port's type.
</p>
108 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>key
</b>- A String or Symbol matching the port's key.
</p>
109 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
110 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>getOutputValue (key)
</b></p>
111 <p class=
"p8"><b><span class=
"Apple-tab-span"> </span></b></p>
112 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Get the current value of an output port. The type of object returned will correspond to the port's type.
</p>
113 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>key
</b>- A String or Symbol matching the port's key.
</p>
114 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
115 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>maxFPS_ (rate)
</b></p>
116 <p class=
"p8"><b><span class=
"Apple-tab-span"> </span></b></p>
117 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Set the maximum frames per second at which the composition will render.
</p>
118 <p class=
"p9"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span><b>rate
</b>- A value of
0 indicates no limit.
</p>
119 <p class=
"p10"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
120 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>openInQC
</b></p>
121 <p class=
"p8"><b><span class=
"Apple-tab-span"> </span></b></p>
122 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></b>Open the currently loaded composition in Quartz Composer. You will need to reload the composition into the view before any saved changes take effect.
</p>
123 <p class=
"p8"><span class=
"Apple-tab-span"> </span><span class=
"Apple-tab-span"> </span></p>
124 <p class=
"p14"><b>Subclassing and Internal Methods
</span></b></p>
125 <p class=
"p7"><span class=
"s10"><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.
</span></p>
126 <p class=
"p6"><br></p>
127 <p class=
"p7"><b><span class=
"Apple-tab-span"> </span>doesNotUnderstand (selector, args)
</b></p>
128 <p class=
"p6"><br></p>
129 <p class=
"p14"><b>Examples
</b></p>
130 <p class=
"p15"><br></p>
131 <p class=
"p15"><br></p>
132 <p class=
"p16">////////// Simple example
</p>
134 <p class=
"p12"><span class=
"s7">w =
</span><span class=
"s8">SCWindow
</span><span class=
"s7">(
</span>"Simple QC Test"<span class=
"s7">).front;
</span></p>
135 <p class=
"p11">b =
<span class=
"s8">SCButton
</span>(w,
<span class=
"s8">Rect
</span>(
0,
0,
150,
20))
</p>
136 <p class=
"p12"><span class=
"s7"><span class=
"Apple-tab-span"> </span>.states_([[
</span>"pick another QC file"<span class=
"s7">]])
</span></p>
137 <p class=
"p11"><span class=
"Apple-tab-span"> </span>.action_({
<span class=
"s8">File
</span>.openDialog(
<span class=
"s9">""</span>, {
<span class=
"s8">|path|
</span> m.path_(path) }) });
</p>
138 <p class=
"p11">m =
<span class=
"s8">SCQuartzComposerView
</span>(w,
<span class=
"s8">Rect
</span>(
0,
20,
400,
260));
</p>
139 <p class=
"p11">m.path =
<span class=
"s8">Document
</span>.current.path.dirname ++
<span class=
"s9">"/Cells.qtz"</span>;
</p>
141 <p class=
"p11">m.start;
</p>
142 <p class=
"p11">m.stop;
</p>
143 <p class=
"p15"><br></p>
144 <p class=
"p16">////////// Set and get inputs and outputs
</p>
146 <p class=
"p11">w =
<span class=
"s8">SCWindow
</span>(
<span class=
"s9">"SCTV"</span>).front;
</p>
147 <p class=
"p11">m =
<span class=
"s8">SCQuartzComposerView
</span>(w,
<span class=
"s8">Rect
</span>(
0,
20,
400,
260));
</p>
148 <p class=
"p11">m.path =
<span class=
"s8">Document
</span>.current.path.dirname ++
<span class=
"s9">"/SCQuartzComposerViewTest.qtz"</span>;
</p>
149 <p class=
"p11">m.start;
</p>
151 <p class=
"p15"><br></p>
152 <p class=
"p16">// get the names of input and output keys
</p>
153 <p class=
"p11">m.inputKeys;
</p>
154 <p class=
"p11">m.outputKeys;
</p>
155 <p class=
"p16"><span class=
"s7">m.openInQC;
</span>// you can see the published inputs and outputs in the composition
</p>
156 <p class=
"p15"><br></p>
157 <p class=
"p16">// You can access input and output ports using setInputValue, getInputValue and getOutputValue
</p>
158 <p class=
"p16">// or directly using the keys as getters and setters
</p>
159 <p class=
"p11">m.setInputValue(
<span class=
"s11">\direction
</span>,
1);
</p>
160 <p class=
"p11">m.direction =
0;
</p>
161 <p class=
"p11">m.direction;
</p>
162 <p class=
"p16"><span class=
"s7">m.fontSize;
</span>// font size in QC Units
</p>
163 <p class=
"p11">m.fontSize_(
0.1);
</p>
164 <p class=
"p15"><br></p>
165 <p class=
"p11">m.string_(
<span class=
"s9">"SCTV"</span>).fontName_(
<span class=
"s9">"Courier"</span>);
</p>
166 <p class=
"p11">m.startColor_(
<span class=
"s8">Color
</span>.green);
</p>
167 <p class=
"p11">m.billboardEnable_(
<span class=
"s8">false
</span>);
</p>
168 <p class=
"p11">m.billboardEnable_(
<span class=
"s8">true
</span>);
</p>
169 <p class=
"p11">m.maxFPS_(
5.0);
</p>
170 <p class=
"p11">m.maxFPS_(
10);
</p>
171 <p class=
"p11">m.maxFPS_(
0.0);
<span class=
"s12">// no max
</span></p>
172 <p class=
"p15"><br></p>
173 <p class=
"p16"><span class=
"s7">m.getOutputValue(
</span><span class=
"s11">\interpResult
</span><span class=
"s7">);
</span>// current rotation of the text in degrees
</p>
174 <p class=
"p11">m.interpResult;
</p>
175 <p class=
"p16"><span class=
"s7">m.systemTime;
</span>// current System Time published in the composition
</p>
176 <p class=
"p16"><span class=
"s7">m.endColor.class;
</span>// yup, it's a SC Color object
</p>
177 <p class=
"p11">m.endColor ==
<span class=
"s8">Color
</span>.white;
</p>
178 <p class=
"p15"><br></p>
180 <p class=
"p16">// probably more efficient to do this in QC, but...
</p>
182 <p class=
"p11">c =
<span class=
"s8">Color
</span>.blue;
</p>
183 <p class=
"p11">100.do({ m.startColor_(c = c.vary(
1));
0.1.wait; });
</p>
184 <p class=
"p11">}.fork(
<span class=
"s8">AppClock
</span>);
</p>
186 <p class=
"p15"><br></p>
187 <p class=
"p11">m.bounds =
<span class=
"s8">Rect
</span>(
100,
20,
200,
260);
</p>
188 <p class=
"p15"><br></p>
189 <p class=
"p11">m.stop;
</p>
190 <p class=
"p15"><br></p>
191 <p class=
"p16">///////////// Fullscreen
</p>
192 <p class=
"p15"><br></p>
194 <p class=
"p11">w =
<span class=
"s8">SCWindow
</span>(
<span class=
"s9">"SCTV"</span>,
<span class=
"s8">Rect
</span>(
0,
0,
360,
280), border:
<span class=
"s8">false
</span>).front;
</p>
195 <p class=
"p11">b =
<span class=
"s8">SCButton
</span>(w,
<span class=
"s8">Rect
</span>(
0,
0,
150,
20))
</p>
196 <p class=
"p11"><span class=
"Apple-tab-span"> </span>.states_([[
<span class=
"s9">"Close Me"</span>]])
</p>
197 <p class=
"p11"><span class=
"Apple-tab-span"> </span>.action_({w.close});
</p>
198 <p class=
"p11">m =
<span class=
"s8">SCQuartzComposerView
</span>(w,
<span class=
"s8">Rect
</span>(
0,
20,
360,
260));
</p>
199 <p class=
"p11">m.path =
<span class=
"s8">Document
</span>.current.path.dirname ++
<span class=
"s9">"/SCQuartzComposerViewTest.qtz"</span>;
</p>
200 <p class=
"p15"><br></p>
201 <p class=
"p11">m.resize =
5;
</p>
202 <p class=
"p11">m.start;
</p>
204 <p class=
"p15"><br></p>
205 <p class=
"p11">w.fullScreen;
</p>
206 <p class=
"p15"><br></p>
207 <p class=
"p15"><br></p>
208 <p class=
"p16">////////// Structure test
</p>
210 <p class=
"p11">w =
<span class=
"s8">SCWindow
</span>(
<span class=
"s9">"SCTV"</span>).front;
</p>
211 <p class=
"p11">m =
<span class=
"s8">SCQuartzComposerView
</span>(w,
<span class=
"s8">Rect
</span>(
0,
20,
400,
260));
</p>
212 <p class=
"p12"><span class=
"s7">m.path =
</span><span class=
"s8">Document
</span><span class=
"s7">.current.path.dirname ++
</span>"/SCQuartzComposerViewStructureTest.qtz"<span class=
"s7">;
</span></p>
213 <p class=
"p11">m.start;
</p>
215 <p class=
"p15"><br></p>
216 <p class=
"p11">m.inputKeys;
</p>
217 <p class=
"p11">m.outputKeys;
</p>
218 <p class=
"p16"><span class=
"s7">m.openInQC;
</span>// Take a look at the various inputs and outputs. Select and mouseover for key names.
</p>
219 <p class=
"p15"><br></p>
220 <p class=
"p16">// set several parameters at once
</p>
221 <p class=
"p16">// [background color, num copies, scale, string, [font size in QC units, font]]
</p>
222 <p class=
"p11">m.structure = [
<span class=
"s8">Color
</span>.red,
4,
1.5,
<span class=
"s9">"Hello"</span>, [
0.2,
<span class=
"s9">"Courier"</span>]];
</p>
223 <p class=
"p11">m.structure = [
<span class=
"s8">Color
</span>.red,
3,
1.5,
<span class=
"s9">"World"</span>, [
0.4,
<span class=
"s9">"Arial"</span>]];
</p>
224 <p class=
"p11">m.structure = [
<span class=
"s8">Color
</span>.red,
4,
0.1,
<span class=
"s9">"!!"</span>, [
0.7,
<span class=
"s9">"Times"</span>]];
</p>
225 <p class=
"p11">m.structure = [
<span class=
"s8">Color
</span>.black,
4,
0.1,
<span class=
"s9">"!!!"</span>, [
0.6,
<span class=
"s9">"Courier"</span>]];
</p>
226 <p class=
"p11">m.dictStructure =
<span class=
"s8">IdentityDictionary
</span>[
<span class=
"s11">\x
</span>-
>(-
0.4),
<span class=
"s11">\y
</span>-
>0.4];
</p>
227 <p class=
"p15"><br></p>
228 <p class=
"p16">// get stuff out
</p>
229 <p class=
"p16">// QCView stores all structures as instances of NSCFDictionary internally
</p>
230 <p class=
"p16">// so all structure outputs are instances of IdentityDictionary
</p>
231 <p class=
"p11">m.structure = [
<span class=
"s8">Color
</span>.blue,
4,
0.2,
<span class=
"s9">"Gruess Welt"</span>, [
0.12,
<span class=
"s9">"Zapfino"</span>]];
</p>
232 <p class=
"p16"><span class=
"s7">x = m.stringStruct;
</span>// separates the string into components
</p>
233 <p class=
"p17"><span class=
"s7">x[
</span>\component_1
<span class=
"s7">];
</span></p>
234 <p class=
"p15"><br></p>
235 <p class=
"p16">// pass something through
</p>
236 <p class=
"p11">m.arbStructIn = [
<span class=
"s9">"foo"</span>,
<span class=
"s9">"bar"</span>, [
<span class=
"s9">"foobar"</span>]];
<span class=
"s12">// array in
</span></p>
237 <p class=
"p16"><span class=
"s7">x = m.arbStructOut;
</span>// IdentDict out with Integer Symbols as keys
</p>
238 <p class=
"p11">x[\
0];
</p>
239 <p class=
"p11">x[\
2][\
0];
</p>
241 <p class=
"p16">// convert to array
</p>
242 <p class=
"p11">y =
<span class=
"s8">Array
</span>.newClear(x.size);
</p>
243 <p class=
"p11">x.keysValuesDo({
<span class=
"s8">|i, elem|
</span> y[i.asInteger] = elem});
</p>
244 <p class=
"p11">y.postln;
</p>
246 <p class=
"p15"><br></p>
247 <p class=
"p16">// use QC to concat the strings)
</p>
248 <p class=
"p11">m.stringConcatIn = [
<span class=
"s9">"foo"</span>,
<span class=
"s9">"bar"</span>];
<span class=
"s12">// array in
</span></p>
249 <p class=
"p11">x = m.stringConcatOut;
<span class=
"s12">// String Out
</span></p>
250 <p class=
"p15"><br></p>
251 <p class=
"p15"><br></p>
252 <p class=
"p16">////////// Control some audio: Stupid Pan Example
</p>
253 <p class=
"p15"><br></p>
255 <p class=
"p11">w =
<span class=
"s8">SCWindow
</span>(
<span class=
"s9">"Stupid Pan Example"</span>,
<span class=
"s8">Rect
</span>(
0,
20,
600,
150)).front;
</p>
256 <p class=
"p11">m =
<span class=
"s8">SCQuartzComposerView
</span>(w,
<span class=
"s8">Rect
</span>(
0,
20,
600,
100));
</p>
257 <p class=
"p11">m.path =
<span class=
"s8">Document
</span>.current.path.dirname ++
<span class=
"s9">"/Stupid Pan.qtz"</span>;
</p>
258 <p class=
"p11">m.resize =
5;
</p>
259 <p class=
"p11">m.start;
</p>
261 <p class=
"p15"><br></p>
262 <p class=
"p11">s.boot;
</p>
263 <p class=
"p16">// use mouse to set pan position
</p>
266 <p class=
"p11">loop({
</span></p>
267 <p class=
"p11">{
<span class=
"s8">Pan2
</span>.ar(
<span class=
"s8">Saw
</span>.ar(mul:
0.1) *
<span class=
"s8">EnvGen
</span>.ar(
<span class=
"s8">Env
</span>.perc, timeScale:
4, doneAction:
2), m.x_pos) }.play;
</span></p>
268 <p class=
"p11">1.wait;
</span></p>
269 <p class=
"p11">});
</p>
270 <p class=
"p11">}.fork(
<span class=
"s8">AppClock
</span>);
</p>
272 <p class=
"p15"><br></p>
273 <p class=
"p16">////////// Sonogram
</p>
274 <p class=
"p15"><br></p>
275 <p class=
"p16">// could be better optimised, but proves the concept
</p>
277 <p class=
"p11">w =
<span class=
"s8">SCWindow
</span>(
<span class=
"s9">"Sonogram"</span>,
<span class=
"s8">Rect
</span>(
0,
20,
600,
300)).front;
</p>
278 <p class=
"p11">m =
<span class=
"s8">SCQuartzComposerView
</span>(w,
<span class=
"s8">Rect
</span>(
0,
20,
600,
256));
</p>
279 <p class=
"p11">m.path =
<span class=
"s8">Document
</span>.current.path.dirname ++
<span class=
"s9">"/SCQCsonogramCount2.qtz"</span>;
</p>
280 <p class=
"p11">m.start;
</p>
281 <p class=
"p11">m.setInputValue(
<span class=
"s11">\framesPerView
</span>,
300);
</p>
282 <p class=
"p11">m.setInputValue(
<span class=
"s11">\magnitudes
</span>, (
0,
0.01.
.1));
</p>
284 <p class=
"p15"><br></p>
285 <p class=
"p11">s.boot;
</p>
286 <p class=
"p11">b =
<span class=
"s8">Buffer
</span>.alloc(s,
256);
</p>
288 <p class=
"p11">a = {
<span class=
"s8">FFT
</span>(b,
<span class=
"s8">LFSaw
</span>.ar(
4000));
0.0 }.play;
<span class=
"s12">// sawtooth
</span></p>
289 <p class=
"p15"><br></p>
290 <p class=
"p11">p =
0.25; i =
0;
</p>
291 <p class=
"p16">//m.setInputValue(\period, p);
</p>
292 <p class=
"p16">//m.maxFPS_(p.reciprocal *
2);
</p>
293 <p class=
"p11"><span class=
"s8">SystemClock
</span>.sched(
0.0, {
</p>
294 <p class=
"p11">b.getn(
0,
256, {
<span class=
"s8">arg
</span> buf;
</p>
295 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"s8">var
</span> z, x;
</p>
296 <p class=
"p11"><span class=
"Apple-tab-span"> </span>z = buf.clump(
2).flop;
</p>
297 <p class=
"p11"><span class=
"Apple-tab-span"> </span>z = [
<span class=
"s8">Signal
</span>.newFrom(z[
0]),
<span class=
"s8">Signal
</span>.newFrom(z[
1])];
</p>
298 <p class=
"p11"><span class=
"Apple-tab-span"> </span>x =
<span class=
"s8">Complex
</span>(z[
0], z[
1]);
</p>
299 <p class=
"p16"><span class=
"s7"><span class=
"Apple-tab-span"> </span></span>//{m.setInputValue(\magnitudes, x.magnitude.resamp1(m.bounds.height *
0.5));}.defer
</p>
300 <p class=
"p11"><span class=
"Apple-tab-span"> </span>{m.setInputValue(
<span class=
"s11">\magnitudes
</span>, x.magnitude *
0.025); m.setInputValue(
<span class=
"s11">\count
</span>, i);}.defer;
</p>
301 <p class=
"p11"><span class=
"Apple-tab-span"> </span>i = i +
1;
</p>
302 <p class=
"p11">}); p
</p>
303 <p class=
"p11">});
</p>
305 <p class=
"p15"><br></p>
306 <p class=
"p11">a.free;
</p>
307 <p class=
"p11">a = {
<span class=
"s8">FFT
</span>(b,
<span class=
"s8">Dust2
</span>.ar(
500) *
5);
0.0 }.play;
<span class=
"s12">// Impulses
</span></p>
308 <p class=
"p15"><br></p>
309 <p class=
"p11">a.free;
</p>
310 <p class=
"p12"><span class=
"s7">c =
</span><span class=
"s8">Buffer
</span><span class=
"s7">.read(s,
</span>"sounds/a11wlk01.wav"<span class=
"s7">);
</span></p>
312 <p class=
"p11">m.setInputValue(
<span class=
"s11">\framesPerView
</span>,
50);
</p>
313 <p class=
"p11">a = {
<span class=
"s8">var
</span> colum;
</p>
314 <p class=
"p11"><span class=
"Apple-tab-span"> </span>colum =
<span class=
"s8">PlayBuf
</span>.ar(
1, c,
<span class=
"s8">BufRateScale
</span>.kr(c) *
<span class=
"s8">Line
</span>.kr(
1,
3,
20), loop:
1);
</p>
315 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"s8">FFT
</span>(b, colum);
</span></p>
316 <p class=
"p11"><span class=
"Apple-tab-span"> </span>colum
</p>
317 <p class=
"p11">}.play;
</p>
319 <p class=
"p15"><br></p>
320 <p class=
"p16">///////////// Cheap Level Meter
</p>
322 <p class=
"p11">w =
<span class=
"s8">SCWindow
</span>(
<span class=
"s9">"Level Meters"</span>,
<span class=
"s8">Rect
</span>(
128,
64,
200,
400)).front;
</p>
323 <p class=
"p15"><br></p>
324 <p class=
"p11">m =
<span class=
"s8">SCQuartzComposerView
</span>(w,
<span class=
"s8">Rect
</span>(
20,
20,
50,
360));
</p>
325 <p class=
"p11">n =
<span class=
"s8">SCQuartzComposerView
</span>(w,
<span class=
"s8">Rect
</span>(
130,
20,
50,
360));
</p>
326 <p class=
"p11">m.path =
<span class=
"s8">Document
</span>.current.path.dirname ++
<span class=
"s9">"/SCLevelMeter.qtz"</span>;
</p>
327 <p class=
"p11">n.path =
<span class=
"s8">Document
</span>.current.path.dirname ++
<span class=
"s9">"/SCLevelMeter.qtz"</span>;
</p>
328 <p class=
"p11">m.maxFPS_(
20); n.maxFPS_(
20);
</p>
329 <p class=
"p11">m.start; n.start;
</p>
330 <p class=
"p11">~meters = [m, n];
</p>
332 <p class=
"p15"><br></p>
333 <p class=
"p11">s.boot;
</p>
334 <p class=
"p15"><br></p>
335 <p class=
"p16">// MouseX controls noise amp
</p>
337 <p class=
"p11">o =
<span class=
"s8">OSCresponder
</span>(s.addr,
<span class=
"s11">'/tr'
</span>, {
<span class=
"s8">arg
</span> time, resp, msg;
</p>
338 <p class=
"p11"><span class=
"Apple-tab-span"> </span>{~meters[msg[
2]].level = (msg[
3] +
0.01).explin(
0.01,
1.01,
0,
1);}.defer;
</p>
339 <p class=
"p11">}).add;
</p>
340 <p class=
"p12"><span class=
"s7">b =
</span><span class=
"s8">Buffer
</span><span class=
"s7">.read(s,
</span>"sounds/a11wlk01.wav"<span class=
"s7">);
<span class=
"Apple-tab-span"> </span></span></p>
341 <p class=
"p11">a = {
<span class=
"s8">var
</span> colum, noise, imp, delimp;
</p>
342 <p class=
"p11"><span class=
"Apple-tab-span"> </span>imp =
<span class=
"s8">Impulse
</span>.kr(
20);
</p>
343 <p class=
"p11"><span class=
"Apple-tab-span"> </span>delimp =
<span class=
"s8">Delay1
</span>.kr(imp);
</p>
344 <p class=
"p11"><span class=
"Apple-tab-span"> </span>colum =
<span class=
"s8">PlayBuf
</span>.ar(
1, b,
<span class=
"s8">BufRateScale
</span>.kr(b), loop:
1);
</p>
345 <p class=
"p11"><span class=
"Apple-tab-span"> </span>noise =
<span class=
"s8">PinkNoise
</span>.ar(
<span class=
"s8">MouseX
</span>.kr);
</p>
346 <p class=
"p16"><span class=
"s7"><span class=
"Apple-tab-span"> </span></span>// measure Peak
</p>
347 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"s8">SendTrig
</span>.kr(imp,
0,
<span class=
"s8">Peak
</span>.ar(colum, delimp));
</p>
348 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"s8">SendTrig
</span>.kr(imp,
1,
<span class=
"s8">Peak
</span>.ar(noise, delimp));
</p>
349 <p class=
"p11"><span class=
"Apple-tab-span"> </span>[colum, noise];
</p>
350 <p class=
"p11">}.play;
</p>
352 <p class=
"p15"><br></p>
353 <p class=
"p11">a.free;
</p>
354 <p class=
"p15"><br></p>
355 <p class=
"p15"><br></p>
356 <p class=
"p16">/// using an event type to control a QCView by patterns:
</p>
357 <p class=
"p15"><br></p>
358 <p class=
"p11"><span class=
"s8">Event
</span>.addEventType(
<span class=
"s11">\quartz
</span>, {
<span class=
"s8">|server|
</span></p>
359 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"s8">var
</span> latency = server.latency;
</p>
360 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"s8">var
</span> view = ~view.postln;
</p>
361 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"s8">var
</span> key = ~key, value = ~value;
</p>
362 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"s8">AppClock
</span>.sched(latency, { view.postln; view.setInputValue(key, value) });
</p>
363 <p class=
"p11">});
</p>
364 <p class=
"p15"><br></p>
365 <p class=
"p15"><br></p>
367 <p class=
"p11">w =
<span class=
"s8">SCWindow
</span>(
<span class=
"s9">"Level Meters"</span>,
<span class=
"s8">Rect
</span>(
128,
64,
200,
400)).front;
</p>
368 <p class=
"p15"><br></p>
369 <p class=
"p11">m =
<span class=
"s8">SCQuartzComposerView
</span>(w,
<span class=
"s8">Rect
</span>(
20,
20,
50,
360));
</p>
370 <p class=
"p12"><span class=
"s7">m.path =
</span>"Help/GUI/Cocoa-GUI/SCQuartzComposerView/SCLevelMeter.qtz"<span class=
"s7">.standardizePath;
</span></p>
371 <p class=
"p11">m.maxFPS_(
20);
</p>
372 <p class=
"p11">m.start;
</p>
374 <p class=
"p15"><br></p>
376 <p class=
"p18">Pbind
<span class=
"s7">(
</span></p>
377 <p class=
"p17"><span class=
"s7"><span class=
"Apple-tab-span"> </span></span>\type
<span class=
"s7">,
</span>\quartz
<span class=
"s7">,
</span></p>
378 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"s11">\view
</span>, m,
</p>
379 <p class=
"p17"><span class=
"s7"><span class=
"Apple-tab-span"> </span></span>\key
<span class=
"s7">,
</span>\level
<span class=
"s7">,
</span></p>
380 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"s11">\value
</span>,
<span class=
"s8">Pwhite
</span>(
0,
1.0,
<span class=
"s8">inf
</span>).explin(
0.01,
1.01,
0,
1),
</p>
381 <p class=
"p11"><span class=
"Apple-tab-span"> </span><span class=
"s11">\dur
</span>,
0.1</p>
382 <p class=
"p11">).play;
</p>
384 <p class=
"p15"><br></p>
385 <p class=
"p11">m.setInputValue(
<span class=
"s11">\level
</span>,
0.5);
</p>