ardour
fft.h
Go to the documentation of this file.
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 namespace GTKArdour {
36 
37 class FFT
38 {
39  public:
40  FFT(uint32_t);
41  ~FFT();
42 
46  };
47 
48  void reset();
50  void calculate();
51 
52  uint32_t bins() const { return _data_size; }
53 
54  float power_at_bin(uint32_t i) const { return _power_at_bin[i]; }
55  float phase_at_bin(uint32_t i) const { return _phase_at_bin[i]; }
56 
57 
58  private:
59 
60  float *get_hann_window();
61 
62  uint32_t const _window_size;
63  uint32_t const _data_size;
64  uint32_t _iterations;
65 
66  float *_hann_window;
67 
68  float *_fftInput;
69  float *_fftOutput;
70 
71  float *_power_at_bin;
72  float *_phase_at_bin;
73 
74  fftwf_plan _plan;
75 };
76 
77 }
78 
79 #endif
float phase_at_bin(uint32_t i) const
Definition: fft.h:55
WindowingType
Definition: fft.h:43
uint32_t bins() const
Definition: fft.h:52
uint32_t const _data_size
Definition: fft.h:63
uint32_t const _window_size
Definition: fft.h:62
float power_at_bin(uint32_t i) const
Definition: fft.h:54
void reset()
Definition: fft.cc:47
fftwf_plan _plan
Definition: fft.h:74
float * _hann_window
Definition: fft.h:66
void calculate()
Definition: fft.cc:98
float Sample
Definition: types.h:54
float * _power_at_bin
Definition: fft.h:71
float * get_hann_window()
Definition: fft.cc:110
void analyze(ARDOUR::Sample *, WindowingType w=NONE)
Definition: fft.cc:56
uint32_t _iterations
Definition: fft.h:64
float * _phase_at_bin
Definition: fft.h:72
float * _fftInput
Definition: fft.h:68
FFT(uint32_t)
Definition: fft.cc:28
float * _fftOutput
Definition: fft.h:69
Definition: fft.h:35