File: Unpack1FFT.schelp

package info (click to toggle)
supercollider 1%3A3.11.2%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 71,152 kB
  • sloc: cpp: 387,846; lisp: 80,328; ansic: 76,515; sh: 22,779; python: 7,932; makefile: 2,333; perl: 1,123; javascript: 915; java: 677; xml: 582; yacc: 314; lex: 175; objc: 152; ruby: 136
file content (52 lines) | stat: -rw-r--r-- 1,677 bytes parent folder | download | duplicates (4)
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
class:: Unpack1FFT
summary:: Unpack a single value (magnitude or phase) from an FFT chain
categories:: UGens>FFT, UGens>Demand
related:: Classes/PackFFT, Classes/UnpackFFT, Guides/FFT-Overview


Unpack1FFT(chain, bufsize, binindex, whichmeasure=0)

description::
Takes an FFT chain and extracts a single scalar value as a demand-rate stream. To call it, a "demander" is needed, which fires whenever the FFT chain fires - this is normally achieved using link::Classes/PackFFT:: but can also be done using link::Classes/Demand::.

Note::
This UGen is commonly not used directly. Its main purpose is as a component in link::Classes/PV_ChainUGen#-pvcollect::, link::Classes/PV_ChainUGen#-pvcalc::, and link::Classes/PV_ChainUGen#-pvcalc2:: processes. You're welcome to use it on its own - the example below shows how.
::

classmethods::
private:: categories

method:: new

argument:: chain
an FFT chain
argument:: bufsize
the size of the expected input FFT frames
argument:: binindex
the integer index of the bin you want to query
argument:: whichmeasure
0 for magnitude and 1 for phase. None of these arguments can be modulated.

discussion::
code::

// Let's extract the DC component - i.e. the magnitude at binindex zero.
(
{
	var sig, chain, stream, windowStarts, demand;
	var fftsize = 1024;

	sig = SinOsc.ar(LFDNoise3.kr(LFNoise0.kr(1) * 40 + 60) * 700 + 800);

	chain = FFT(LocalBuf(fftsize), sig);
	stream = Unpack1FFT(chain, bufsize: fftsize, binindex: 0, whichmeasure: 0);

	// each time an FFT window starts, the unpacker returns a new value
	windowStarts = chain > -1;
	demand = Demand.kr(windowStarts, 0, stream);
	demand.poll(windowStarts);

	sig * 0.05
}.play
)
::