Merge pull request #113 from tesselode/fix-multi-targets
[wdl/wdl-ol.git] / WDL / fft.h
blobd2be245fb04724c24c06ce1b7c4d30fce971ab0d
1 /*
2 WDL - fft.h
3 Copyright (C) 2006 and later Cockos Incorporated
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
23 This file defines the interface to the WDL FFT library. These routines are based on the
24 DJBFFT library, which are Copyright 1999 D. J. Bernstein, djb@pobox.com
26 The DJB FFT web page is: http://cr.yp.to/djbfft.html
30 #ifndef _WDL_FFT_H_
31 #define _WDL_FFT_H_
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
37 #ifndef WDL_FFT_REALSIZE
38 #define WDL_FFT_REALSIZE 4
39 #endif
41 #if WDL_FFT_REALSIZE == 4
42 typedef float WDL_FFT_REAL;
43 #elif WDL_FFT_REALSIZE == 8
44 typedef double WDL_FFT_REAL;
45 #else
46 #error invalid FFT item size
47 #endif
49 typedef struct {
50 WDL_FFT_REAL re;
51 WDL_FFT_REAL im;
52 } WDL_FFT_COMPLEX;
54 extern void WDL_fft_init();
56 extern void WDL_fft_complexmul(WDL_FFT_COMPLEX *dest, WDL_FFT_COMPLEX *src, int len);
57 extern void WDL_fft_complexmul2(WDL_FFT_COMPLEX *dest, WDL_FFT_COMPLEX *src, WDL_FFT_COMPLEX *src2, int len);
58 extern void WDL_fft_complexmul3(WDL_FFT_COMPLEX *destAdd, WDL_FFT_COMPLEX *src, WDL_FFT_COMPLEX *src2, int len);
60 /* Expects WDL_FFT_COMPLEX input[0..len-1] scaled by 1.0/len, returns
61 WDL_FFT_COMPLEX output[0..len-1] order by WDL_fft_permute(len). */
62 extern void WDL_fft(WDL_FFT_COMPLEX *, int len, int isInverse);
64 /* Expects WDL_FFT_REAL input[0..len-1] scaled by 0.5/len, returns
65 WDL_FFT_COMPLEX output[0..len/2-1], for len >= 4 order by
66 WDL_fft_permute(len/2). Note that output[len/2].re is stored in
67 output[0].im. */
68 extern void WDL_real_fft(WDL_FFT_REAL *, int len, int isInverse);
70 extern int WDL_fft_permute(int fftsize, int idx);
71 extern int *WDL_fft_permute_tab(int fftsize);
73 #ifdef __cplusplus
75 #endif
77 #endif