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);
46 PeakTime (float p, DCPTime t)
55 void set_sample_peak (std::vector<PeakTime> peak) {
59 void set_true_peak (std::vector<float> peak) {
63 void set_integrated_loudness (float l) {
64 _integrated_loudness = l;
67 void set_loudness_range (float r) {
71 AudioPoint get_point (int c, int p) const;
72 int points (int c) const;
73 int channels () const;
75 std::vector<PeakTime> sample_peak () const {
79 std::pair<PeakTime, int> overall_sample_peak () const;
81 std::vector<float> true_peak () const {
85 boost::optional<float> overall_true_peak () const;
87 boost::optional<float> integrated_loudness () const {
88 return _integrated_loudness;
91 boost::optional<float> loudness_range () const {
92 return _loudness_range;
95 boost::optional<double> analysis_gain () const {
96 return _analysis_gain;
99 void set_analysis_gain (double gain) {
100 _analysis_gain = gain;
103 void write (boost::filesystem::path);
105 float gain_correction (boost::shared_ptr<const Playlist> playlist);
108 std::vector<std::vector<AudioPoint> > _data;
109 std::vector<PeakTime> _sample_peak;
110 std::vector<float> _true_peak;
111 boost::optional<float> _integrated_loudness;
112 boost::optional<float> _loudness_range;
113 /** If this analysis was run on a single piece of
114 * content we store its gain in dB when the analysis
117 boost::optional<double> _analysis_gain;
119 static int const _current_state_version;