First draft of the EQ visualization system. Now force fed to all plugin UIs.
[ardour.git] / gtk2_ardour / fft.h
1 /*
2     Copyright (C) 2008 Paul Davis
3     Author: Sampo Savolainen
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20
21 #ifndef __ardour_fft_h__
22 #define __ardour_fft_h__
23
24
25 #include <iostream>
26
27 #include <stdio.h>
28 #include <sys/types.h>
29 #include <complex> // this needs to be included before fftw3.h
30 #include <fftw3.h>
31
32
33 #include <ardour/types.h>
34
35 class FFT
36 {
37         public:
38                 FFT(uint32_t);
39                 ~FFT();
40
41                 void reset();
42                 void analyze(ARDOUR::Sample *);
43                 void calculate();
44
45                 uint32_t bins() const { return _dataSize; }
46
47                 float powerAtBin(uint32_t i) const { return _powerAtBin[i]; }
48                 float phaseAtBin(uint32_t i) const { return _phaseAtBin[i]; }
49
50         private:
51
52                 uint32_t const _windowSize;
53                 uint32_t const _dataSize;
54                 uint32_t _iterations;
55
56                 float *_fftInput;
57                 float *_fftOutput;
58
59                 float *_powerAtBin;
60                 float *_phaseAtBin;
61
62                 fftwf_plan _plan;
63 };
64
65 #endif