annotate src/ext/kissfft/kiss_fft.h @ 196:da283326bcd3 tip master

Update plugin versions in RDF
author Chris Cannam <cannam@all-day-breakfast.com>
date Fri, 28 Feb 2020 09:43:02 +0000
parents 5ed6e970541b
children
rev   line source
c@174 1 #ifndef KISS_FFT_H
c@174 2 #define KISS_FFT_H
c@174 3
c@174 4 #include <stdlib.h>
c@174 5 #include <stdio.h>
c@174 6 #include <math.h>
c@174 7 #include <string.h>
c@174 8
c@174 9 #ifdef __cplusplus
c@174 10 extern "C" {
c@174 11 #endif
c@174 12
c@174 13 /*
c@174 14 ATTENTION!
c@174 15 If you would like a :
c@174 16 -- a utility that will handle the caching of fft objects
c@174 17 -- real-only (no imaginary time component ) FFT
c@174 18 -- a multi-dimensional FFT
c@174 19 -- a command-line utility to perform ffts
c@174 20 -- a command-line utility to perform fast-convolution filtering
c@174 21
c@174 22 Then see kfc.h kiss_fftr.h kiss_fftnd.h fftutil.c kiss_fastfir.c
c@174 23 in the tools/ directory.
c@174 24 */
c@174 25
c@174 26 #ifdef USE_SIMD
c@174 27 # include <xmmintrin.h>
c@174 28 # define kiss_fft_scalar __m128
c@174 29 #define KISS_FFT_MALLOC(nbytes) _mm_malloc(nbytes,16)
c@174 30 #define KISS_FFT_FREE _mm_free
c@174 31 #else
c@174 32 #define KISS_FFT_MALLOC malloc
c@174 33 #define KISS_FFT_FREE free
c@174 34 #endif
c@174 35
c@174 36
c@174 37 #ifdef FIXED_POINT
c@174 38 #include <sys/types.h>
c@174 39 # if (FIXED_POINT == 32)
c@174 40 # define kiss_fft_scalar int32_t
c@174 41 # else
c@174 42 # define kiss_fft_scalar int16_t
c@174 43 # endif
c@174 44 #else
c@174 45 # ifndef kiss_fft_scalar
c@174 46 /* default is float */
c@174 47 # define kiss_fft_scalar float
c@174 48 # endif
c@174 49 #endif
c@174 50
c@174 51 typedef struct {
c@174 52 kiss_fft_scalar r;
c@174 53 kiss_fft_scalar i;
c@174 54 }kiss_fft_cpx;
c@174 55
c@174 56 typedef struct kiss_fft_state* kiss_fft_cfg;
c@174 57
c@174 58 /*
c@174 59 * kiss_fft_alloc
c@174 60 *
c@174 61 * Initialize a FFT (or IFFT) algorithm's cfg/state buffer.
c@174 62 *
c@174 63 * typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL);
c@174 64 *
c@174 65 * The return value from fft_alloc is a cfg buffer used internally
c@174 66 * by the fft routine or NULL.
c@174 67 *
c@174 68 * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc.
c@174 69 * The returned value should be free()d when done to avoid memory leaks.
c@174 70 *
c@174 71 * The state can be placed in a user supplied buffer 'mem':
c@174 72 * If lenmem is not NULL and mem is not NULL and *lenmem is large enough,
c@174 73 * then the function places the cfg in mem and the size used in *lenmem
c@174 74 * and returns mem.
c@174 75 *
c@174 76 * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough),
c@174 77 * then the function returns NULL and places the minimum cfg
c@174 78 * buffer size in *lenmem.
c@174 79 * */
c@174 80
c@174 81 kiss_fft_cfg kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem);
c@174 82
c@174 83 /*
c@174 84 * kiss_fft(cfg,in_out_buf)
c@174 85 *
c@174 86 * Perform an FFT on a complex input buffer.
c@174 87 * for a forward FFT,
c@174 88 * fin should be f[0] , f[1] , ... ,f[nfft-1]
c@174 89 * fout will be F[0] , F[1] , ... ,F[nfft-1]
c@174 90 * Note that each element is complex and can be accessed like
c@174 91 f[k].r and f[k].i
c@174 92 * */
c@174 93 void kiss_fft(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout);
c@174 94
c@174 95 /*
c@174 96 A more generic version of the above function. It reads its input from every Nth sample.
c@174 97 * */
c@174 98 void kiss_fft_stride(kiss_fft_cfg cfg,const kiss_fft_cpx *fin,kiss_fft_cpx *fout,int fin_stride);
c@174 99
c@174 100 /* If kiss_fft_alloc allocated a buffer, it is one contiguous
c@174 101 buffer and can be simply free()d when no longer needed*/
c@174 102 #define kiss_fft_free free
c@174 103
c@174 104 /*
c@174 105 Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up
c@174 106 your compiler output to call this before you exit.
c@174 107 */
c@174 108 void kiss_fft_cleanup(void);
c@174 109
c@174 110
c@174 111 /*
c@174 112 * Returns the smallest integer k, such that k>=n and k has only "fast" factors (2,3,5)
c@174 113 */
c@174 114 int kiss_fft_next_fast_size(int n);
c@174 115
c@174 116 /* for real ffts, we need an even size */
c@174 117 #define kiss_fftr_next_fast_size_real(n) \
c@174 118 (kiss_fft_next_fast_size( ((n)+1)>>1)<<1)
c@174 119
c@174 120 #ifdef __cplusplus
c@174 121 }
c@174 122 #endif
c@174 123
c@174 124 #endif