2 Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef DCPOMATIC_AUDIO_ANALYSIS_H
22 #define DCPOMATIC_AUDIO_ANALYSIS_H
24 #include "dcpomatic_time.h"
25 #include "audio_point.h"
26 #include <libcxml/cxml.h>
27 #include <boost/optional.hpp>
28 #include <boost/filesystem.hpp>
37 class AudioAnalysis : public boost::noncopyable
40 AudioAnalysis (int c);
41 AudioAnalysis (boost::filesystem::path);
43 void add_point (int c, AudioPoint const & p);
45 void set_sample_peak (float peak, DCPTime time) {
47 _sample_peak_time = time;
50 void set_true_peak (float peak) {
54 void set_integrated_loudness (float l) {
55 _integrated_loudness = l;
58 void set_loudness_range (float r) {
62 AudioPoint get_point (int c, int p) const;
63 int points (int c) const;
64 int channels () const;
66 boost::optional<float> sample_peak () const {
70 boost::optional<DCPTime> sample_peak_time () const {
71 return _sample_peak_time;
74 boost::optional<float> true_peak () const {
78 boost::optional<float> integrated_loudness () const {
79 return _integrated_loudness;
82 boost::optional<float> loudness_range () const {
83 return _loudness_range;
86 boost::optional<double> analysis_gain () const {
87 return _analysis_gain;
90 void set_analysis_gain (double gain) {
91 _analysis_gain = gain;
94 void write (boost::filesystem::path);
96 float gain_correction (boost::shared_ptr<const Playlist> playlist);
99 std::vector<std::vector<AudioPoint> > _data;
100 boost::optional<float> _sample_peak;
101 boost::optional<DCPTime> _sample_peak_time;
102 boost::optional<float> _true_peak;
103 boost::optional<float> _integrated_loudness;
104 boost::optional<float> _loudness_range;
105 /** If this analysis was run on a single piece of
106 * content we store its gain in dB when the analysis
109 boost::optional<double> _analysis_gain;