fft.h
Go to the documentation of this file.
1 /*
2  Harmonic sinusoidal modelling and tools
3 
4  C++ code package for harmonic sinusoidal modelling and relevant signal processing.
5  Centre for Digital Music, Queen Mary, University of London.
6  This file copyright 2011 Wen Xue.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version.
12 */
13 #ifndef fftH
14 #define fftH
15 
34 #include <math.h>
35 #include "xcomplex.h"
36 #include "align8.h"
37 
38 //---------------------------------------------------------------------------
46 #define AllocateFFTBuffer(_WID, _LDATA, _W, _X) \
47  double *_LDATA=(double*)malloc8(sizeof(double)*_WID*4); \
48  cdouble *_X=(cdouble*)&_LDATA[_WID]; \
49  cdouble *_W=(cdouble*)&_X[_WID]; \
50  SetTwiddleFactors(_WID, _W);
51 #define FreeFFTBuffer(_LDATA) free8(_LDATA);
52 
53 //--compelx FFT and IFFT-----------------------------------------------------
54 void CFFTCbii(int Order, cdouble* W, cdouble* X); //complex FFT subroutine after bit-inversed ordering
55 void CFFTC(int Order, cdouble* W, cdouble* X, int* bitinv=0); //complex FFT, compact in-place
56 void CFFTC(cdouble* Input, double* Amp, double *Arg, int Order, cdouble* W, cdouble* X, int* bitinv=0); //complex FFT
57 void CFFTCW(double* Window, int Order, cdouble* W, cdouble* X, int* bitinv=0); //complex FFT with window, compact in-place
58 void CFFTCW(cdouble* Input, double* Window, double *Amp, double *Arg, int Order, cdouble* W, cdouble* X, int* bitinv=0); //complex FFT with window
59 void CIFFTC(int Order, cdouble* W, cdouble* X, int* bitinv=0); //complex IFFT, compact in-place
60 void CIFFTC(cdouble* Input, int Order, cdouble* W, cdouble* X, int* bitinv=0); //complex IFFT
61 
62 //--real FFT and IFFT--------------------------------------------------------
63 void RFFTC_ual(double* Input, double* Amp, double* Arg, int Order, cdouble* W, cdouble* X, int* hbitinv=0); //real-to-complex FFT
64 void RFFTC_ual_old(double* Input, double *Amp, double *Arg, int Order, cdouble* W, double* XR, double* XI, int* bitinv=0); //depreciated
65 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
66 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
67 void CIFFTR(cdouble* Input, int Order, cdouble* W, double* X, int* hbitinv=0); //complex-to-real IFFT
68 
69 /*
70  macro RFFTC: was defined as RFFTC_ual (literally "unaligned RFFTC") enveloped by ALIGN8(). However, as
71  ALIGN8() is currently disabled for lack of compiler support, RFFTC is equivalent to RFFTC_ual.
72 */
73 #define RFFTC(Input, Amp, Arg, Order, W, X, hbitinv) RFFTC_ual(Input, Amp, Arg, Order, W, X, hbitinv);
74 
75 //--MFT----------------------------------------------------------------------
76 void CMFTC(double* xR, double* xI, int Order, cdouble** X, cdouble* W); //complex fast multiresolution FT
77 
78 //--DCT and IDCT-------------------------------------------------------------
79 void RDCT1(double* Input, double* Output, int Order, cdouble* qW, cdouble* qX, int* qbitinv=0); //DCT1
80 void RDCT4(double* Input, double* Output, int Order, cdouble* hW, cdouble* hX, int* hbitinv=0); //DCT4
81 void RIDCT1(double* Input, double* Output, int Order, cdouble* qW, cdouble* qX, int* qbitinv=0); //IDCT1
82 void RIDCT4(double* Input, double* Output, int Order, cdouble* hW, cdouble* hX, int* hbitinv=0); //IDCT4
83 
84 //--LCT----------------------------------------------------------------------
85 void RLCT(double** spec, double* data, int Count, int Order, int wid, double* g); //local cosine transform
86 void RILCT(double* data, double** spec, int Fr, int Order, int wid, double* g); //inverse local cosine transform
87 
88 //--tools--------------------------------------------------------------------
89 double Atan2(double, double);
90 int Log2(int);
91 int* CreateBitInvTable(int Order); //creates table of bit-inversed integers
92 void SetTwiddleFactors(int N, cdouble* w); //set twiddle factors
93 
94 
95 #endif
void RDCT1(double *Input, double *Output, int Order, cdouble *qW, cdouble *qX, int *qbitinv=0)
Definition: fft.cpp:587
void RDCT4(double *Input, double *Output, int Order, cdouble *hW, cdouble *hX, int *hbitinv=0)
Definition: fft.cpp:685
int * CreateBitInvTable(int Order)
Definition: fft.cpp:356
void RFFTCW(double *Input, double *Window, double *Amp, double *Arg, int Order, cdouble *W, cdouble *X, int *hbitinv=0)
Definition: fft.cpp:468
void SetTwiddleFactors(int N, cdouble *w)
Definition: fft.cpp:70
cdouble * Window(cdouble *x, double f, int N, int M, double *c, int K1, int K2)
Definition: sinest.cpp:102
void CFFTCW(double *Window, int Order, cdouble *W, cdouble *X, int *bitinv=0)
Definition: fft.cpp:544
void CFFTCbii(int Order, cdouble *W, cdouble *X)
Definition: fft.cpp:91
int Log2(int)
Definition: fft.cpp:38
void RIDCT4(double *Input, double *Output, int Order, cdouble *hW, cdouble *hX, int *hbitinv=0)
Definition: fft.cpp:841
void RLCT(double **spec, double *data, int Count, int Order, int wid, double *g)
Definition: fft.cpp:886
void CIFFTR(cdouble *Input, int Order, cdouble *W, double *X, int *hbitinv=0)
Definition: fft.cpp:281
void RFFTC_ual(double *Input, double *Amp, double *Arg, int Order, cdouble *W, cdouble *X, int *hbitinv=0)
Definition: fft.cpp:379
Definition: xcomplex.h:26
double Atan2(double, double)
Definition: fft.cpp:27
void CFFTC(int Order, cdouble *W, cdouble *X, int *bitinv=0)
Definition: fft.cpp:131
void RILCT(double *data, double **spec, int Fr, int Order, int wid, double *g)
Definition: fft.cpp:946
void RIDCT1(double *Input, double *Output, int Order, cdouble *qW, cdouble *qX, int *qbitinv=0)
Definition: fft.cpp:731
void CIFFTC(int Order, cdouble *W, cdouble *X, int *bitinv=0)
Definition: fft.cpp:231