X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Faudio_analysis.h;h=478b0e532f0dab46ad263ac7ce5249269c8ec892;hb=80f27f81cc7991f52e4a41c7f687681fd9c15a65;hp=d57eba90a3184200a18619bcb0ac4b0727998038;hpb=50cb31af16240b248700dab1484d7f07656c66df;p=dcpomatic.git diff --git a/src/lib/audio_analysis.h b/src/lib/audio_analysis.h index d57eba90a..478b0e532 100644 --- a/src/lib/audio_analysis.h +++ b/src/lib/audio_analysis.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2015 Carl Hetherington This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,10 +20,12 @@ #ifndef DCPOMATIC_AUDIO_ANALYSIS_H #define DCPOMATIC_AUDIO_ANALYSIS_H -#include #include #include #include +#include +#include +#include "types.h" class AudioPoint { @@ -35,10 +37,12 @@ public: }; AudioPoint (); - AudioPoint (std::istream &); + AudioPoint (cxml::ConstNodePtr node); + AudioPoint (AudioPoint const &); + AudioPoint& operator= (AudioPoint const &); + + void as_xml (xmlpp::Element *) const; - void write (std::ostream &) const; - float& operator[] (int t) { return _data[t]; } @@ -47,22 +51,49 @@ private: float _data[COUNT]; }; -class AudioAnalysis +class AudioAnalysis : public boost::noncopyable { public: AudioAnalysis (int c); AudioAnalysis (boost::filesystem::path); void add_point (int c, AudioPoint const & p); - + void set_peak (float peak, DCPTime time) { + _peak = peak; + _peak_time = time; + } + AudioPoint get_point (int c, int p) const; int points (int c) const; int channels () const; + boost::optional peak () const { + return _peak; + } + + boost::optional peak_time () const { + return _peak_time; + } + + boost::optional analysis_gain () const { + return _analysis_gain; + } + + void set_analysis_gain (double gain) { + _analysis_gain = gain; + } + void write (boost::filesystem::path); private: std::vector > _data; + boost::optional _peak; + boost::optional _peak_time; + /** If this analysis was run on a single piece of + * content we store its gain in dB when the analysis + * happened. + */ + boost::optional _analysis_gain; }; #endif