Some missing copy constructors / operator= / noncopyable.
[dcpomatic.git] / src / lib / audio_analysis.cc
index 0cf08c5bdf1b42078f571b0b6105a99572d7e66c..bc59bcccaa56539a6f8a4a1728c2d9e50e9e1a50 100644 (file)
@@ -48,6 +48,27 @@ AudioPoint::AudioPoint (istream& s)
        }
 }
 
+AudioPoint::AudioPoint (AudioPoint const & other)
+{
+       for (int i = 0; i < COUNT; ++i) {
+               _data[i] = other._data[i];
+       }
+}
+
+AudioPoint &
+AudioPoint::operator= (AudioPoint const & other)
+{
+       if (this == &other) {
+               return *this;
+       }
+       
+       for (int i = 0; i < COUNT; ++i) {
+               _data[i] = other._data[i];
+       }
+
+       return *this;
+}
+
 void
 AudioPoint::write (ostream& s) const
 {
@@ -62,9 +83,9 @@ AudioAnalysis::AudioAnalysis (int channels)
        _data.resize (channels);
 }
 
-AudioAnalysis::AudioAnalysis (string filename)
+AudioAnalysis::AudioAnalysis (boost::filesystem::path filename)
 {
-       ifstream f (filename.c_str ());
+       ifstream f (filename.string().c_str ());
 
        int channels;
        f >> channels;
@@ -107,10 +128,10 @@ AudioAnalysis::points (int c) const
 }
 
 void
-AudioAnalysis::write (string filename)
+AudioAnalysis::write (boost::filesystem::path filename)
 {
-       string tmp = filename + ".tmp";
-       
+       string tmp = filename.string() + ".tmp";
+
        ofstream f (tmp.c_str ());
        f << _data.size() << "\n";
        for (vector<vector<AudioPoint> >::iterator i = _data.begin(); i != _data.end(); ++i) {
@@ -123,29 +144,3 @@ AudioAnalysis::write (string filename)
        f.close ();
        boost::filesystem::rename (tmp, filename);
 }
-
-float
-AudioAnalysis::smooth (list<float> const & data, AudioPoint::Type t)
-{
-       float val;
-
-       switch (t) {
-       case AudioPoint::PEAK:
-               /* XXX: fall-off, or something...? */
-               val = -200;
-               for (list<float>::const_iterator i = data.begin(); i != data.end(); ++i) {
-                       val = max (val, *i);
-               }
-               return val;
-       case AudioPoint::RMS:
-               val = 0;
-               for (list<float>::const_iterator i = data.begin(); i != data.end(); ++i) {
-                       val += pow (*i, 2);
-               }
-               return sqrt (val / data.size());
-       default:
-               assert (false);
-       }
-
-       return 0;
-}