diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-06-03 15:31:21 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-06-03 15:31:21 +0100 |
| commit | f98caf4af896e9be943046b84586da5c2e103f18 (patch) | |
| tree | 993f719e293667c432c95026dc2bfd53d5b84982 /src/wx | |
| parent | 92c377d1b9e781fbb4b1f1b7a76ca7dba0bd637f (diff) | |
Make show audio work on the whole DCP, not individual content.
Diffstat (limited to 'src/wx')
| -rw-r--r-- | src/wx/audio_dialog.cc | 54 | ||||
| -rw-r--r-- | src/wx/audio_dialog.h | 6 | ||||
| -rw-r--r-- | src/wx/audio_panel.cc | 30 | ||||
| -rw-r--r-- | src/wx/audio_panel.h | 4 | ||||
| -rw-r--r-- | src/wx/audio_plot.cc | 10 | ||||
| -rw-r--r-- | src/wx/audio_plot.h | 3 | ||||
| -rw-r--r-- | src/wx/dcp_panel.cc | 27 | ||||
| -rw-r--r-- | src/wx/dcp_panel.h | 6 |
8 files changed, 65 insertions, 75 deletions
diff --git a/src/wx/audio_dialog.cc b/src/wx/audio_dialog.cc index 11de9586b..0034e793d 100644 --- a/src/wx/audio_dialog.cc +++ b/src/wx/audio_dialog.cc @@ -17,13 +17,15 @@ */ -#include <boost/filesystem.hpp> -#include "lib/audio_analysis.h" -#include "lib/film.h" -#include "lib/audio_content.h" #include "audio_dialog.h" #include "audio_plot.h" #include "wx_util.h" +#include "lib/audio_analysis.h" +#include "lib/film.h" +#include "lib/analyse_audio_job.h" +#include "lib/job_manager.h" +#include "lib/playlist.h" +#include <boost/filesystem.hpp> using boost::shared_ptr; using boost::bind; @@ -97,18 +99,13 @@ AudioDialog::AudioDialog (wxWindow* parent, shared_ptr<Film> film) } void -AudioDialog::set_content (shared_ptr<AudioContent> c) +AudioDialog::set_playlist (shared_ptr<const Playlist> p) { - _content_changed_connection.disconnect (); - - _content = c; - + _playlist_connection.disconnect (); + _playlist = p; + _playlist_connection = _playlist->ContentChanged.connect (boost::bind (&AudioDialog::try_to_load_analysis, this)); try_to_load_analysis (); - _plot->set_gain (_content->audio_gain ()); - - _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_summary()).data())); + SetTitle (_("DCP-o-matic audio")); } void @@ -118,18 +115,27 @@ AudioDialog::try_to_load_analysis () return; } - if (!boost::filesystem::exists (_content->audio_analysis_path())) { + shared_ptr<const Film> film = _film.lock (); + DCPOMATIC_ASSERT (film); + + boost::filesystem::path path = film->audio_analysis_path (_playlist); + + if (!boost::filesystem::exists (path)) { _plot->set_analysis (shared_ptr<AudioAnalysis> ()); _analysis.reset (); - _analysis_finished_connection = _content->analyse_audio (bind (&AudioDialog::analysis_finished, this)); + shared_ptr<AnalyseAudioJob> job (new AnalyseAudioJob (film, _playlist)); + _analysis_finished_connection = job->Finished.connect (bind (&AudioDialog::analysis_finished, this)); + JobManager::instance()->add (job); return; } try { - _analysis.reset (new AudioAnalysis (_content->audio_analysis_path ())); + _analysis.reset (new AudioAnalysis (path)); } catch (xmlpp::exception& e) { /* Probably an old-style analysis file: recreate it */ - _analysis_finished_connection = _content->analyse_audio (bind (&AudioDialog::analysis_finished, this)); + shared_ptr<AnalyseAudioJob> job (new AnalyseAudioJob (film, _playlist)); + _analysis_finished_connection = job->Finished.connect (bind (&AudioDialog::analysis_finished, this)); + JobManager::instance()->add (job); return; } @@ -166,7 +172,10 @@ AudioDialog::try_to_load_analysis () void AudioDialog::analysis_finished () { - if (!boost::filesystem::exists (_content->audio_analysis_path())) { + shared_ptr<const Film> film = _film.lock (); + DCPOMATIC_ASSERT (film); + + 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. */ @@ -193,10 +202,7 @@ AudioDialog::channel_clicked (wxCommandEvent& ev) void AudioDialog::content_changed (int p) { - if (p == AudioContentProperty::AUDIO_GAIN) { - _plot->set_gain (_content->audio_gain ()); - setup_peak_time (); - } else if (p == AudioContentProperty::AUDIO_STREAMS) { + if (p == AudioContentProperty::AUDIO_GAIN || p == AudioContentProperty::AUDIO_STREAMS) { try_to_load_analysis (); } } @@ -232,7 +238,7 @@ AudioDialog::setup_peak_time () return; } - float peak_dB = 20 * log10 (_analysis->peak().get()) + _content->audio_gain(); + float peak_dB = 20 * log10 (_analysis->peak().get()); _peak_time->SetLabel ( wxString::Format ( diff --git a/src/wx/audio_dialog.h b/src/wx/audio_dialog.h index aef8ea944..b6cc41254 100644 --- a/src/wx/audio_dialog.h +++ b/src/wx/audio_dialog.h @@ -31,7 +31,7 @@ class AudioDialog : public wxDialog public: AudioDialog (wxWindow *, boost::shared_ptr<Film> film); - void set_content (boost::shared_ptr<AudioContent>); + void set_playlist (boost::shared_ptr<const Playlist>); private: void content_changed (int); @@ -42,7 +42,7 @@ private: void analysis_finished (); void setup_peak_time (); - boost::shared_ptr<AudioContent> _content; + boost::shared_ptr<const Playlist> _playlist; boost::shared_ptr<AudioAnalysis> _analysis; boost::weak_ptr<Film> _film; AudioPlot* _plot; @@ -50,6 +50,6 @@ private: wxCheckBox* _channel_checkbox[MAX_DCP_AUDIO_CHANNELS]; wxCheckBox* _type_checkbox[AudioPoint::COUNT]; wxSlider* _smoothing; - boost::signals2::scoped_connection _content_changed_connection; + boost::signals2::scoped_connection _playlist_connection; boost::signals2::scoped_connection _analysis_finished_connection; }; diff --git a/src/wx/audio_panel.cc b/src/wx/audio_panel.cc index 436e6db4c..4c2eaafc5 100644 --- a/src/wx/audio_panel.cc +++ b/src/wx/audio_panel.cc @@ -20,7 +20,6 @@ #include "lib/config.h" #include "lib/ffmpeg_content.h" #include "lib/cinema_sound_processor.h" -#include "audio_dialog.h" #include "audio_panel.h" #include "audio_mapping_view.h" #include "wx_util.h" @@ -41,17 +40,12 @@ 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<AudioContent> ( this, @@ -98,7 +92,6 @@ AudioPanel::AudioPanel (ContentPanel* p) _gain->wrapped()->SetIncrement (0.5); _delay->wrapped()->SetRange (-1000, 1000); - _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)); @@ -163,24 +156,6 @@ AudioPanel::gain_calculate_button_clicked () } 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 ()); - _audio_dialog->Show (); - _audio_dialog->set_content (ac.front ()); -} - -void AudioPanel::setup_description () { AudioContentList ac = _parent->selected_audio (); @@ -206,15 +181,10 @@ AudioPanel::content_selection_changed () { AudioContentList sel = _parent->selected_audio (); - if (_audio_dialog && sel.size() == 1) { - _audio_dialog->set_content (sel.front ()); - } - _gain->set_content (sel); _delay->set_content (sel); _gain_calculate_button->Enable (sel.size() == 1); - _show->Enable (sel.size() == 1); _mapping->Enable (sel.size() == 1); film_content_changed (AudioContentProperty::AUDIO_STREAMS); diff --git a/src/wx/audio_panel.h b/src/wx/audio_panel.h index ad7d6081b..edd3dfcd4 100644 --- a/src/wx/audio_panel.h +++ b/src/wx/audio_panel.h @@ -26,7 +26,6 @@ class wxButton; class wxChoice; class wxStaticText; class AudioMappingView; -class AudioDialog; class AudioPanel : public ContentSubPanel { @@ -39,17 +38,14 @@ public: private: void gain_calculate_button_clicked (); - void show_clicked (); void mapping_changed (AudioMapping); void setup_description (); ContentSpinCtrlDouble<AudioContent>* _gain; wxButton* _gain_calculate_button; - wxButton* _show; ContentSpinCtrl<AudioContent>* _delay; AudioMappingView* _mapping; wxStaticText* _description; - AudioDialog* _audio_dialog; boost::signals2::scoped_connection _mapping_connection; }; diff --git a/src/wx/audio_plot.cc b/src/wx/audio_plot.cc index 16930ffd8..829290d4d 100644 --- a/src/wx/audio_plot.cc +++ b/src/wx/audio_plot.cc @@ -38,7 +38,6 @@ int const AudioPlot::max_smoothing = 128; AudioPlot::AudioPlot (wxWindow* parent) : wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE) - , _gain (0) , _smoothing (max_smoothing / 2) { #ifndef __WXOSX__ @@ -205,7 +204,7 @@ AudioPlot::y_for_linear (float p, Metrics const & metrics) const p = 1e-4; } - return metrics.height - (20 * log10(p) - _minimum + _gain) * metrics.y_scale - metrics.y_origin; + return metrics.height - (20 * log10(p) - _minimum) * metrics.y_scale - metrics.y_origin; } void @@ -289,13 +288,6 @@ AudioPlot::plot_rms (wxGraphicsPath& path, int channel, Metrics const & metrics) } void -AudioPlot::set_gain (float g) -{ - _gain = g; - Refresh (); -} - -void AudioPlot::set_smoothing (int s) { _smoothing = s; diff --git a/src/wx/audio_plot.h b/src/wx/audio_plot.h index adf11e633..846ac22dc 100644 --- a/src/wx/audio_plot.h +++ b/src/wx/audio_plot.h @@ -33,7 +33,6 @@ public: void set_analysis (boost::shared_ptr<AudioAnalysis>); void set_channel_visible (int c, bool v); void set_type_visible (int t, bool v); - void set_gain (float); void set_smoothing (int); void set_message (wxString); @@ -48,8 +47,6 @@ private: boost::shared_ptr<AudioAnalysis> _analysis; bool _channel_visible[MAX_DCP_AUDIO_CHANNELS]; bool _type_visible[AudioPoint::COUNT]; - /** gain to apply in dB */ - float _gain; int _smoothing; std::vector<wxColour> _colours; diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc index 022fe9a06..24c678c57 100644 --- a/src/wx/dcp_panel.cc +++ b/src/wx/dcp_panel.cc @@ -21,6 +21,7 @@ #include "wx_util.h" #include "key_dialog.h" #include "isdcf_metadata_dialog.h" +#include "audio_dialog.h" #include "lib/ratio.h" #include "lib/config.h" #include "lib/dcp_content_type.h" @@ -44,7 +45,8 @@ using boost::lexical_cast; using boost::shared_ptr; DCPPanel::DCPPanel (wxNotebook* n, boost::shared_ptr<Film> f) - : _film (f) + : _audio_dialog (0) + , _film (f) , _generally_sensitive (true) { _panel = new wxPanel (n); @@ -672,11 +674,15 @@ DCPPanel::make_audio_panel () _audio_processor->Append (std_to_wx (ap->name ()), new wxStringClientData (std_to_wx (ap->id ()))); } grid->Add (_audio_processor, wxGBPosition (r, 1)); - + ++r; + + _show_audio = new wxButton (panel, wxID_ANY, _("Show audio...")); + grid->Add (_show_audio, wxGBPosition (r, 0), wxGBSpan (1, 2)); ++r; _audio_channels->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DCPPanel::audio_channels_changed, this)); _audio_processor->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DCPPanel::audio_processor_changed, this)); + _show_audio->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&DCPPanel::show_audio_clicked, this)); return panel; } @@ -698,3 +704,20 @@ DCPPanel::audio_processor_changed () string const s = string_client_data (_audio_processor->GetClientObject (_audio_processor->GetSelection ())); _film->set_audio_processor (AudioProcessor::from_id (s)); } + +void +DCPPanel::show_audio_clicked () +{ + if (!_film) { + return; + } + + if (_audio_dialog) { + _audio_dialog->Destroy (); + _audio_dialog = 0; + } + + AudioDialog* d = new AudioDialog (_panel, _film); + d->Show (); + d->set_playlist (_film->playlist ()); +} diff --git a/src/wx/dcp_panel.h b/src/wx/dcp_panel.h index 3aa97ad53..3179ad73a 100644 --- a/src/wx/dcp_panel.h +++ b/src/wx/dcp_panel.h @@ -31,6 +31,8 @@ class wxButton; class wxSpinCtrl; class wxSizer; +class AudioDialog; + class Film; class DCPPanel : public boost::noncopyable @@ -69,6 +71,7 @@ private: void encrypted_toggled (); void edit_key_clicked (); void audio_processor_changed (); + void show_audio_clicked (); void setup_frame_rate_widget (); void setup_container (); @@ -98,6 +101,7 @@ private: wxSizer* _frame_rate_sizer; wxChoice* _audio_channels; wxChoice* _audio_processor; + wxButton* _show_audio; wxButton* _best_frame_rate; wxCheckBox* _three_d; wxChoice* _resolution; @@ -108,6 +112,8 @@ private: wxStaticText* _key; wxButton* _edit_key; + AudioDialog* _audio_dialog; + boost::shared_ptr<Film> _film; bool _generally_sensitive; }; |
