Fix apparently ineffective processors when analysing audio (#2671).
[dcpomatic.git] / test / audio_analysis_test.cc
index 8bdca4c32877ccb744804f3a274608e611bc4735..8ded9eda9296d28a67f17a0fc7520e07e5a96415 100644 (file)
@@ -41,6 +41,7 @@
 #include "lib/ratio.h"
 #include "test.h"
 #include <boost/test/unit_test.hpp>
+#include <numeric>
 
 
 using std::make_shared;
@@ -283,3 +284,27 @@ BOOST_AUTO_TEST_CASE(analyse_audio_with_more_channels_than_film)
        BOOST_CHECK(!wait_for_jobs());
 }
 
+
+BOOST_AUTO_TEST_CASE(analyse_audio_uses_processor_when_analysing_whole_film)
+{
+       auto sound = content_factory(TestPaths::private_data() / "betty_stereo.wav")[0];
+       auto film = new_test_film2("analyse_audio_uses_processor_when_analysing_whole_film", { sound });
+
+       auto job = make_shared<AnalyseAudioJob>(film, film->playlist(), true);
+       JobManager::instance()->add(job);
+       BOOST_REQUIRE(!wait_for_jobs());
+
+       AudioAnalysis analysis(job->path());
+
+       BOOST_REQUIRE(analysis.channels() > 2);
+       bool centre_non_zero = false;
+       /* Make sure there's something from the mid-side decoder on the centre channel */
+       for (auto point = 0; point < analysis.points(2); ++point) {
+               if (std::abs(analysis.get_point(2, point)[AudioPoint::Type::PEAK]) > 0) {
+                       centre_non_zero = true;
+               }
+       }
+
+       BOOST_CHECK(centre_non_zero);
+}
+