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 | |
| parent | 92c377d1b9e781fbb4b1f1b7a76ca7dba0bd637f (diff) | |
Make show audio work on the whole DCP, not individual content.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/analyse_audio_job.cc | 15 | ||||
| -rw-r--r-- | src/lib/analyse_audio_job.h | 12 | ||||
| -rw-r--r-- | src/lib/audio_content.cc | 27 | ||||
| -rw-r--r-- | src/lib/audio_content.h | 3 | ||||
| -rw-r--r-- | src/lib/film.cc | 24 | ||||
| -rw-r--r-- | src/lib/film.h | 3 | ||||
| -rw-r--r-- | src/lib/md5_digester.cc | 6 | ||||
| -rw-r--r-- | src/lib/md5_digester.h | 2 | ||||
| -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 |
16 files changed, 108 insertions, 124 deletions
diff --git a/src/lib/analyse_audio_job.cc b/src/lib/analyse_audio_job.cc index cdf623876..31b9dccae 100644 --- a/src/lib/analyse_audio_job.cc +++ b/src/lib/analyse_audio_job.cc @@ -34,9 +34,9 @@ using boost::shared_ptr; int const AnalyseAudioJob::_num_points = 1024; -AnalyseAudioJob::AnalyseAudioJob (shared_ptr<const Film> f, shared_ptr<AudioContent> c) +AnalyseAudioJob::AnalyseAudioJob (shared_ptr<const Film> f, shared_ptr<const Playlist> p) : Job (f) - , _content (c) + , _playlist (p) , _done (0) , _samples_per_point (1) , _overall_peak (0) @@ -60,14 +60,7 @@ AnalyseAudioJob::json_name () const void AnalyseAudioJob::run () { - shared_ptr<AudioContent> content = _content.lock (); - if (!content) { - return; - } - - shared_ptr<Playlist> playlist (new Playlist); - playlist->add (content); - shared_ptr<Player> player (new Player (_film, playlist)); + shared_ptr<Player> player (new Player (_film, _playlist)); player->set_ignore_video (); int64_t const len = _film->length().frames (_film->audio_frame_rate()); @@ -84,7 +77,7 @@ AnalyseAudioJob::run () } _analysis->set_peak (_overall_peak, DCPTime::from_frames (_overall_peak_frame, _film->audio_frame_rate ())); - _analysis->write (content->audio_analysis_path ()); + _analysis->write (_film->audio_analysis_path (_playlist)); set_progress (1); set_state (FINISHED_OK); diff --git a/src/lib/analyse_audio_job.h b/src/lib/analyse_audio_job.h index ec61c0d39..cc913e1f3 100644 --- a/src/lib/analyse_audio_job.h +++ b/src/lib/analyse_audio_job.h @@ -26,19 +26,19 @@ #include "types.h" class AudioBuffers; -class AudioContent; +class Playlist; /** @class AnalyseAudioJob - * @brief A job to analyse the audio of a piece of AudioContent and make a note of its + * @brief A job to analyse the audio of a playlist and make a note of its * broad peak and RMS levels. * - * After computing the peak and RMS levels over the length of the content, the job - * will write a file to Content::audio_analysis_path. + * After computing the peak and RMS levels the job will write a file + * to Playlist::audio_analysis_path. */ class AnalyseAudioJob : public Job { public: - AnalyseAudioJob (boost::shared_ptr<const Film>, boost::shared_ptr<AudioContent>); + AnalyseAudioJob (boost::shared_ptr<const Film>, boost::shared_ptr<const Playlist>); std::string name () const; std::string json_name () const; @@ -47,7 +47,7 @@ public: private: void analyse (boost::shared_ptr<const AudioBuffers>); - boost::weak_ptr<AudioContent> _content; + boost::shared_ptr<const Playlist> _playlist; int64_t _done; int64_t _samples_per_point; std::vector<AudioPoint> _current; diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index b6749d20b..46b80a21c 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -25,6 +25,7 @@ #include "config.h" #include "frame_rate_change.h" #include "raw_convert.h" +#include "playlist.h" #include <libcxml/cxml.h> #include <boost/foreach.hpp> @@ -129,32 +130,6 @@ AudioContent::set_audio_delay (int d) signal_changed (AudioContentProperty::AUDIO_DELAY); } -boost::signals2::connection -AudioContent::analyse_audio (boost::function<void()> finished) -{ - shared_ptr<const Film> film = _film.lock (); - DCPOMATIC_ASSERT (film); - - shared_ptr<AnalyseAudioJob> job (new AnalyseAudioJob (film, dynamic_pointer_cast<AudioContent> (shared_from_this()))); - boost::signals2::connection c = job->Finished.connect (finished); - JobManager::instance()->add (job); - - return c; -} - -boost::filesystem::path -AudioContent::audio_analysis_path () const -{ - shared_ptr<const Film> film = _film.lock (); - if (!film) { - return boost::filesystem::path (); - } - - boost::filesystem::path p = film->audio_analysis_dir (); - p /= digest() + "_" + audio_mapping().digest(); - return p; -} - string AudioContent::technical_summary () const { diff --git a/src/lib/audio_content.h b/src/lib/audio_content.h index 63ce3d0fa..df6527ed0 100644 --- a/src/lib/audio_content.h +++ b/src/lib/audio_content.h @@ -62,13 +62,10 @@ public: AudioMapping audio_mapping () const; void set_audio_mapping (AudioMapping); - boost::filesystem::path audio_analysis_path () const; int resampled_audio_frame_rate () const; bool has_rate_above_48k () const; std::vector<std::string> audio_channel_names () const; - boost::signals2::connection analyse_audio (boost::function<void()>); - void set_audio_gain (double); void set_audio_delay (int); diff --git a/src/lib/film.cc b/src/lib/film.cc index 90bfad6a2..590acedfd 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -42,6 +42,7 @@ #include "environment_info.h" #include "raw_convert.h" #include "audio_processor.h" +#include "md5_digester.h" #include <libcxml/cxml.h> #include <dcp/cpl.h> #include <dcp/signer.h> @@ -247,9 +248,28 @@ Film::filename_safe_name () const } boost::filesystem::path -Film::audio_analysis_dir () const +Film::audio_analysis_path (shared_ptr<const Playlist> playlist) const { - return dir ("analysis"); + boost::filesystem::path p = dir ("analysis"); + + MD5Digester digester; + BOOST_FOREACH (shared_ptr<Content> i, playlist->content ()) { + shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (i); + if (!ac) { + continue; + } + + digester.add (ac->digest ()); + digester.add (ac->audio_mapping().digest ()); + digester.add (ac->audio_gain ()); + } + + if (audio_processor ()) { + digester.add (audio_processor()->id ()); + } + + p /= digester.get (); + return p; } /** Add suitable Jobs to the JobManager to create a DCP for this Film */ diff --git a/src/lib/film.h b/src/lib/film.h index 6008160cd..b0f1a8685 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -68,7 +68,8 @@ public: boost::filesystem::path j2c_path (int, Eyes, bool) const; boost::filesystem::path internal_video_mxf_dir () const; boost::filesystem::path internal_video_mxf_filename () const; - boost::filesystem::path audio_analysis_dir () const; + + boost::filesystem::path audio_analysis_path (boost::shared_ptr<const Playlist>) const; void send_dcp_to_tms (); void make_dcp (); diff --git a/src/lib/md5_digester.cc b/src/lib/md5_digester.cc index 1d4d1974a..df73a6945 100644 --- a/src/lib/md5_digester.cc +++ b/src/lib/md5_digester.cc @@ -43,6 +43,12 @@ MD5Digester::add (void const * data, size_t size) MD5_Update (&_context, data, size); } +void +MD5Digester::add (string const & s) +{ + add (s.c_str (), s.length ()); +} + string MD5Digester::get () const { diff --git a/src/lib/md5_digester.h b/src/lib/md5_digester.h index 981334e28..8ae7e81cf 100644 --- a/src/lib/md5_digester.h +++ b/src/lib/md5_digester.h @@ -34,6 +34,8 @@ public: void add (T data) { add (&data, sizeof (T)); } + + void add (std::string const & s); std::string get () const; 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; }; |
