comparison src/vamp-sdk/ext/vamp_kiss_fft_guts.h @ 501:90571dcc371a vamp-kiss-naming

Extensively rename things in the KissFFT headers to use a Vamp prefix. The motivation is not to change anything about the Vamp SDK library builds, but to avoid confusion in case any other code (for example that pulls in the Vamp SDK as part of a wider project definition) accidentally includes these headers instead of, or as well as, some other copy of KissFFT.
author Chris Cannam
date Tue, 30 Jan 2018 09:56:46 +0000
parents src/vamp-sdk/ext/_kiss_fft_guts.h@e979a9c4ffb6
children
comparison
equal deleted inserted replaced
500:4a86f866bb6b 501:90571dcc371a
1 #ifndef VAMP_KISS_FFT__GUTS_H
2 #define VAMP_KISS_FFT__GUTS_H
3 /*
4 Copyright (c) 2003-2010, Mark Borgerding
5
6 All rights reserved.
7
8 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
9
10 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
12 * Neither the author nor the names of any contributors may be used to endorse or promote products derived from this software without specific prior written permission.
13
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15 */
16
17 /* kiss_fft.h
18 defines kiss_fft_scalar as either short or a float type
19 and defines
20 typedef struct { kiss_fft_scalar r; kiss_fft_scalar i; }kiss_fft_cpx; */
21 #include "vamp_kiss_fft.h"
22 #include <limits.h>
23
24 #define MAXFACTORS 32
25 /* e.g. an fft of length 128 has 4 factors
26 as far as kissfft is concerned
27 4*4*4*2
28 */
29
30 struct vamp_kiss_fft_state{
31 int nfft;
32 int inverse;
33 int factors[2*MAXFACTORS];
34 vamp_kiss_fft_cpx twiddles[1];
35 };
36
37 /*
38 Explanation of macros dealing with complex math:
39
40 C_MUL(m,a,b) : m = a*b
41 C_FIXDIV( c , div ) : if a fixed point impl., c /= div. noop otherwise
42 C_SUB( res, a,b) : res = a - b
43 C_SUBFROM( res , a) : res -= a
44 C_ADDTO( res , a) : res += a
45 * */
46
47 # define S_MUL(a,b) ( (a)*(b) )
48 #define C_MUL(m,a,b) \
49 do{ (m).r = (a).r*(b).r - (a).i*(b).i;\
50 (m).i = (a).r*(b).i + (a).i*(b).r; }while(0)
51 # define C_FIXDIV(c,div) /* NOOP */
52 # define C_MULBYSCALAR( c, s ) \
53 do{ (c).r *= (s);\
54 (c).i *= (s); }while(0)
55
56 # define CHECK_OVERFLOW_OP(a,op,b) /* noop */
57
58 #define C_ADD( res, a,b)\
59 do { \
60 CHECK_OVERFLOW_OP((a).r,+,(b).r)\
61 CHECK_OVERFLOW_OP((a).i,+,(b).i)\
62 (res).r=(a).r+(b).r; (res).i=(a).i+(b).i; \
63 }while(0)
64 #define C_SUB( res, a,b)\
65 do { \
66 CHECK_OVERFLOW_OP((a).r,-,(b).r)\
67 CHECK_OVERFLOW_OP((a).i,-,(b).i)\
68 (res).r=(a).r-(b).r; (res).i=(a).i-(b).i; \
69 }while(0)
70 #define C_ADDTO( res , a)\
71 do { \
72 CHECK_OVERFLOW_OP((res).r,+,(a).r)\
73 CHECK_OVERFLOW_OP((res).i,+,(a).i)\
74 (res).r += (a).r; (res).i += (a).i;\
75 }while(0)
76
77 #define C_SUBFROM( res , a)\
78 do {\
79 CHECK_OVERFLOW_OP((res).r,-,(a).r)\
80 CHECK_OVERFLOW_OP((res).i,-,(a).i)\
81 (res).r -= (a).r; (res).i -= (a).i; \
82 }while(0)
83
84
85 # define VAMP_KISS_FFT_COS(phase) (vamp_kiss_fft_scalar) cos(phase)
86 # define VAMP_KISS_FFT_SIN(phase) (vamp_kiss_fft_scalar) sin(phase)
87 # define HALF_OF(x) ((x)*.5)
88
89 #define kf_cexp(x,phase) \
90 do{ \
91 (x)->r = VAMP_KISS_FFT_COS(phase);\
92 (x)->i = VAMP_KISS_FFT_SIN(phase);\
93 }while(0)
94
95 #define VAMP_KISS_FFT_TMP_ALLOC(nbytes) VAMP_KISS_FFT_MALLOC(nbytes)
96 #define VAMP_KISS_FFT_TMP_FREE(ptr) VAMP_KISS_FFT_FREE(ptr)
97
98 /* a debugging function */
99 #define pcpx(c)\
100 fprintf(stderr,"%g + %gi\n",(double)((c)->r),(double)((c)->i) )
101
102 #endif