Mercurial > hg > x
comparison fft.h @ 1:6422640a802f
first upload
author | Wen X <xue.wen@elec.qmul.ac.uk> |
---|---|
date | Tue, 05 Oct 2010 10:45:57 +0100 |
parents | |
children | 5f3c32dc6e17 |
comparison
equal
deleted
inserted
replaced
0:9b9f21935f24 | 1:6422640a802f |
---|---|
1 #ifndef fftH | |
2 #define fftH | |
3 | |
4 /* | |
5 fft.cpp - fast Fourier and cosine transforms | |
6 | |
7 Arguments of the function in this unit roughly follow the following rules: | |
8 Wid : size of transform | |
9 Order : log2(Wid) | |
10 W : FFT buffer: twiddle factors, standard size Wid/2 | |
11 X : FFT buffer: data buffer, standard size Wid | |
12 bitinv: FFT buffer: table of bit-inversed integers, standard size Wid | |
13 Window: window function, standard size Wid | |
14 spec : complex spectrogram | |
15 Amp : amplitude spectrogram | |
16 Arg : phase spectrogram | |
17 prefix h- : half-size | |
18 prefix q- : quarter-size | |
19 */ | |
20 | |
21 | |
22 #include <math.h> | |
23 #include "xcomplex.h" | |
24 #include "align8.h" | |
25 | |
26 //--------------------------------------------------------------------------- | |
27 /* | |
28 macro AllocateFFTBuffer: allocates FFT buffers X and W of given length with an extra LDATA buffer the | |
29 right size for hosting such arrays as the standard-size window function or output amplitude spectrum. | |
30 | |
31 This macro allocates buffer with 64-bit alignment, which must be freed with free8() or FreeFFTBuffer | |
32 macro. | |
33 */ | |
34 #define AllocateFFTBuffer(_WID, _LDATA, _W, _X) \ | |
35 double *_LDATA=(double*)malloc8(sizeof(double)*_WID*4); \ | |
36 cdouble *_X=(cdouble*)&_LDATA[_WID]; \ | |
37 cdouble *_W=(cdouble*)&_X[_WID]; \ | |
38 SetTwiddleFactors(_WID, _W); | |
39 #define FreeFFTBuffer(_LDATA) free8(_LDATA); | |
40 | |
41 //--compelx FFT and IFFT----------------------------------------------------- | |
42 void CFFTCbii(int Order, cdouble* W, cdouble* X); //complex FFT subroutine after bit-inversed ordering | |
43 void CFFTC(int Order, cdouble* W, cdouble* X, int* bitinv=0); //complex FFT, compact in-place | |
44 void CFFTC(cdouble* Input, double* Amp, double *Arg, int Order, cdouble* W, cdouble* X, int* bitinv=0); //complex FFT | |
45 void CFFTCW(double* Window, int Order, cdouble* W, cdouble* X, int* bitinv=0); //complex FFT with window, compact in-place | |
46 void CFFTCW(cdouble* Input, double* Window, double *Amp, double *Arg, int Order, cdouble* W, cdouble* X, int* bitinv=0); //complex FFT with window | |
47 void CIFFTC(int Order, cdouble* W, cdouble* X, int* bitinv=0); //complex IFFT, compact in-place | |
48 void CIFFTC(cdouble* Input, int Order, cdouble* W, cdouble* X, int* bitinv=0); //complex IFFT | |
49 | |
50 //--real FFT and IFFT-------------------------------------------------------- | |
51 void RFFTC_ual(double* Input, double* Amp, double* Arg, int Order, cdouble* W, cdouble* X, int* hbitinv=0); //real-to-complex FFT | |
52 void RFFTC_ual_old(double* Input, double *Amp, double *Arg, int Order, cdouble* W, double* XR, double* XI, int* bitinv=0); //depreciated | |
53 void RFFTCW(double* Input, double* Window, double *Amp, double *Arg, int Order, cdouble* W, cdouble* X, int* hbitinv=0); //real-to-complex FFT with window, double-type input | |
54 void RFFTCW(__int16* Input, double* Window, double *Amp, double *Arg, int Order, cdouble* W, cdouble* X, int* hbitinv=0); //real-to-complex FFT with window, __int16 input | |
55 void CIFFTR(cdouble* Input, int Order, cdouble* W, double* X, int* hbitinv=0); //complex-to-real IFFT | |
56 | |
57 /* | |
58 macro RFFTC: was defined as RFFTC_ual (literally "unaligned RFFTC") enveloped by ALIGN8(). However, as | |
59 ALIGN8() is currently disabled for lack of compiler support, RFFTC is equivalent to RFFTC_ual. | |
60 */ | |
61 #define RFFTC(Input, Amp, Arg, Order, W, X, hbitinv) RFFTC_ual(Input, Amp, Arg, Order, W, X, hbitinv); | |
62 | |
63 //--MFT---------------------------------------------------------------------- | |
64 void CMFTC(double* xR, double* xI, int Order, cdouble** X, cdouble* W); //complex fast multiresolution FT | |
65 | |
66 //--DCT and IDCT------------------------------------------------------------- | |
67 void RDCT1(double* Input, double* Output, int Order, cdouble* qW, cdouble* qX, int* qbitinv=0); //DCT1 | |
68 void RDCT4(double* Input, double* Output, int Order, cdouble* hW, cdouble* hX, int* hbitinv=0); //DCT4 | |
69 void RIDCT1(double* Input, double* Output, int Order, cdouble* qW, cdouble* qX, int* qbitinv=0); //IDCT1 | |
70 void RIDCT4(double* Input, double* Output, int Order, cdouble* hW, cdouble* hX, int* hbitinv=0); //IDCT4 | |
71 | |
72 //--LCT---------------------------------------------------------------------- | |
73 void RLCT(double** spec, double* data, int Count, int Order, int wid, double* g); //local cosine transform | |
74 void RILCT(double* data, double** spec, int Fr, int Order, int wid, double* g); //inverse local cosine transform | |
75 | |
76 //--tools-------------------------------------------------------------------- | |
77 double Atan2(double, double); | |
78 int* CreateBitInvTable(int Order); //creates table of bit-inversed integers | |
79 void SetTwiddleFactors(int N, cdouble* w); //set twiddle factors | |
80 | |
81 | |
82 #endif |