2 summary:: Complex division
4 related:: Classes/PV_Mul, Classes/PV_MagDiv
15 In this example we estimate the transfer function of the LPF UGen. The transfer function is estimated by dividing the FFT of the output, by the FFT of the input, and looking at the magnitudes in the result.
20 b = Buffer.alloc(s, fftsize)
27 // Any input should theoretically be OK, white noise is a good choice
28 var son = WhiteNoise.ar;
29 // var son = Impulse.ar;
30 var out = LPF.ar(son, MouseX.kr(100, 10000, 1));
31 var fft1 = FFT(LocalBuf(b.numFrames), son, wintype: 1);
32 var fft2 = FFT(b, out, wintype: 1);
34 // As with most PV_ ugens, the result is *actually* stored in the first fft buf
35 var result = PV_Div(fft2, fft1);
37 Out.ar(0, out.dup * 0.1);
41 // Now we can grab the FFT buffer and peek at the magnitudes
46 b.loadToFloatArray(action: {|data| {
47 w.view.children.do(_.remove);
50 .collect {|a| (a[0].squared + a[1].squared)}
51 .collect {|a| if(a.isNaN){ 0.post }{ a } }