-
Notifications
You must be signed in to change notification settings - Fork 731
/
ScopeExample.rtf
73 lines (72 loc) · 2.84 KB
/
ScopeExample.rtf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf440
{\fonttbl\f0\fnil\fcharset77 Monaco;}
{\colortbl;\red255\green255\blue255;\red191\green0\blue0;\red0\green0\blue0;\red0\green0\blue191;
\red0\green115\blue0;\red96\green96\blue96;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural
\f0\fs18 \cf2 // thor magnusson (2007)\cf3 \
\
\cf2 // Example showing how SCScope can be used in a UI\cf3 \
\
\cf4 GUI\cf3 .cocoa; \cf2 // use Mac OS X native GUI\cf3 \
\cf4 GUI\cf3 .swing; \cf2 // use Java GUI\cf3 \
\
(\
s = \cf4 GUI\cf3 .stethoscope.defaultServer;\
s.waitForBoot(\{\
\cf4 var\cf3 sc;\
b = \cf4 Buffer\cf3 .alloc(s,2048,2);\
a = \cf4 SynthDef\cf3 (\cf5 \\scopeExample\cf3 , \{ \cf4 arg\cf3 freq=400, rate=2, amp=0.4, pan=0;\
\cf4 var\cf3 signal, scope;\
signal = [\cf4 LFSaw\cf3 .ar(freq, 0, amp/2)*\cf4 SinOsc\cf3 .ar(rate), \
\cf4 Pulse\cf3 .ar( freq, 0.51, amp)*\cf4 SinOsc\cf3 .ar(rate)];\
signal = \cf4 Balance2\cf3 .ar(signal[0], signal[1], pan);\
scope = if( \cf4 GUI\cf3 .id === \cf5 \\cocoa\cf3 , \cf5 \\ScopeOut\cf3 , \cf5 \\JScopeOut\cf3 ).asClass;\
scope.ar( signal, b );\
\cf4 Out\cf3 .ar(0, signal);\
\}).play(s);\
\
w = \cf4 GUI\cf3 .window.new(\cf6 "scope in a gui"\cf3 , \cf4 Rect\cf3 (100, 400, 400, 300))\
.onClose_(\{a.free;\}) \cf2 // free synth on closing window\cf3 \
.front;\
\
\cf4 GUI\cf3 .multiSliderView.new(w, \cf4 Rect\cf3 (10, 10, 90, 120))\
.value_([0.4, 0.5, 0.6, 0.5])\
.indexIsHorizontal_(\cf4 false\cf3 )\
.isFilled_(\cf4 true\cf3 )\
.strokeColor_(\cf4 Color\cf3 .new255(10, 55, 10))\
.fillColor_(\cf4 Color\cf3 .new255(110, 155, 110).alpha_(0.6))\
.indexThumbSize_(26)\
.gap_(4)\
.valueThumbSize_(1)\
.action_(\{\cf4 |sl|\cf3 \
sl.index.switch\
\{0\} \{ a.set(\cf5 \\freq\cf3 , 400+(sl.value[sl.index]*400)) \}\
\{1\} \{ a.set(\cf5 \\rate\cf3 , (sl.value[sl.index]*10)) \}\
\{2\} \{ a.set(\cf5 \\amp\cf3 , sl.value[sl.index]) \}\
\{3\} \{ a.set(\cf5 \\pan\cf3 , (sl.value[sl.index]*2)-1) \};\
\});\
\
\cf4 GUI\cf3 .staticText.new(w, \cf4 Rect\cf3 (14, 4, 90, 30))\
.string_(\cf6 "Freq"\cf3 );\
\cf4 GUI\cf3 .staticText.new(w, \cf4 Rect\cf3 (14, 34, 90, 30))\
.string_(\cf6 "Rate"\cf3 );\
\cf4 GUI\cf3 .staticText.new(w, \cf4 Rect\cf3 (14, 64, 90, 30))\
.string_(\cf6 "Amp"\cf3 );\
\cf4 GUI\cf3 .staticText.new(w, \cf4 Rect\cf3 (14, 94, 90, 30))\
.string_(\cf6 "Pan"\cf3 );\
\
\cf4 GUI\cf3 .staticText.new(w, \cf4 Rect\cf3 (10, 140, 90, 16))\
.string_(\cf6 "xZoom:"\cf3 );\
\
\cf4 GUI\cf3 .slider.new(w, \cf4 Rect\cf3 (10, 160, 90, 24))\
.action_(\{\cf4 |sl|\cf3 sc.xZoom_(sl.value*4)\});\
\
sc = \cf4 GUI\cf3 .scopeView.new(w, \cf4 Rect\cf3 (120,10,260,260))\
.bufnum_(b.bufnum)\
.background_(\cf4 Color\cf3 .white)\
.resize_(5)\
.waveColors_([\cf4 Color\cf3 .black, \cf4 Color\cf3 .black]);\
\});\
)\
\
}