Move Export Audition Buttons to the bottom
[ardour.git] / libs / audiographer / audiographer / general / analyser.h
1 /*
2  * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (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
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18
19 #ifndef AUDIOGRAPHER_ANALYSER_H
20 #define AUDIOGRAPHER_ANALYSER_H
21
22 #include <fftw3.h>
23
24 #include <vamp-hostsdk/PluginLoader.h>
25 #include <vamp-sdk/Plugin.h>
26
27 #include "audiographer/visibility.h"
28 #include "audiographer/sink.h"
29 #include "audiographer/utils/listed_source.h"
30
31 #include "ardour/export_analysis.h"
32
33 namespace AudioGrapher
34 {
35
36 class LIBAUDIOGRAPHER_API Analyser : public ListedSource<float>, public Sink<float>
37 {
38   public:
39         Analyser (float sample_rate, unsigned int channels, framecnt_t bufsize, framecnt_t n_samples);
40         ~Analyser ();
41         void process (ProcessContext<float> const & c);
42         ARDOUR::ExportAnalysisPtr result ();
43
44         using Sink<float>::process;
45
46         private:
47         float fft_power_at_bin (const uint32_t b, const float norm) const;
48
49         ARDOUR::ExportAnalysis _result;
50         Vamp::Plugin*  _ebur128_plugin;
51         Vamp::Plugin** _dbtp_plugin;
52
53         float        _sample_rate;
54         unsigned int _channels;
55         framecnt_t   _bufsize;
56         framecnt_t   _n_samples;
57         framecnt_t   _pos;
58         framecnt_t   _spp;
59         framecnt_t   _fpp;
60
61         float* _bufs[2];
62
63         float*     _hann_window;
64         uint32_t   _fft_data_size;
65         double     _fft_freq_per_bin;
66         float*     _fft_data_in;
67         float*     _fft_data_out;
68         float*     _fft_power;
69         fftwf_plan _fft_plan;
70
71 };
72
73 } // namespace
74
75 #endif