X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fwx%2Faudio_dialog.cc;h=1f882e61f14ae9a5a10a47a8765f32e0d1b8437b;hb=9e4c091e6ef0f79fab10664e95240de2f14e5702;hp=c7a0815f821ba341aae418a7d6f2067072f95ae9;hpb=373f010a7f04add1f49169cbaa60cb7ae5f508d4;p=dcpomatic.git diff --git a/src/wx/audio_dialog.cc b/src/wx/audio_dialog.cc index c7a0815f8..1f882e61f 100644 --- a/src/wx/audio_dialog.cc +++ b/src/wx/audio_dialog.cc @@ -45,7 +45,7 @@ AudioDialog::AudioDialog (wxWindow* parent) side->Add (m, 1, wxALIGN_CENTER_VERTICAL | wxTOP, 16); } - for (int i = 0; i < MAX_AUDIO_CHANNELS; ++i) { + for (int i = 0; i < MAX_DCP_AUDIO_CHANNELS; ++i) { _channel_checkbox[i] = new wxCheckBox (this, wxID_ANY, std_to_wx (audio_channel_name (i))); side->Add (_channel_checkbox[i], 1, wxEXPAND | wxALL, 3); _channel_checkbox[i]->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&AudioDialog::channel_clicked, this, _1)); @@ -87,7 +87,7 @@ void AudioDialog::set_content (shared_ptr c) { _content_changed_connection.disconnect (); - + _content = c; try_to_load_analysis (); @@ -95,14 +95,19 @@ AudioDialog::set_content (shared_ptr c) _content_changed_connection = _content->Changed.connect (bind (&AudioDialog::content_changed, this, _2)); - SetTitle (wxString::Format (_("DCP-o-matic audio - %s"), std_to_wx(_content->path().filename().string()).data())); + SetTitle (wxString::Format (_("DCP-o-matic audio - %s"), std_to_wx(_content->path_summary()).data())); } void AudioDialog::try_to_load_analysis () { - if (!boost::filesystem::exists (_content->audio_analysis_path()) && IsShown ()) { - _content->analyse_audio (bind (&AudioDialog::analysis_finished, this)); + if (!IsShown ()) { + return; + } + + if (!boost::filesystem::exists (_content->audio_analysis_path())) { + _plot->set_analysis (shared_ptr ()); + _analysis_finished_connection = _content->analyse_audio (bind (&AudioDialog::analysis_finished, this)); return; } @@ -111,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); + } } } @@ -140,11 +159,11 @@ void AudioDialog::channel_clicked (wxCommandEvent& ev) { int c = 0; - while (c < MAX_AUDIO_CHANNELS && ev.GetEventObject() != _channel_checkbox[c]) { + while (c < MAX_DCP_AUDIO_CHANNELS && ev.GetEventObject() != _channel_checkbox[c]) { ++c; } - assert (c < MAX_AUDIO_CHANNELS); + assert (c < MAX_DCP_AUDIO_CHANNELS); _plot->set_channel_visible (c, _channel_checkbox[c]->GetValue ()); } @@ -154,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 (); } }