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 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
{\rtf1\mac\ansicpg10000\cocoartf102
{\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;\f1\fswiss\fcharset77 Helvetica;\f2\fnil\fcharset77 Monaco;
}
{\colortbl;\red255\green255\blue255;\red0\green0\blue0;\red191\green0\blue0;\red0\green0\blue191;
\red96\green96\blue96;\red0\green0\blue191;\red191\green0\blue0;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
\f0\b\fs36 \cf2 SCFreqScope frequency analysis view\
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
\fs24 \cf2 SCFreqScope.new(parent, bounds)\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
\f1\b0 \cf2 \
SCFreqScope shows the frequency spectrum of a specified audio bus. The scope will\
remain active after a command-period. To turn it off you must use the 'active' method.\
\
Public methods:\
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
\f0\b \cf2 kill()
\f1\b0 \
\f0\b Very important.
\f1\b0 This must be run when the parent window is closed to avoid problems.\
It also frees the buffers that the scope allocated and stops the FFT analysis synth.\
\
\f0\b active_(Boolean)
\f1\b0 \
Turns the scope on if true or off if false. When the scope is turned on for the first time,\
it will send SynthDefs to the internal server, allocate the FFT and scope buffers, and\
start the FFT analysis synth. After that, only the FFT synth will be turned on and off.\
\
\f0\b dbRange_(Integer)
\f1\b0 \
Determines the amplitude range. This sets the lowest negative decibel reading.\
\
\f0\b freqMode_(Integer)
\f1\b0 \
Can be either 0 or 1. 0 displays frequencies on a linear scale and 1 displays frequencies\
on a logarithmic or equally spaced octave scale.\
\
\f0\b inBus_(Integer)
\f1\b0 \
Change the bus number to analyze.\
\
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
\f2\fs18 \cf3 // Start internal server\cf2 \
s = \cf4 Server\cf2 .internal.boot;\
\
\cf3 // Create analyzer in a window\cf2 \
(\
w = \cf4 SCWindow\cf2 (\cf5 "My Analyzer"\cf2 , \cf4 Rect\cf2 (0, 0, 511, 300)); \cf3 // width should be 511\cf2 \
f = \cf4 SCFreqScope\cf2 (w, w.view.bounds);\
f.active_(\cf4 true\cf2 ); \cf3 // turn it on the first time;\cf2 \
\
w.onClose_(\{ f.kill \}); \cf3 // you must have this\cf2 \
w.front;\
)\
\
\{ \cf4 SinOsc\cf2 .ar([500, 1000], 0, 0.25) \}.play(s); \cf3 // start two sine waves\cf2 \
\
f.freqMode_(1); \cf3 // change to log scale so we can see them\cf2 \
f.inBus_(1); \cf3 // look at bus 1\cf2 \
f.dbRange_(200); \cf3 // expand amplitude range\cf2 \
f.active_(\cf4 false\cf2 ); \cf3 // turn scope off (watch CPU)\cf2 \
f.active_(\cf4 true\cf2 ); \cf3 // turn it back on \cf2 \
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
\fs24 \cf2 \
Now press command-period. The scope is still running.\
\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
\fs18 \cf0 \{ \cf6 SinOsc\cf0 .ar([500, 1000], 0, 0.25) \}.play(s); \cf7 // start sines again
\fs24 \cf2 \
\
Close window and scope is killed.\
}
|