annotate src/vamp-sdk/ext/vamp_kiss_fft.h @ 526:459cddd7e64a c++11-mutex

Switch from C++98 to C++11
author Chris Cannam
date Wed, 11 Sep 2019 14:30:14 +0100
parents 90571dcc371a
children
rev   line source
Chris@501 1 #ifndef VAMP_KISS_FFT_H
Chris@501 2 #define VAMP_KISS_FFT_H
Chris@434 3
Chris@434 4 #include <stdlib.h>
Chris@434 5 #include <stdio.h>
Chris@434 6 #include <math.h>
Chris@434 7 #include <string.h>
Chris@434 8
Chris@501 9 #ifndef _VAMP_IN_PLUGINSDK
Chris@501 10 # ifndef _VAMP_IN_HOSTSDK
Chris@501 11 # error "Do not use the Vamp SDK mangled KissFFT header except through the Vamp SDK API"
Chris@501 12 # endif
Chris@501 13 #endif
Chris@501 14
Chris@501 15 #ifdef VAMP_KISSFFT_USE_CPP_LINKAGE
Chris@501 16 #define VAMP_KISS_FFT_MALLOC ::malloc
Chris@501 17 #define VAMP_KISS_FFT_FREE ::free
Chris@501 18 #else
Chris@434 19 #ifdef __cplusplus
Chris@434 20 extern "C" {
Chris@501 21 #define VAMP_KISS_FFT_MALLOC malloc
Chris@501 22 #define VAMP_KISS_FFT_FREE free
Chris@434 23 #endif
Chris@493 24 #endif
Chris@434 25
Chris@501 26 # ifndef vamp_kiss_fft_scalar
Chris@501 27 # error "vamp_kiss_fft_scalar must be defined before inclusion, we don't have a default in this build"
Chris@434 28 # endif
Chris@434 29
Chris@434 30 typedef struct {
Chris@501 31 vamp_kiss_fft_scalar r;
Chris@501 32 vamp_kiss_fft_scalar i;
Chris@501 33 } vamp_kiss_fft_cpx;
Chris@434 34
Chris@501 35 typedef struct vamp_kiss_fft_state* vamp_kiss_fft_cfg;
Chris@434 36
Chris@434 37 /*
Chris@434 38 * kiss_fft_alloc
Chris@434 39 *
Chris@434 40 * Initialize a FFT (or IFFT) algorithm's cfg/state buffer.
Chris@434 41 *
Chris@434 42 * typical usage: kiss_fft_cfg mycfg=kiss_fft_alloc(1024,0,NULL,NULL);
Chris@434 43 *
Chris@434 44 * The return value from fft_alloc is a cfg buffer used internally
Chris@434 45 * by the fft routine or NULL.
Chris@434 46 *
Chris@434 47 * If lenmem is NULL, then kiss_fft_alloc will allocate a cfg buffer using malloc.
Chris@434 48 * The returned value should be free()d when done to avoid memory leaks.
Chris@434 49 *
Chris@434 50 * The state can be placed in a user supplied buffer 'mem':
Chris@434 51 * If lenmem is not NULL and mem is not NULL and *lenmem is large enough,
Chris@434 52 * then the function places the cfg in mem and the size used in *lenmem
Chris@434 53 * and returns mem.
Chris@434 54 *
Chris@434 55 * If lenmem is not NULL and ( mem is NULL or *lenmem is not large enough),
Chris@434 56 * then the function returns NULL and places the minimum cfg
Chris@434 57 * buffer size in *lenmem.
Chris@434 58 * */
Chris@434 59
Chris@501 60 vamp_kiss_fft_cfg vamp_kiss_fft_alloc(int nfft,int inverse_fft,void * mem,size_t * lenmem);
Chris@434 61
Chris@434 62 /*
Chris@434 63 * kiss_fft(cfg,in_out_buf)
Chris@434 64 *
Chris@434 65 * Perform an FFT on a complex input buffer.
Chris@434 66 * for a forward FFT,
Chris@434 67 * fin should be f[0] , f[1] , ... ,f[nfft-1]
Chris@434 68 * fout will be F[0] , F[1] , ... ,F[nfft-1]
Chris@434 69 * Note that each element is complex and can be accessed like
Chris@434 70 f[k].r and f[k].i
Chris@434 71 * */
Chris@501 72 void vamp_kiss_fft(vamp_kiss_fft_cfg cfg,const vamp_kiss_fft_cpx *fin,vamp_kiss_fft_cpx *fout);
Chris@434 73
Chris@434 74 /*
Chris@434 75 A more generic version of the above function. It reads its input from every Nth sample.
Chris@434 76 * */
Chris@501 77 void vamp_kiss_fft_stride(vamp_kiss_fft_cfg cfg,const vamp_kiss_fft_cpx *fin,vamp_kiss_fft_cpx *fout,int fin_stride);
Chris@434 78
Chris@434 79 /* If kiss_fft_alloc allocated a buffer, it is one contiguous
Chris@434 80 buffer and can be simply free()d when no longer needed*/
Chris@501 81 void vamp_kiss_fft_free(void *);
Chris@434 82
Chris@434 83 /*
Chris@434 84 Cleans up some memory that gets managed internally. Not necessary to call, but it might clean up
Chris@434 85 your compiler output to call this before you exit.
Chris@434 86 */
Chris@501 87 void vamp_kiss_fft_cleanup(void);
Chris@434 88
Chris@434 89
Chris@434 90 /*
Chris@434 91 * Returns the smallest integer k, such that k>=n and k has only "fast" factors (2,3,5)
Chris@434 92 */
Chris@501 93 int vamp_kiss_fft_next_fast_size(int n);
Chris@434 94
Chris@434 95 /* for real ffts, we need an even size */
Chris@501 96 #define vamp_kiss_fftr_next_fast_size_real(n) \
Chris@501 97 (vamp_kiss_fft_next_fast_size( ((n)+1)>>1)<<1)
Chris@434 98
Chris@501 99 #ifndef VAMP_KISSFFT_USE_CPP_LINKAGE
Chris@434 100 #ifdef __cplusplus
Chris@434 101 }
Chris@434 102 #endif
Chris@493 103 #endif
Chris@493 104
Chris@501 105 #ifdef VAMP_KISSFFT_USE_CPP_LINKAGE
Chris@501 106 #define VAMP_KISSFFT_USED_CPP_LINKAGE 1
Chris@493 107 #endif
Chris@434 108
Chris@434 109 #endif