Mercurial > hg > x
view fft.h @ 13:de3961f74f30 tip
Add Linux/gcc Makefile; build fix
author | Chris Cannam |
---|---|
date | Mon, 05 Sep 2011 15:22:35 +0100 |
parents | 977f541d6683 |
children |
line wrap: on
line source
/* Harmonic sinusoidal modelling and tools C++ code package for harmonic sinusoidal modelling and relevant signal processing. Centre for Digital Music, Queen Mary, University of London. This file copyright 2011 Wen Xue. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. */ #ifndef fftH #define fftH /** \file fft.h - fast Fourier and cosine transforms Arguments of the function in this unit roughly follow the following rules: Wid : size of transform Order : log2(Wid) W : FFT buffer: twiddle factors, standard size Wid/2 X : FFT buffer: data buffer, standard size Wid bitinv: FFT buffer: table of bit-inversed integers, standard size Wid Window: window function, standard size Wid spec : complex spectrogram Amp : amplitude spectrogram Arg : phase spectrogram prefix h- : half-size prefix q- : quarter-size */ #include <math.h> #include "xcomplex.h" #include "align8.h" //--------------------------------------------------------------------------- /** macro AllocateFFTBuffer: allocates FFT buffers X and W of given length with an extra LDATA buffer the right size for hosting such arrays as the standard-size window function or output amplitude spectrum. This macro allocates buffer with 64-bit alignment, which must be freed with free8() or FreeFFTBuffer macro. */ #define AllocateFFTBuffer(_WID, _LDATA, _W, _X) \ double *_LDATA=(double*)malloc8(sizeof(double)*_WID*4); \ cdouble *_X=(cdouble*)&_LDATA[_WID]; \ cdouble *_W=(cdouble*)&_X[_WID]; \ SetTwiddleFactors(_WID, _W); #define FreeFFTBuffer(_LDATA) free8(_LDATA); //--compelx FFT and IFFT----------------------------------------------------- void CFFTCbii(int Order, cdouble* W, cdouble* X); //complex FFT subroutine after bit-inversed ordering void CFFTC(int Order, cdouble* W, cdouble* X, int* bitinv=0); //complex FFT, compact in-place void CFFTC(cdouble* Input, double* Amp, double *Arg, int Order, cdouble* W, cdouble* X, int* bitinv=0); //complex FFT void CFFTCW(double* Window, int Order, cdouble* W, cdouble* X, int* bitinv=0); //complex FFT with window, compact in-place void CFFTCW(cdouble* Input, double* Window, double *Amp, double *Arg, int Order, cdouble* W, cdouble* X, int* bitinv=0); //complex FFT with window void CIFFTC(int Order, cdouble* W, cdouble* X, int* bitinv=0); //complex IFFT, compact in-place void CIFFTC(cdouble* Input, int Order, cdouble* W, cdouble* X, int* bitinv=0); //complex IFFT //--real FFT and IFFT-------------------------------------------------------- void RFFTC_ual(double* Input, double* Amp, double* Arg, int Order, cdouble* W, cdouble* X, int* hbitinv=0); //real-to-complex FFT void RFFTC_ual_old(double* Input, double *Amp, double *Arg, int Order, cdouble* W, double* XR, double* XI, int* bitinv=0); //depreciated 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 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 void CIFFTR(cdouble* Input, int Order, cdouble* W, double* X, int* hbitinv=0); //complex-to-real IFFT /* macro RFFTC: was defined as RFFTC_ual (literally "unaligned RFFTC") enveloped by ALIGN8(). However, as ALIGN8() is currently disabled for lack of compiler support, RFFTC is equivalent to RFFTC_ual. */ #define RFFTC(Input, Amp, Arg, Order, W, X, hbitinv) RFFTC_ual(Input, Amp, Arg, Order, W, X, hbitinv); //--MFT---------------------------------------------------------------------- void CMFTC(double* xR, double* xI, int Order, cdouble** X, cdouble* W); //complex fast multiresolution FT //--DCT and IDCT------------------------------------------------------------- void RDCT1(double* Input, double* Output, int Order, cdouble* qW, cdouble* qX, int* qbitinv=0); //DCT1 void RDCT4(double* Input, double* Output, int Order, cdouble* hW, cdouble* hX, int* hbitinv=0); //DCT4 void RIDCT1(double* Input, double* Output, int Order, cdouble* qW, cdouble* qX, int* qbitinv=0); //IDCT1 void RIDCT4(double* Input, double* Output, int Order, cdouble* hW, cdouble* hX, int* hbitinv=0); //IDCT4 //--LCT---------------------------------------------------------------------- void RLCT(double** spec, double* data, int Count, int Order, int wid, double* g); //local cosine transform void RILCT(double* data, double** spec, int Fr, int Order, int wid, double* g); //inverse local cosine transform //--tools-------------------------------------------------------------------- double Atan2(double, double); int Log2(int); int* CreateBitInvTable(int Order); //creates table of bit-inversed integers void SetTwiddleFactors(int N, cdouble* w); //set twiddle factors #endif