kiss_fft.h

00001 #ifndef KISS_FFT_H
00002 #define KISS_FFT_H
00003 
00004 #include <stdlib.h>
00005 #include <stdio.h>
00006 #include <math.h>
00007 #include <memory.h>
00008 #include <malloc.h>
00009 
00010 #ifdef __cplusplus
00011 extern "C" {
00012 #endif
00013 
00014 /*
00015  ATTENTION!
00016  If you would like a :
00017  -- a utility that will handle the caching of fft objects
00018  -- real-only (no imaginary time component ) FFT
00019  -- a multi-dimensional FFT
00020  -- a command-line utility to perform ffts
00021  -- a command-line utility to perform fast-convolution filtering
00022 
00023  Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c
00024   in the tools/ directory.
00025 */
00026 
00027 #ifdef USE_SIMD
00028 # include <xmmintrin.h>
00029 # define kiss_fft_scalar __m128
00030 #define KISS_FFT_MALLOC(nbytes) memalign(16,nbytes)
00031 #else 
00032 #define KISS_FFT_MALLOC malloc
00033 #endif  
00034 
00035 
00036 #ifdef FIXED_POINT
00037 #include <sys/types.h>  
00038 # if (FIXED_POINT == 32)
00039 #  define kiss_fft_scalar int32_t
00040 # else  
00041 #  define kiss_fft_scalar int16_t
00042 # endif
00043 #else
00044 # ifndef kiss_fft_scalar
00045 /*  default is float */
00046 #   define kiss_fft_scalar double
00047 # endif
00048 #endif
00049 
00050 typedef struct {
00051     kiss_fft_scalar r;
00052     kiss_fft_scalar i;
00053 }kiss_fft_cpx;
00054 
00055 typedef struct kiss_fft_state* kiss_fft_cfg;
00056 
00057 /* 
00058  *  kiss_fft_alloc
00059  *  
00060  *  Initialize a FFT (or IFFT) algorithm's cfg/state buffer.
00061  *
00062  *  typical usage:      kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL);
00063  *
00064  *  The return value from fft_alloc is a cfg buffer used internally
00065  *  by the fft routine or NULL.
00066  *
00067  *  If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc.
00068  *  The returned value should be free()d when done to avoid memory leaks.
00069  *  
00070  *  The state can be placed in a user supplied buffer 'mem':
00071  *  If lenmem is not NULL and mem is not NULL and *lenmem is large enough,
00072  *      then the function places the cfg in mem and the size used in *lenmem
00073  *      and returns mem.
00074  *  
00075  *  If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough),
00076  *      then the function returns NULL and places the minimum cfg 
00077  *      buffer size in *lenmem.
00078  * */
00079 
00080 kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem); 
00081 
00082 /*
00083  * kiss_fft(cfg,in_out_buf)
00084  *
00085  * Perform an FFT on a complex input buffer.
00086  * for a forward FFT,
00087  * fin should be  f[0] , f[1] , ... ,f[nfft-1]
00088  * fout will be   F[0] , F[1] , ... ,F[nfft-1]
00089  * Note that each element is complex and can be accessed like
00090     f[k].r and f[k].i
00091  * */
00092 void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout);
00093 
00094 /*
00095  A more generic version of the above function. It reads its input from every Nth sample.
00096  * */
00097 void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride);
00098 
00099 /* If kiss_fft_alloc allocated a buffer, it is one contiguous 
00100    buffer and can be simply free()d when no longer needed*/
00101 #define kiss_fft_free free
00102 
00103 /*
00104  Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up 
00105  your compiler output to call this before you exit.
00106 */
00107 void kiss_fft_cleanup(void);
00108   
00109 
00110 /*
00111  * Returns the smallest integer k, such that k>=n and k has only "fast" factors (2,3,5)
00112  */
00113 int kiss_fft_next_fast_size(int n);
00114 
00115 #ifdef __cplusplus
00116 } 
00117 #endif
00118 
00119 #endif

Generated on Sun Feb 8 15:31:09 2009 for The Zenautics Matrix Project by  doxygen 1.5.4