2 Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
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.
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.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef DCPOMATIC_AUDIO_ANALYSIS_H
21 #define DCPOMATIC_AUDIO_ANALYSIS_H
23 #include "dcpomatic_time.h"
24 #include <libcxml/cxml.h>
25 #include <boost/optional.hpp>
26 #include <boost/filesystem.hpp>
43 AudioPoint (cxml::ConstNodePtr node);
44 AudioPoint (AudioPoint const &);
45 AudioPoint& operator= (AudioPoint const &);
47 void as_xml (xmlpp::Element *) const;
49 float& operator[] (int t) {
57 class AudioAnalysis : public boost::noncopyable
60 AudioAnalysis (int c);
61 AudioAnalysis (boost::filesystem::path);
63 void add_point (int c, AudioPoint const & p);
64 void set_peak (float peak, DCPTime time) {
69 AudioPoint get_point (int c, int p) const;
70 int points (int c) const;
71 int channels () const;
73 boost::optional<float> peak () const {
77 boost::optional<DCPTime> peak_time () const {
81 boost::optional<double> analysis_gain () const {
82 return _analysis_gain;
85 void set_analysis_gain (double gain) {
86 _analysis_gain = gain;
89 void write (boost::filesystem::path);
92 std::vector<std::vector<AudioPoint> > _data;
93 boost::optional<float> _peak;
94 boost::optional<DCPTime> _peak_time;
95 /** If this analysis was run on a single piece of
96 * content we store its gain in dB when the analysis
99 boost::optional<double> _analysis_gain;