#include "compose.hpp"
#include "film.h"
#include "player.h"
+#include "playlist.h"
#include <boost/foreach.hpp>
#include "i18n.h"
int const AnalyseAudioJob::_num_points = 1024;
-AnalyseAudioJob::AnalyseAudioJob (shared_ptr<const Film> f, shared_ptr<const Playlist> p)
- : Job (f)
- , _playlist (p)
+AnalyseAudioJob::AnalyseAudioJob (shared_ptr<const Film> film, shared_ptr<const Playlist> playlist)
+ : Job (film)
+ , _playlist (playlist)
, _done (0)
, _samples_per_point (1)
, _overall_peak (0)
{
shared_ptr<Player> player (new Player (_film, _playlist));
player->set_ignore_video ();
-
- int64_t const len = _film->length().frames (_film->audio_frame_rate());
+
+ int64_t const len = _playlist->length().frames_round (_film->audio_frame_rate());
_samples_per_point = max (int64_t (1), len / _num_points);
_current.resize (_film->audio_channels ());
_analysis.reset (new AudioAnalysis (_film->audio_channels ()));
bool has_any_audio = false;
- BOOST_FOREACH (shared_ptr<Content> c, _film->content ()) {
+ BOOST_FOREACH (shared_ptr<Content> c, _playlist->content ()) {
if (dynamic_pointer_cast<AudioContent> (c)) {
has_any_audio = true;
}
}
_analysis->set_peak (_overall_peak, DCPTime::from_frames (_overall_peak_frame, _film->audio_frame_rate ()));
+
+ if (_playlist->content().size() == 1) {
+ /* If there was only one piece of content in this analysis we may later need to know what its
+ gain was when we analysed it.
+ */
+ shared_ptr<const AudioContent> ac = dynamic_pointer_cast<const AudioContent> (_playlist->content().front ());
+ DCPOMATIC_ASSERT (ac);
+ _analysis->set_analysis_gain (ac->audio_gain ());
+ }
+
_analysis->write (_film->audio_analysis_path (_playlist));
-
+
set_progress (1);
set_state (FINISHED_OK);
}
++_done;
}
}
-