Fix red in fft plugin.
[kugel-rb.git] / apps / plugins / fft / kiss_fft.h
blobbcd7eb76d4b3b0533f6633791c0c96a9ef682262
1 #ifndef KISS_FFT_H
2 #define KISS_FFT_H
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <math.h>
7 #include <string.h>
8 /* no malloc
9 #include <malloc.h>
11 #include "plugin.h"
12 #include "lib/helper.h"
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
19 ATTENTION!
20 If you would like a :
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
34 #ifdef FIXED_POINT
35 #include <inttypes.h>
36 # if 1 /* 16-bit data is _slow_ on devices (FIXED_POINT == 32) */
37 # define kiss_fft_scalar int32_t
38 # else
39 # define kiss_fft_scalar int16_t
40 # endif
41 #else
42 # ifndef kiss_fft_scalar
43 /* default is float */
44 # define kiss_fft_scalar float
45 # endif
46 #endif
48 typedef struct {
49 kiss_fft_scalar r;
50 kiss_fft_scalar i;
51 }kiss_fft_cpx;
53 typedef struct kiss_fft_state* kiss_fft_cfg;
56 * kiss_fft_alloc
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
71 * and returns mem.
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.
76 * */
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.
84 * for a forward FFT,
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
88 f[k].r and f[k].i
89 * */
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.
94 * */
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)
117 #ifdef __cplusplus
119 #endif
121 #endif