Update audio plot window when audio mapping is changed.
authorCarl Hetherington <cth@carlh.net>
Tue, 3 Jun 2014 14:24:30 +0000 (15:24 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 3 Jun 2014 14:24:30 +0000 (15:24 +0100)
ChangeLog
src/wx/audio_dialog.cc
src/wx/audio_plot.cc

index dfcf699c0b84c9932c64d0e3a3ed1966502fe121..b24adacb90e27945cce0cb715ab4b9d8950da907 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,6 @@
 2014-06-03  Carl Hetherington  <cth@carlh.net>
 
-       * Re-calculate audio plots when the mapping is changed.
+       * Re-calculate and update audio plots when the mapping is changed.
 
        * Change the -3dB preset to -6dB since we are talking about
        amplitude, not power.
index 0e1316cf31979f21d3ec4790f1a3ba5bb7154461..1f882e61f14ae9a5a10a47a8765f32e0d1b8437b 100644 (file)
@@ -106,6 +106,7 @@ AudioDialog::try_to_load_analysis ()
        }
 
        if (!boost::filesystem::exists (_content->audio_analysis_path())) {
+               _plot->set_analysis (shared_ptr<AudioAnalysis> ());
                _analysis_finished_connection = _content->analyse_audio (bind (&AudioDialog::analysis_finished, this));
                return;
        }
@@ -115,14 +116,28 @@ AudioDialog::try_to_load_analysis ()
        a.reset (new AudioAnalysis (_content->audio_analysis_path ()));
        _plot->set_analysis (a);
 
-       if (_channel_checkbox[0]) {
+       /* 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);
        }
-       _plot->set_channel_visible (0, true);
 
-       for (int i = 0; i < AudioPoint::COUNT; ++i) {
-               _type_checkbox[i]->SetValue (true);
-               _plot->set_type_visible (i, 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);
+               }
        }
 }
 
@@ -158,6 +173,8 @@ AudioDialog::content_changed (int p)
 {
        if (p == AudioContentProperty::AUDIO_GAIN) {
                _plot->set_gain (_content->audio_gain ());
+       } else if (p == AudioContentProperty::AUDIO_MAPPING) {
+               try_to_load_analysis ();
        }
 }
 
index 69faf127e2db0404fa5192cf9f12d8a74510ec5b..c4e5d992fe2c11a3dbc107b287a1462e8437ca54 100644 (file)
@@ -40,7 +40,6 @@ AudioPlot::AudioPlot (wxWindow* parent)
        : wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE)
        , _gain (0)
        , _smoothing (max_smoothing / 2)
-       , _message (_("Please wait; audio is being analysed..."))
 {
 #ifndef __WXOSX__      
        SetDoubleBuffered (true);
@@ -67,6 +66,8 @@ AudioPlot::AudioPlot (wxWindow* parent)
        _colours.push_back (wxColour (255,   0, 139));
        _colours.push_back (wxColour (139,   0, 255));
 
+       set_analysis (shared_ptr<AudioAnalysis> ());
+
 #if MAX_DCP_AUDIO_CHANNELS != 12
 #warning AudioPlot::AudioPlot is expecting the wrong MAX_DCP_AUDIO_CHANNELS
 #endif 
@@ -81,14 +82,10 @@ AudioPlot::set_analysis (shared_ptr<AudioAnalysis> a)
 {
        _analysis = a;
 
-       for (int i = 0; i < MAX_DCP_AUDIO_CHANNELS; ++i) {
-               _channel_visible[i] = false;
+       if (!a) {
+               _message = _("Please wait; audio is being analysed...");
        }
 
-       for (int i = 0; i < AudioPoint::COUNT; ++i) {
-               _type_visible[i] = false;
-       }
-       
        Refresh ();
 }