c@289
|
1 #ifndef KISS_FFT_H
|
c@289
|
2 #define KISS_FFT_H
|
c@289
|
3
|
c@289
|
4 #include <stdlib.h>
|
c@289
|
5 #include <stdio.h>
|
c@289
|
6 #include <math.h>
|
c@289
|
7 #include <memory.h>
|
c@289
|
8 #include <malloc.h>
|
c@289
|
9
|
c@289
|
10 #ifdef __cplusplus
|
c@289
|
11 extern "C" {
|
c@289
|
12 #endif
|
c@289
|
13
|
c@289
|
14 #ifdef USE_SIMD
|
c@289
|
15 # include <xmmintrin.h>
|
c@289
|
16 # define kiss_fft_scalar __m128
|
c@289
|
17 #define KISS_FFT_MALLOC(nbytes) memalign(16,nbytes)
|
c@289
|
18 #else
|
c@289
|
19 #define KISS_FFT_MALLOC malloc
|
c@289
|
20 #endif
|
c@289
|
21
|
c@289
|
22
|
c@289
|
23 #ifdef FIXED_POINT
|
c@289
|
24 #include <sys/types.h>
|
c@289
|
25 # if (FIXED_POINT == 32)
|
c@289
|
26 # define kiss_fft_scalar int32_t
|
c@289
|
27 # else
|
c@289
|
28 # define kiss_fft_scalar int16_t
|
c@289
|
29 # endif
|
c@289
|
30 #else
|
c@289
|
31 # ifndef kiss_fft_scalar
|
c@289
|
32 /* default is float */
|
c@289
|
33 /* # define kiss_fft_scalar float */
|
c@289
|
34 /* ... but doubles for QM library ... */
|
c@289
|
35 #define kiss_fft_scalar double
|
c@289
|
36 # endif
|
c@289
|
37 #endif
|
c@289
|
38
|
c@289
|
39 typedef struct {
|
c@289
|
40 kiss_fft_scalar r;
|
c@289
|
41 kiss_fft_scalar i;
|
c@289
|
42 }kiss_fft_cpx;
|
c@289
|
43
|
c@289
|
44 typedef struct kiss_fft_state* kiss_fft_cfg;
|
c@289
|
45
|
c@289
|
46 /*
|
c@289
|
47 * kiss_fft_alloc
|
c@289
|
48 *
|
c@289
|
49 * Initialize a FFT (or IFFT) algorithm's cfg/state buffer.
|
c@289
|
50 *
|
c@289
|
51 * typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL);
|
c@289
|
52 *
|
c@289
|
53 * The return value from fft_alloc is a cfg buffer used internally
|
c@289
|
54 * by the fft routine or NULL.
|
c@289
|
55 *
|
c@289
|
56 * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc.
|
c@289
|
57 * The returned value should be free()d when done to avoid memory leaks.
|
c@289
|
58 *
|
c@289
|
59 * The state can be placed in a user supplied buffer 'mem':
|
c@289
|
60 * If lenmem is not NULL and mem is not NULL and *lenmem is large enough,
|
c@289
|
61 * then the function places the cfg in mem and the size used in *lenmem
|
c@289
|
62 * and returns mem.
|
c@289
|
63 *
|
c@289
|
64 * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough),
|
c@289
|
65 * then the function returns NULL and places the minimum cfg
|
c@289
|
66 * buffer size in *lenmem.
|
c@289
|
67 * */
|
c@289
|
68
|
c@289
|
69 kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem);
|
c@289
|
70
|
c@289
|
71 /*
|
c@289
|
72 * kiss_fft(cfg,in_out_buf)
|
c@289
|
73 *
|
c@289
|
74 * Perform an FFT on a complex input buffer.
|
c@289
|
75 * for a forward FFT,
|
c@289
|
76 * fin should be f[0] , f[1] , ... ,f[nfft-1]
|
c@289
|
77 * fout will be F[0] , F[1] , ... ,F[nfft-1]
|
c@289
|
78 * Note that each element is complex and can be accessed like
|
c@289
|
79 f[k].r and f[k].i
|
c@289
|
80 * */
|
c@289
|
81 void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout);
|
c@289
|
82
|
c@289
|
83 /*
|
c@289
|
84 A more generic version of the above function. It reads its input from every Nth sample.
|
c@289
|
85 * */
|
c@289
|
86 void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride);
|
c@289
|
87
|
c@289
|
88 /* If kiss_fft_alloc allocated a buffer, it is one contiguous
|
c@289
|
89 buffer and can be simply free()d when no longer needed*/
|
c@289
|
90 #define kiss_fft_free free
|
c@289
|
91
|
c@289
|
92 /*
|
c@289
|
93 Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up
|
c@289
|
94 your compiler output to call this before you exit.
|
c@289
|
95 */
|
c@289
|
96 void kiss_fft_cleanup(void);
|
c@289
|
97
|
c@289
|
98
|
c@289
|
99 /*
|
c@289
|
100 * Returns the smallest integer k, such that k>=n and k has only "fast" factors (2,3,5)
|
c@289
|
101 */
|
c@289
|
102 int kiss_fft_next_fast_size(int n);
|
c@289
|
103
|
c@289
|
104 #ifdef __cplusplus
|
c@289
|
105 }
|
c@289
|
106 #endif
|
c@289
|
107
|
c@289
|
108 #endif
|