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
|
{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410
{\fonttbl\f0\fswiss\fcharset77 Helvetica-Bold;\f1\fnil\fcharset77 Monaco;\f2\fswiss\fcharset77 Helvetica;
}
{\colortbl;\red255\green255\blue255;\red0\green0\blue191;\red96\green96\blue96;\red0\green0\blue0;
\red191\green0\blue0;\red0\green0\blue191;\red96\green96\blue96;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
\f0\b\fs36 \cf0 FFTPower - Sum of instantaneous FFT magnitudes
\f1\b0\fs42 \
\f2\fs24 \
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
\f0\b \cf0 FFTPower.kr(chain)\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
\f2\b0 \cf0 \
Outputs a power measurement (sum of magnitudes) taken from an FFT chain. It can be used for similar purposes as the \ul [Amplitude]\ulnone UGen but has different characteristics since it operates on the frequency-domain rather than time-domain representation.\
\
The output is scaled by dividing by the number of bins. To scale the power (e.g.) to lie between 0 and 1, you'll need to find an empirical value that suits the application - note the multipliers used in the examples below.\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
\f1\fs22 \cf0 \
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural
\fs18 \cf0 \
s = \cf2 Server\cf0 .internal.boot; \
\
b = \cf2 Buffer\cf0 .alloc(s,2048,1);\
\
(\
\{\
\cf2 var\cf0 in, chain;\
in = \cf2 WhiteNoise\cf0 .ar(\cf2 MouseX\cf0 .kr(0,1));\
chain = \cf2 FFT\cf0 (b.bufnum, in);\
\cf2 Out\cf0 .ar(0, in * 0.1);\
\cf2 Out\cf0 .kr(0, (\cf2 FFTPower\cf0 .kr(chain) * 0.05955912289792).poll(
\fs20 \CocoaLigature0 label:\cf3 "Noise power"
\fs18 \cf0 \CocoaLigature1 ));\
\}.scope;\
)\
\
(\cf4 \
\{ \cf5 // Sine - note how the peak measured power changes with frequency\cf4 \
\cf6 var\cf4 in, chain;\
in = \cf6 SinOsc\cf4 .ar(\cf6 MouseY\cf4 .kr(100, 1000, 1), 0, \cf6 MouseX\cf4 .kr(0,1));\
chain = \cf6 FFT\cf4 (b.bufnum, in);\
\cf6 Out\cf4 .ar(0, in * 0.1);\
\cf6 Out\cf4 .kr(0, (
\fs20 \cf6 \CocoaLigature0 FFTPower\cf4 .kr(chain) * 0.66667).poll(label:\cf7 "Sine power"\cf4 )
\fs18 \CocoaLigature1 );\
\}.scope;\
\cf0 )}
|