+
+void
+AudioDialog::setup_statistics ()
+{
+ if (!_analysis) {
+ return;
+ }
+
+ shared_ptr<Film> film = _film.lock ();
+ if (!film) {
+ return;
+ }
+
+ pair<AudioAnalysis::PeakTime, int> const peak = _analysis->overall_sample_peak ();
+ float const peak_dB = 20 * log10 (peak.first.peak) + _analysis->gain_correction (_playlist);
+ _sample_peak->SetLabel (
+ wxString::Format (
+ _("Sample peak is %.2fdB at %s on %s"),
+ peak_dB,
+ time_to_timecode (peak.first.time, film->video_frame_rate ()).data (),
+ std_to_wx (short_audio_channel_name (peak.second)).data ()
+ )
+ );
+
+ if (peak_dB > -3) {
+ _sample_peak->SetForegroundColour (wxColour (255, 0, 0));
+ } else {
+ _sample_peak->SetForegroundColour (wxColour (0, 0, 0));
+ }
+
+ if (_analysis->overall_true_peak()) {
+ float const peak = _analysis->overall_true_peak().get();
+ float const peak_dB = 20 * log10 (peak) + _analysis->gain_correction (_playlist);
+
+ _true_peak->SetLabel (wxString::Format (_("True peak is %.2fdB"), peak_dB));
+
+ if (peak_dB > -3) {
+ _true_peak->SetForegroundColour (wxColour (255, 0, 0));
+ } else {
+ _true_peak->SetForegroundColour (wxColour (0, 0, 0));
+ }
+ }
+
+ /* XXX: check whether it's ok to add dB gain to these quantities */
+
+ if (static_cast<bool>(_analysis->integrated_loudness ())) {
+ _integrated_loudness->SetLabel (
+ wxString::Format (
+ _("Integrated loudness %.2f LUFS"),
+ _analysis->integrated_loudness().get() + _analysis->gain_correction (_playlist)
+ )
+ );
+ }
+
+ if (static_cast<bool>(_analysis->loudness_range ())) {
+ _loudness_range->SetLabel (
+ wxString::Format (
+ _("Loudness range %.2f LU"),
+ _analysis->loudness_range().get() + _analysis->gain_correction (_playlist)
+ )
+ );
+ }
+}
+
+bool
+AudioDialog::Show (bool show)
+{
+ bool const r = wxDialog::Show (show);
+ try_to_load_analysis ();
+ return r;
+}
+
+void
+AudioDialog::set_cursor (optional<DCPTime> time, optional<float> db)
+{
+ if (!time || !db) {
+ _cursor->SetLabel (_("Cursor: none"));
+ return;
+ }
+
+ shared_ptr<Film> film = _film.lock();
+ DCPOMATIC_ASSERT (film);
+ _cursor->SetLabel (wxString::Format (_("Cursor: %.1fdB at %s"), *db, time->timecode(film->video_frame_rate())));
+}