+ if (has_any_audio) {
+ player->seek (_start, true);
+ _done = 0;
+ while (!player->pass ()) {}
+ }
+
+ vector<AudioAnalysis::PeakTime> sample_peak;
+ for (int i = 0; i < _film->audio_channels(); ++i) {
+ sample_peak.push_back (
+ AudioAnalysis::PeakTime (_sample_peak[i], DCPTime::from_frames (_sample_peak_frame[i], _film->audio_frame_rate ()))
+ );
+ }
+ _analysis->set_sample_peak (sample_peak);
+
+#ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG
+ if (Config::instance()->analyse_ebur128 ()) {
+ void* eb = _ebur128->get("Parsed_ebur128_0")->priv;
+ vector<float> true_peak;
+ for (int i = 0; i < _film->audio_channels(); ++i) {
+ true_peak.push_back (av_ebur128_get_true_peaks(eb)[i]);
+ }
+ _analysis->set_true_peak (true_peak);
+ _analysis->set_integrated_loudness (av_ebur128_get_integrated_loudness(eb));
+ _analysis->set_loudness_range (av_ebur128_get_loudness_range(eb));
+ }
+#endif
+
+ 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 = _playlist->content().front()->audio;
+ if (ac) {
+ _analysis->set_analysis_gain (ac->gain());
+ }
+ }
+
+ _analysis->set_samples_per_point (_samples_per_point);
+ _analysis->set_sample_rate (_film->audio_frame_rate ());
+ _analysis->write (_path);
+