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