1 /*
2  * lingot, a musical instrument tuner.
3  *
4  * Copyright (C) 2004-2018  Iban Cereijo.
5  * Copyright (C) 2004-2008  Jairo Chapela.
6 
7  *
8  * This file is part of lingot.
9  *
10  * lingot is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * lingot is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with lingot; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23  */
24 
25 #ifndef _LINGOT_FFT_H_
26 #define _LINGOT_FFT_H_
27 
28 /*
29  Fourier transforms.
30  */
31 
32 #include "lingot-defs.h"
33 
34 #ifdef LIBFFTW
35 # include <fftw3.h>
36 #endif
37 
38 # include "lingot-complex.h"
39 
40 typedef struct {
41 
42 	int n;
43 	FLT* in;
44 
45 #ifdef LIBFFTW
46 	fftw_plan fftwplan;
47 #else
48 // phase factor table, for FFT optimization.
49 	LingotComplex* wn;
50 #endif
51 	LingotComplex* fft_out; // complex signal in freq.
52 } LingotFFTPlan;
53 
54 void lingot_fft_plan_create(LingotFFTPlan*, FLT* in, int n);
55 void lingot_fft_plan_destroy(LingotFFTPlan*);
56 
57 // Full Spectral Power Distribution (SPD) esteem.
58 void lingot_fft_compute_dft_and_spd(LingotFFTPlan*, FLT* out, int n_out);
59 
60 // Spectral Power Distribution (SPD) evaluation at a given frequency.
61 void lingot_fft_spd_eval(FLT* in, int N1, FLT wi, FLT dw, FLT* out, int N2);
62 
63 // Evaluates first and second SPD derivatives at frequency w.
64 void lingot_fft_spd_diffs_eval(const FLT* in, int N, FLT w, FLT* out_d0,
65 		FLT* out_d1, FLT* out_d2);
66 
67 #endif
68