#endif
-/** @param from_zero true to analyse audio from time 0 in the playlist, otherwise begin at Playlist::start */
-AnalyseAudioJob::AnalyseAudioJob (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist, bool from_zero)
+/** @param whole_film true to analyse the whole film' audio (i.e. start from time 0 and use processors), false
+ * to analyse just the single piece of content in the playlist (i.e. start from Playlist::start() and do not
+ * use processors.
+ */
+AnalyseAudioJob::AnalyseAudioJob (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist, bool whole_film)
: Job (film)
- , _analyser (film, playlist, from_zero, boost::bind(&Job::set_progress, this, _1, false))
+ , _analyser(film, playlist, whole_film, boost::bind(&Job::set_progress, this, _1, false))
, _playlist (playlist)
, _path (film->audio_analysis_path(playlist))
+ , _whole_film(whole_film)
{
LOG_DEBUG_AUDIO_ANALYSIS_NC("AnalyseAudioJob::AnalyseAudioJob");
}
player->set_fast ();
player->set_play_referenced ();
player->Audio.connect (bind(&AudioAnalyser::analyse, &_analyser, _1, _2));
+ if (!_whole_film) {
+ player->set_disable_audio_processor();
+ }
bool has_any_audio = false;
for (auto c: _playlist->content()) {
class AnalyseAudioJob : public Job
{
public:
- AnalyseAudioJob (std::shared_ptr<const Film>, std::shared_ptr<const Playlist>, bool from_zero);
+ AnalyseAudioJob(std::shared_ptr<const Film>, std::shared_ptr<const Playlist>, bool whole_film);
~AnalyseAudioJob ();
std::string name () const override;
std::shared_ptr<const Playlist> _playlist;
/** playlist's audio analysis path when the job was created */
boost::filesystem::path _path;
+ bool _whole_film;
static const int _num_points;
};
static auto constexpr num_points = 1024;
-AudioAnalyser::AudioAnalyser (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist, bool from_zero, std::function<void (float)> set_progress)
+AudioAnalyser::AudioAnalyser(shared_ptr<const Film> film, shared_ptr<const Playlist> playlist, bool whole_film, std::function<void (float)> set_progress)
: _film (film)
, _playlist (playlist)
, _set_progress (set_progress)
_current = std::vector<AudioPoint>(_film->audio_channels());
- if (!from_zero) {
+ if (!whole_film) {
_start = _playlist->start().get_value_or(DCPTime());
}
};
auto content = _playlist->content();
- if (content.size() == 1 && content[0]->audio) {
+ if (whole_film) {
+ _leqm_channels = film->audio_channels();
+ } else {
_leqm_channels = 0;
for (auto channel: content[0]->audio->mapping().mapped_output_channels()) {
/* This means that if, for example, a file only maps C we will
*/
_leqm_channels = std::min(film->audio_channels(), channel + 1);
}
- } else {
- _leqm_channels = film->audio_channels();
}
/* XXX: is this right? Especially for more than 5.1? */
class AudioAnalyser
{
public:
- AudioAnalyser (std::shared_ptr<const Film> film, std::shared_ptr<const Playlist> playlist, bool from_zero, std::function<void (float)> set_progress);
+ AudioAnalyser(std::shared_ptr<const Film> film, std::shared_ptr<const Playlist> playlist, bool whole_film, std::function<void (float)> set_progress);
AudioAnalyser (AudioAnalyser const&) = delete;
AudioAnalyser& operator= (AudioAnalyser const&) = delete;
#include "lib/ratio.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
+#include <numeric>
using std::make_shared;
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);
+}
+