+ ContentList sel = _parent->selected_audio ();
+ bool alert = false;
+
+ if (sel.size() != 1) {
+ _peak->SetLabel (wxT (""));
+ } else {
+ shared_ptr<Playlist> playlist (new Playlist);
+ playlist->add (sel.front ());
+ try {
+ shared_ptr<AudioAnalysis> analysis (new AudioAnalysis (_parent->film()->audio_analysis_path (playlist)));
+ if (analysis->sample_peak ()) {
+ float const peak_dB = 20 * log10 (analysis->sample_peak().get()) + analysis->gain_correction (playlist);
+ if (peak_dB > -3) {
+ alert = true;
+ }
+ _peak->SetLabel (wxString::Format (_("Peak: %.2fdB"), peak_dB));
+ } else {
+ _peak->SetLabel (_("Peak: unknown"));
+ }
+ } catch (...) {
+ _peak->SetLabel (_("Peak: unknown"));
+ }
+ }
+
+ static wxColour normal = _peak->GetForegroundColour ();
+
+ if (alert) {
+ _peak->SetForegroundColour (wxColour (255, 0, 0));
+ } else {
+ _peak->SetForegroundColour (normal);