more pool allocation debugging for oofus
[ardour2.git] / gtk2_ardour / fft.h
blobba191c03cd3fcdc9bb9c7a9c5f2aa8fdde4e368f
1 /*
2 Copyright (C) 2008 Paul Davis
3 Author: Sampo Savolainen
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.
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.
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.
21 #ifndef __ardour_fft_h__
22 #define __ardour_fft_h__
25 #include <iostream>
27 #include <stdio.h>
28 #include <sys/types.h>
29 #include <complex> // this needs to be included before fftw3.h
30 #include <fftw3.h>
33 #include "ardour/types.h"
35 class FFT
37 public:
38 FFT(uint32_t);
39 ~FFT();
41 enum WindowingType {
42 NONE,
43 HANN
46 void reset();
47 void analyze(ARDOUR::Sample *, WindowingType w = NONE);
48 void calculate();
50 uint32_t bins() const { return _data_size; }
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]; }
56 private:
58 float *get_hann_window();
60 uint32_t const _window_size;
61 uint32_t const _data_size;
62 uint32_t _iterations;
64 float *_hann_window;
66 float *_fftInput;
67 float *_fftOutput;
69 float *_power_at_bin;
70 float *_phase_at_bin;
72 fftwf_plan _plan;
75 #endif