12 #include "lib/helper.h"
21 -- a utility that will handle the caching of fft objects
22 -- real-only (no imaginary time component ) FFT
23 -- a multi-dimensional FFT
24 -- a command-line utility to perform ffts
25 -- a command-line utility to perform fast-convolution filtering
27 Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c
28 in the tools/ directory.
31 #define KISS_FFT_MALLOC malloc
36 # if 1 /* 16-bit data is _slow_ on devices (FIXED_POINT == 32) */
37 # define kiss_fft_scalar int32_t
39 # define kiss_fft_scalar int16_t
42 # ifndef kiss_fft_scalar
43 /* default is float */
44 # define kiss_fft_scalar float
53 typedef struct kiss_fft_state
* kiss_fft_cfg
;
58 * Initialize a FFT (or IFFT) algorithm's cfg/state buffer.
60 * typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL);
62 * The return value from fft_alloc is a cfg buffer used internally
63 * by the fft routine or NULL.
65 * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc.
66 * The returned value should be free()d when done to avoid memory leaks.
68 * The state can be placed in a user supplied buffer 'mem':
69 * If lenmem is not NULL and mem is not NULL and *lenmem is large enough,
70 * then the function places the cfg in mem and the size used in *lenmem
73 * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough),
74 * then the function returns NULL and places the minimum cfg
75 * buffer size in *lenmem.
78 kiss_fft_cfg
kiss_fft_alloc(int nfft
,int inverse_fft
,void * mem
,size_t * lenmem
);
81 * kiss_fft(cfg,in_out_buf)
83 * Perform an FFT on a complex input buffer.
85 * fin should be f[0] , f[1] , ... ,f[nfft-1]
86 * fout will be F[0] , F[1] , ... ,F[nfft-1]
87 * Note that each element is complex and can be accessed like
90 void kiss_fft(kiss_fft_cfg cfg
,const kiss_fft_cpx
*fin
,kiss_fft_cpx
*fout
);
93 A more generic version of the above function. It reads its input from every Nth sample.
95 void kiss_fft_stride(kiss_fft_cfg cfg
,const kiss_fft_cpx
*fin
,kiss_fft_cpx
*fout
,int fin_stride
);
97 /* If kiss_fft_alloc allocated a buffer, it is one contiguous
98 buffer and can be simply free()d when no longer needed*/
99 #define kiss_fft_free free
102 Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up
103 your compiler output to call this before you exit.
105 void kiss_fft_cleanup(void);
109 * Returns the smallest integer k, such that k>=n and k has only "fast" factors (2,3,5)
111 int kiss_fft_next_fast_size(int n
);
113 /* for real ffts, we need an even size */
114 #define kiss_fftr_next_fast_size_real(n) \
115 (kiss_fft_next_fast_size( ((n)+1)>>1)<<1)