prepare region/range loudness analysis
[ardour.git] / libs / ardour / ardour / analysis_graph.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 __ardour_analysis_graph_h__
20 #define __ardour_analysis_graph_h__
21
22 #include <map>
23 #include <set>
24 #include <cstring>
25 #include <boost/shared_ptr.hpp>
26
27 #include "ardour/audioregion.h"
28 #include "ardour/audioplaylist.h"
29 #include "ardour/export_analysis.h"
30
31 namespace AudioGrapher {
32         class Analyser;
33         template <typename T> class Chunker;
34         template <typename T> class Interleaver;
35 }
36
37 namespace ARDOUR {
38 class AnalysisGraph {
39         public:
40                 AnalysisGraph (ARDOUR::Session*);
41                 ~AnalysisGraph ();
42
43                 void analyze_region (boost::shared_ptr<ARDOUR::AudioRegion>);
44                 void analyze_range (boost::shared_ptr<ARDOUR::Route>, boost::shared_ptr<ARDOUR::AudioPlaylist>, const std::list<AudioRange>&);
45                 const AnalysisResults& results () const { return _results; }
46
47                 void cancel () { _canceled = true; }
48                 bool canceled () const { return _canceled; }
49
50                 void set_total_frames (framecnt_t p) { _frames_end = p; }
51                 PBD::Signal2<void, framecnt_t, framecnt_t> Progress;
52
53         private:
54                 ARDOUR::Session* _session;
55                 AnalysisResults  _results;
56                 framecnt_t       _max_chunksize;
57
58                 ARDOUR::Sample*  _buf;
59                 ARDOUR::Sample*  _mixbuf;
60                 float*           _gainbuf;
61                 framecnt_t       _frames_read;
62                 framecnt_t       _frames_end;
63                 bool             _canceled;
64
65                 typedef boost::shared_ptr<AudioGrapher::Analyser> AnalysisPtr;
66                 typedef boost::shared_ptr<AudioGrapher::Chunker<float> > ChunkerPtr;
67                 typedef boost::shared_ptr<AudioGrapher::Interleaver<Sample> > InterleaverPtr;
68
69                 InterleaverPtr  interleaver;
70                 ChunkerPtr      chunker;
71                 AnalysisPtr     analyser;
72 };
73 } // namespace ARDOUR
74 #endif