2 summary:: Fast Fourier Transform
3 related:: Classes/IFFT, Guides/FFT-Overview
8 The fast fourier transform analyzes the frequency content of a signal, which can be useful for audio analysis or for frequency-domain sound processing (phase vocoder).
15 A buffer to store spectral data. The buffer's size must
16 correspond to a power of 2. LocalBuf is useful here, because processes should not share data between synths. (Note: most PV UGens operate on this data in place. Use PV_Copy for parallel processing.)
19 The signal to be analyzed. The signal's rate determines the rate at which the input is read.
22 The amount of offset from one FFT analysis frame to the next, measured in multiples of the analysis frame size. This can range between zero and one, and the default is 0.5 (meaning each frame has a 50% overlap with the preceding/following frames).
25 Defines how the data is windowed:
27 ## -1 || strong::rectangular:: windowing, simple but typically not recommended;
28 ## 0 || (the default) strong::Sine:: windowing, typically recommended for phase-vocoder work;
29 ## 1 || strong::Hann:: windowing, typically recommended for analysis work.
33 A simple control allowing FFT analysis to be active (>0) or inactive (<=0). This is mainly useful for signal analysis processes which are only intended to analyse at specific times rather than continuously
36 The windowed audio frames are usually the same size as the buffer. If you wish the FFT to be zero-padded then you can specify a window size smaller than the actual buffer size (e.g. window size 1024 with buffer size 2048). Both values must still be a power of two. Leave this at its default of zero for no zero-padding.
42 Only the first two arguments are required. The remaining arguments allow for custom FFT analyses for specialised situations.
44 FFT uses a local buffer for holding the buffered audio. The buffer size must be a multiple of the control block size as well as being a power of two.
46 Note that for phase-vocoder usage, changing the hop or wintype settings from their defaults will typically result in unnatural sound when used in combination with IFFT, due to windowing artifacts. (A hop of 0.25, with Hann windowing, can be a useful combination for phase-vocoder work.)
52 s = Server.local.boot;
54 b = Buffer.alloc(s,2048,1);
57 SynthDef("help-noopFFT", { arg out=0,bufnum=0;
59 in = WhiteNoise.ar(0.01);
60 chain = FFT(bufnum, in);
61 chain.inspect; // its an FFT
63 IFFT(chain) // inverse FFT
65 }).play(s,[\out,0,\bufnum,b.bufnum]);
69 SynthDef("help-sineFFT", { arg out=0,bufnum=0;
71 in = SinOsc.ar(SinOsc.kr(SinOsc.kr(0.08,0,6,6.2).squared, 0, 100,800));
72 chain = FFT(bufnum, in);
73 Out.ar(out, IFFT(chain));
74 }).play(s,[\out,0,\bufnum,b.bufnum]);
78 SynthDef("help-magAbove", { arg out=0,bufnum=0;
80 in = SinOsc.ar(SinOsc.kr(SinOsc.kr(0.08,0,6,6.2).squared, 0, 100,800));
81 //in = WhiteNoise.ar(0.2);
82 chain = FFT(bufnum, in);
83 chain = PV_MagAbove(chain, 310);
84 Out.ar(out, 0.5 * IFFT(chain));
85 }).play(s,[\out,0,\bufnum,b.bufnum]);
89 SynthDef("help-brick", { arg out=0,bufnum=0;
91 in = {WhiteNoise.ar(0.2)}.dup;
92 chain = FFT(bufnum, in);
93 chain = PV_BrickWall(chain, SinOsc.kr(0.1));
94 Out.ar(out, IFFT(chain));
95 }).play(s,[\out,0,\bufnum,b.bufnum]);
99 SynthDef("help-randcomb", { arg out=0,bufnum=0;
101 in = {WhiteNoise.ar(0.8)}.dup;
102 chain = FFT(bufnum, in);
103 chain = PV_RandComb(chain, 0.95, Impulse.kr(0.4));
104 Out.ar(out, IFFT(chain));
105 }).play(s,[\out,0,\bufnum,b.bufnum]);
109 SynthDef("help-rectcomb", { arg out=0,bufnum=0;
111 in = {WhiteNoise.ar(0.2)}.dup;
112 chain = FFT(bufnum, in);
113 chain = PV_RectComb(chain, 8, LFTri.kr(0.097,0,0.4,0.5),
114 LFTri.kr(0.24,0,-0.5,0.5));
115 Out.ar(out, IFFT(chain));
116 }).play(s,[\out,0,\bufnum,b.bufnum]);
120 SynthDef("help-magFreeze", { arg out=0,bufnum=0;
122 in = SinOsc.ar(LFNoise1.kr(5.2,250,400));
123 chain = FFT(bufnum, in);
124 // moves in and out of freeze
125 chain = PV_MagFreeze(chain, SinOsc.kr(0.2) );
126 Out.ar(out, 0.5 * IFFT(chain));
127 }).play(s,[\out,0,\bufnum,b.bufnum]);