+ _analysis->set_sample_peak (_sample_peak, DCPTime::from_frames (_sample_peak_frame, _film->audio_frame_rate ()));
+
+#ifdef DCPOMATIC_HAVE_EBUR128_PATCHED_FFMPEG
+ if (Config::instance()->analyse_ebur128 ()) {
+ void* eb = _ebur128->get("Parsed_ebur128_0")->priv;
+ double true_peak = 0;
+ for (int i = 0; i < _film->audio_channels(); ++i) {
+ true_peak = max (true_peak, 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;
+ DCPOMATIC_ASSERT (ac);
+ _analysis->set_analysis_gain (ac->gain ());
+ }
+
+ _analysis->write (_film->audio_analysis_path (_playlist));
+