Refactoring of rec process "~" in faustexp.ml.
[Faustine.git] / dsp_files / fft2d.dsp
1 import ( "mrfaustlib/fft.lib" ) ;
2 import ( "mrfaustlib/complex.lib" ) ;
3
4 GREY_MAX = 256;
5
6 //fft2d(x,y) = vectorize(x) : vectorize(y) <: picks(n) : real2complex(n) : fft(n) : stops(n/2), pcplx_moduls(n/2) : modules_vector(n/2);
7 //fft2d(x,y) = vectorize(x) : vectorize(y) : fft(x) : fftc(y) : pcplx_moduls(y) : modules_vector(y);
8 //fft2d(x,y) = vectorize(x) : fft(x) : fftc(y) : pcplx_moduls(y) : modules_vector(y);
9
10 matricize(x, y) = vectorize(y) : vectorize(x);
11
12 ffts(n, m) = par(i, n, (fft(m) : nconcat(m)));
13
14 fftcs(n, m) = par(i, n, (fftc(m) : nconcat(m)));
15
16 lines_fft(n, m) = _ <: picks(n) : ffts(n, m) : nconcat(n);
17
18 lines_fftc(n, m) = _ <: picks(n) : fftcs(n, m) : nconcat(n);
19
20 take_column(n, m) = par(i, n, [m]) : nconcat(n);
21
22 matrix_transpose(n, m) = _ <: picks(n) <: par(i, m, take_column(n, i)) : nconcat(m);
23
24 matrix_pcplx2modul(n, m) = _ <: picks(n) : par(i, n, ( _ <: picks(m) : pcplx_moduls(m) : nconcat(m))) : nconcat(n);
25
26 matrix_real2pcplx(n, m) = _ <: picks(n) : par(i, n, ( _ <: picks(m) : real2pcplx(m) : nconcat(m))) : nconcat(n);
27
28 normalize(n) = _ , n : /;
29
30 unnormalize(n) = par(i, n, ( _ , GREY_MAX : *));
31
32 norm_out(n, m) = _ <: picks(n) : par(i, n, ( _ <: picks(m) : unnormalize(m) : nconcat(m))) : nconcat(n) : serialize;
33
34 output(n, m) = serialize;
35
36 //fft2d(x, y) = matricize(x, y) : lines_fft(x, y) : matrix_transpose(x, y) : lines_fftc(y, x) : matrix_transpose(y, x) : output(x, y);
37 //fft2d(x, y) = normalize(GREY_MAX) : matricize(x, y) : lines_fft(x, y) : matrix_transpose(x, y) : lines_fftc(y, x) : matrix_transpose(y, x) : norm_out(x, y);
38 //fft2d(x, y) = matricize(x, y) : matrix_real2pcplx(x, y) : matrix_pcplx2modul(x, y) : output(x, y);
39 //fft2d(x, y) = matricize(x, y) : output(x, y);
40 fft2d(x, y) = normalize(GREY_MAX) : matricize(x, y) : lines_fft(x, y) : matrix_transpose(x, y) : lines_fftc(y, x) : matrix_transpose(y, x) : norm_out(x, y);
41
42 //safer with x=y because tests and zero padding are still to implement
43 process = fft2d(32,32);
44