From 92b6430402753a572c33d594ba0745a4e461edf4 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 1 Jul 2015 18:04:14 +0100 Subject: [PATCH] Re-add show audio button and analyse just that content when it is clicked. --- src/lib/analyse_audio_job.cc | 2 +- src/lib/film.cc | 4 ++-- src/lib/film.h | 2 +- src/wx/audio_dialog.cc | 19 ++++++++++++++----- src/wx/audio_dialog.h | 10 ++++++---- src/wx/audio_panel.cc | 33 ++++++++++++++++++++++++++++++++- src/wx/audio_panel.h | 5 +++++ 7 files changed, 61 insertions(+), 14 deletions(-) diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc index 2146b03c5..1cec15c2a 100644 --- a/src/lib/analyse_audio_job.cc +++ b/src/lib/analyse_audio_job.cc @@ -89,7 +89,7 @@ AnalyseAudioJob::run () } _analysis->set_peak (_overall_peak, DCPTime::from_frames (_overall_peak_frame, _film->audio_frame_rate ())); - _analysis->write (_film->audio_analysis_path ()); + _analysis->write (_film->audio_analysis_path (_playlist)); set_progress (1); set_state (FINISHED_OK); diff --git a/src/lib/film.cc b/src/lib/film.cc index dbb73303c..5310ef71f 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -228,12 +228,12 @@ Film::internal_video_asset_filename () const } boost::filesystem::path -Film::audio_analysis_path () const +Film::audio_analysis_path (shared_ptr playlist) const { boost::filesystem::path p = dir ("analysis"); MD5Digester digester; - BOOST_FOREACH (shared_ptr i, content ()) { + BOOST_FOREACH (shared_ptr i, playlist->content ()) { shared_ptr ac = dynamic_pointer_cast (i); if (!ac) { continue; diff --git a/src/lib/film.h b/src/lib/film.h index 23478c478..f1df57142 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -69,7 +69,7 @@ public: boost::filesystem::path internal_video_asset_dir () const; boost::filesystem::path internal_video_asset_filename () const; - boost::filesystem::path audio_analysis_path () const; + boost::filesystem::path audio_analysis_path (boost::shared_ptr) const; void send_dcp_to_tms (); void make_dcp (); diff --git a/src/wx/audio_dialog.cc b/src/wx/audio_dialog.cc index 70046f52f..cd59693ea 100644 --- a/src/wx/audio_dialog.cc +++ b/src/wx/audio_dialog.cc @@ -30,8 +30,10 @@ using boost::shared_ptr; using boost::bind; using boost::optional; +using boost::const_pointer_cast; -AudioDialog::AudioDialog (wxWindow* parent, shared_ptr film) +/** @param content Content to analyse, or 0 to analyse all of the film's audio */ +AudioDialog::AudioDialog (wxWindow* parent, shared_ptr film, shared_ptr content) : wxDialog (parent, wxID_ANY, _("Audio"), wxDefaultPosition, wxSize (640, 512), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE) , _film (film) , _plot (0) @@ -109,6 +111,13 @@ AudioDialog::AudioDialog (wxWindow* parent, shared_ptr film) _film_connection = film->ContentChanged.connect (boost::bind (&AudioDialog::try_to_load_analysis, this)); SetTitle (_("DCP-o-matic audio")); + + if (content) { + _playlist.reset (new Playlist ()); + const_pointer_cast (_playlist)->add (content); + } else { + _playlist = film->playlist (); + } } void @@ -121,12 +130,12 @@ AudioDialog::try_to_load_analysis () shared_ptr film = _film.lock (); DCPOMATIC_ASSERT (film); - boost::filesystem::path path = film->audio_analysis_path (); + boost::filesystem::path path = film->audio_analysis_path (_playlist); if (!boost::filesystem::exists (path)) { _plot->set_analysis (shared_ptr ()); _analysis.reset (); - shared_ptr job (new AnalyseAudioJob (film, film->playlist ())); + shared_ptr job (new AnalyseAudioJob (film, _playlist)); _analysis_finished_connection = job->Finished.connect (bind (&AudioDialog::analysis_finished, this)); JobManager::instance()->add (job); return; @@ -136,7 +145,7 @@ AudioDialog::try_to_load_analysis () _analysis.reset (new AudioAnalysis (path)); } catch (xmlpp::exception& e) { /* Probably an old-style analysis file: recreate it */ - shared_ptr job (new AnalyseAudioJob (film, film->playlist ())); + shared_ptr job (new AnalyseAudioJob (film, _playlist)); _analysis_finished_connection = job->Finished.connect (bind (&AudioDialog::analysis_finished, this)); JobManager::instance()->add (job); return; @@ -178,7 +187,7 @@ AudioDialog::analysis_finished () shared_ptr film = _film.lock (); DCPOMATIC_ASSERT (film); - if (!boost::filesystem::exists (film->audio_analysis_path ())) { + if (!boost::filesystem::exists (film->audio_analysis_path (_playlist))) { /* We analysed and still nothing showed up, so maybe it was cancelled or it failed. Give up. */ diff --git a/src/wx/audio_dialog.h b/src/wx/audio_dialog.h index d35cca110..c99261150 100644 --- a/src/wx/audio_dialog.h +++ b/src/wx/audio_dialog.h @@ -17,11 +17,12 @@ */ -#include -#include -#include #include "lib/film.h" #include "lib/audio_analysis.h" +#include "lib/playlist.h" +#include +#include +#include class AudioPlot; class Film; @@ -29,7 +30,7 @@ class Film; class AudioDialog : public wxDialog { public: - AudioDialog (wxWindow *, boost::shared_ptr film); + AudioDialog (wxWindow *, boost::shared_ptr film, boost::shared_ptr content = boost::shared_ptr ()); bool Show (bool show = true); @@ -44,6 +45,7 @@ private: boost::shared_ptr _analysis; boost::weak_ptr _film; + boost::shared_ptr _playlist; AudioPlot* _plot; wxStaticText* _peak_time; wxCheckBox* _channel_checkbox[MAX_DCP_AUDIO_CHANNELS]; diff --git a/src/wx/audio_panel.cc b/src/wx/audio_panel.cc index c31d5b575..46d7a2254 100644 --- a/src/wx/audio_panel.cc +++ b/src/wx/audio_panel.cc @@ -25,6 +25,7 @@ #include "wx_util.h" #include "gain_calculator_dialog.h" #include "content_panel.h" +#include "audio_dialog.h" #include #include #include @@ -40,12 +41,17 @@ using boost::shared_ptr; AudioPanel::AudioPanel (ContentPanel* p) : ContentSubPanel (p, _("Audio")) + , _audio_dialog (0) { wxGridBagSizer* grid = new wxGridBagSizer (DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); _sizer->Add (grid, 0, wxALL, 8); int r = 0; + _show = new wxButton (this, wxID_ANY, _("Show Audio...")); + grid->Add (_show, wxGBPosition (r, 0)); + ++r; + add_label_to_grid_bag_sizer (grid, this, _("Gain"), true, wxGBPosition (r, 0)); _gain = new ContentSpinCtrlDouble ( this, @@ -92,11 +98,19 @@ AudioPanel::AudioPanel (ContentPanel* p) _gain->wrapped()->SetIncrement (0.5); _delay->wrapped()->SetRange (-1000, 1000); - _gain_calculate_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&AudioPanel::gain_calculate_button_clicked, this)); + _show->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&AudioPanel::show_clicked, this)); + _gain_calculate_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&AudioPanel::gain_calculate_button_clicked, this)); _mapping_connection = _mapping->Changed.connect (boost::bind (&AudioPanel::mapping_changed, this, _1)); } +AudioPanel::~AudioPanel () +{ + if (_audio_dialog) { + _audio_dialog->Destroy (); + _audio_dialog = 0; + } +} void AudioPanel::film_changed (Film::Property property) @@ -190,3 +204,20 @@ AudioPanel::content_selection_changed () film_content_changed (AudioContentProperty::AUDIO_STREAMS); } + +void +AudioPanel::show_clicked () +{ + if (_audio_dialog) { + _audio_dialog->Destroy (); + _audio_dialog = 0; + } + + AudioContentList ac = _parent->selected_audio (); + if (ac.size() != 1) { + return; + } + + _audio_dialog = new AudioDialog (this, _parent->film (), ac.front ()); + _audio_dialog->Show (); +} diff --git a/src/wx/audio_panel.h b/src/wx/audio_panel.h index 2856cec4d..e4ccfaf3d 100644 --- a/src/wx/audio_panel.h +++ b/src/wx/audio_panel.h @@ -26,26 +26,31 @@ class wxButton; class wxChoice; class wxStaticText; class AudioMappingView; +class AudioDialog; class AudioPanel : public ContentSubPanel { public: AudioPanel (ContentPanel *); + ~AudioPanel (); void film_changed (Film::Property); void film_content_changed (int); void content_selection_changed (); private: + void show_clicked (); void gain_calculate_button_clicked (); void mapping_changed (AudioMapping); void setup_description (); + wxButton* _show; ContentSpinCtrlDouble* _gain; wxButton* _gain_calculate_button; ContentSpinCtrl* _delay; AudioMappingView* _mapping; wxStaticText* _description; + AudioDialog* _audio_dialog; boost::signals2::scoped_connection _mapping_connection; }; -- 2.30.2