Ardour  9.0-pre0-582-g084a23a80d
fft.h
Go to the documentation of this file.
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 #pragma once
20 
21 
22 #include <iostream>
23 
24 #include <stdio.h>
25 #include <sys/types.h>
26 #include <complex> // this needs to be included before fftw3.h
27 #include <fftw3.h>
28 
29 
30 #include "ardour/types.h"
31 
32 namespace GTKArdour {
33 
34 class FFT
35 {
36 public:
37  FFT (uint32_t);
38  ~FFT ();
39 
42  HANN
43  };
44 
45  void reset ();
47  void calculate ();
48 
49  uint32_t bins () const { return _data_size; }
50 
51  float power_at_bin (uint32_t i) const { return _power_at_bin[i]; }
52  float phase_at_bin (uint32_t i) const { return _phase_at_bin[i]; }
53 
54 private:
55  float* get_hann_window ();
56 
57  uint32_t const _window_size;
58  uint32_t const _data_size;
59  uint32_t _iterations;
60 
61  float* _hann_window;
62 
63  float* _fftInput;
64  float* _fftOutput;
65 
66  float* _power_at_bin;
67  float* _phase_at_bin;
68 
69  fftwf_plan _plan;
70 };
71 
72 }
73 
float power_at_bin(uint32_t i) const
Definition: fft.h:51
float phase_at_bin(uint32_t i) const
Definition: fft.h:52
float * _power_at_bin
Definition: fft.h:66
float * _phase_at_bin
Definition: fft.h:67
fftwf_plan _plan
Definition: fft.h:69
FFT(uint32_t)
uint32_t bins() const
Definition: fft.h:49
void analyze(ARDOUR::Sample *, WindowingType w=NONE)
float * _hann_window
Definition: fft.h:61
WindowingType
Definition: fft.h:40
uint32_t const _window_size
Definition: fft.h:57
float * _fftInput
Definition: fft.h:63
uint32_t _iterations
Definition: fft.h:59
float * _fftOutput
Definition: fft.h:64
float * get_hann_window()
uint32_t const _data_size
Definition: fft.h:58
Definition: fft.h:32