- if (boost::filesystem::exists (_film->audio_analysis_path())) {
- a.reset (new AudioAnalysis (_film->audio_analysis_path ()));
- } else {
- if (IsShown ()) {
- _film->analyse_audio ();
+ if (!boost::filesystem::exists (_content->audio_analysis_path())) {
+ _plot->set_analysis (shared_ptr<AudioAnalysis> ());
+ _analysis.reset ();
+ _analysis_finished_connection = _content->analyse_audio (bind (&AudioDialog::analysis_finished, this));
+ return;
+ }
+
+ try {
+ _analysis.reset (new AudioAnalysis (_content->audio_analysis_path ()));
+ } catch (xmlpp::exception& e) {
+ /* Probably an old-style analysis file: recreate it */
+ _analysis_finished_connection = _content->analyse_audio (bind (&AudioDialog::analysis_finished, this));
+ return;
+ }
+
+ _plot->set_analysis (_analysis);
+ setup_peak_time ();
+
+ /* Set up some defaults if no check boxes are checked */
+
+ int i = 0;
+ while (i < MAX_DCP_AUDIO_CHANNELS && (!_channel_checkbox[i] || !_channel_checkbox[i]->GetValue ())) {
+ ++i;
+ }
+
+ if (i == MAX_DCP_AUDIO_CHANNELS && _channel_checkbox[0]) {
+ _channel_checkbox[0]->SetValue (true);
+ _plot->set_channel_visible (0, true);
+ }
+
+ i = 0;
+ while (i < AudioPoint::COUNT && !_type_checkbox[i]->GetValue ()) {
+ i++;
+ }
+
+ if (i == AudioPoint::COUNT) {
+ for (int i = 0; i < AudioPoint::COUNT; ++i) {
+ _type_checkbox[i]->SetValue (true);
+ _plot->set_type_visible (i, true);