BOOST_FOREACH.
[dcpomatic.git] / src / lib / audio_analysis.cc
index 13917cb5f6d693f3987b0c8adb85526a6426747c..22c14c7647ecc3de54f5a918ea1820e47623c485 100644 (file)
 #include "util.h"
 #include "playlist.h"
 #include "audio_content.h"
+#include "warnings.h"
 #include <dcp/raw_convert.h>
+DCPOMATIC_DISABLE_WARNINGS
 #include <libxml++/libxml++.h>
+DCPOMATIC_ENABLE_WARNINGS
 #include <boost/filesystem.hpp>
-#include <boost/foreach.hpp>
 #include <stdint.h>
 #include <cmath>
 #include <cstdio>
@@ -42,9 +44,9 @@ using std::max;
 using std::pair;
 using std::make_pair;
 using std::list;
-using boost::shared_ptr;
+using std::shared_ptr;
 using boost::optional;
-using boost::dynamic_pointer_cast;
+using std::dynamic_pointer_cast;
 using dcp::raw_convert;
 using namespace dcpomatic;
 
@@ -65,17 +67,17 @@ AudioAnalysis::AudioAnalysis (boost::filesystem::path filename)
                throw OldFormatError ("Audio analysis file is too old");
        }
 
-       BOOST_FOREACH (cxml::NodePtr i, f.node_children ("Channel")) {
+       for (auto i: f.node_children("Channel")) {
                vector<AudioPoint> channel;
 
-               BOOST_FOREACH (cxml::NodePtr j, i->node_children ("Point")) {
-                       channel.push_back (AudioPoint (j));
+               for (auto j: i->node_children("Point")) {
+                       channel.push_back (AudioPoint(j));
                }
 
                _data.push_back (channel);
        }
 
-       BOOST_FOREACH (cxml::ConstNodePtr i, f.node_children ("SamplePeak")) {
+       for (auto i: f.node_children ("SamplePeak")) {
                _sample_peak.push_back (
                        PeakTime (
                                dcp::raw_convert<float>(i->content()), DCPTime(i->number_attribute<Frame>("Time"))
@@ -83,7 +85,7 @@ AudioAnalysis::AudioAnalysis (boost::filesystem::path filename)
                        );
        }
 
-       BOOST_FOREACH (cxml::ConstNodePtr i, f.node_children ("TruePeak")) {
+       for (auto i: f.node_children ("TruePeak")) {
                _true_peak.push_back (dcp::raw_convert<float> (i->content ()));
        }
 
@@ -93,6 +95,8 @@ AudioAnalysis::AudioAnalysis (boost::filesystem::path filename)
        _analysis_gain = f.optional_number_child<double> ("AnalysisGain");
        _samples_per_point = f.number_child<int64_t> ("SamplesPerPoint");
        _sample_rate = f.number_child<int64_t> ("SampleRate");
+
+       _leqm = f.optional_number_child<double>("Leqm");
 }
 
 void
@@ -130,9 +134,9 @@ AudioAnalysis::write (boost::filesystem::path filename)
 
        root->add_child("Version")->add_child_text (raw_convert<string> (_current_state_version));
 
-       BOOST_FOREACH (vector<AudioPoint>& i, _data) {
+       for (auto& i: _data) {
                xmlpp::Element* channel = root->add_child ("Channel");
-               BOOST_FOREACH (AudioPoint& j, i) {
+               for (auto& j: i) {
                        j.as_xml (channel->add_child ("Point"));
                }
        }
@@ -143,7 +147,7 @@ AudioAnalysis::write (boost::filesystem::path filename)
                n->set_attribute ("Time", raw_convert<string> (_sample_peak[i].time.get()));
        }
 
-       BOOST_FOREACH (float i, _true_peak) {
+       for (auto i: _true_peak) {
                root->add_child("TruePeak")->add_child_text (raw_convert<string> (i));
        }
 
@@ -162,6 +166,10 @@ AudioAnalysis::write (boost::filesystem::path filename)
        root->add_child("SamplesPerPoint")->add_child_text (raw_convert<string> (_samples_per_point));
        root->add_child("SampleRate")->add_child_text (raw_convert<string> (_sample_rate));
 
+       if (_leqm) {
+               root->add_child("Leqm")->add_child_text(raw_convert<string>(*_leqm));
+       }
+
        doc->write_to_file_formatted (filename.string ());
 }
 
@@ -204,7 +212,7 @@ AudioAnalysis::overall_true_peak () const
 {
        optional<float> p;
 
-       BOOST_FOREACH (float i, _true_peak) {
+       for (auto i: _true_peak) {
                if (!p || i > *p) {
                        p = i;
                }
@@ -212,3 +220,4 @@ AudioAnalysis::overall_true_peak () const
 
        return p;
 }
+