Reenable the correct sort column and type when redisplaying regions
[ardour.git] / gtk2_ardour / fft.h
1 /*
2  * Copyright (C) 2008 Sampo Savolainen <v2@iki.fi>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18
19 #ifndef __ardour_fft_h__
20 #define __ardour_fft_h__
21
22
23 #include <iostream>
24
25 #include <stdio.h>
26 #include <sys/types.h>
27 #include <complex> // this needs to be included before fftw3.h
28 #include <fftw3.h>
29
30
31 #include "ardour/types.h"
32
33 namespace GTKArdour {
34
35 class FFT
36 {
37 public:
38         FFT (uint32_t);
39         ~FFT ();
40
41         enum WindowingType {
42                 NONE,
43                 HANN
44         };
45
46         void reset ();
47         void analyze (ARDOUR::Sample*, WindowingType w = NONE);
48         void calculate ();
49
50         uint32_t bins () const { return _data_size; }
51
52         float power_at_bin (uint32_t i) const { return _power_at_bin[i]; }
53         float phase_at_bin (uint32_t i) const { return _phase_at_bin[i]; }
54
55 private:
56         float* get_hann_window ();
57
58         uint32_t const _window_size;
59         uint32_t const _data_size;
60         uint32_t       _iterations;
61
62         float* _hann_window;
63
64         float* _fftInput;
65         float* _fftOutput;
66
67         float* _power_at_bin;
68         float* _phase_at_bin;
69
70         fftwf_plan _plan;
71 };
72
73 }
74
75 #endif