summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-07-01 18:04:14 +0100
committerCarl Hetherington <cth@carlh.net>2015-07-01 18:04:14 +0100
commit92b6430402753a572c33d594ba0745a4e461edf4 (patch)
treed9bd040ee243cfe0e1730fc2df18d97adc7f2e8e /src
parentc5b9ad09ab5eaf032b0816f619ab5d75254e8597 (diff)
Re-add show audio button and analyse just that content when it is clicked.
Diffstat (limited to 'src')
-rw-r--r--src/lib/analyse_audio_job.cc2
-rw-r--r--src/lib/film.cc4
-rw-r--r--src/lib/film.h2
-rw-r--r--src/wx/audio_dialog.cc19
-rw-r--r--src/wx/audio_dialog.h10
-rw-r--r--src/wx/audio_panel.cc33
-rw-r--r--src/wx/audio_panel.h5
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<const Playlist> playlist) const
{
boost::filesystem::path p = dir ("analysis");
MD5Digester digester;
- BOOST_FOREACH (shared_ptr<Content> i, content ()) {
+ BOOST_FOREACH (shared_ptr<Content> i, playlist->content ()) {
shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (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 Playlist>) 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> film)
+/** @param content Content to analyse, or 0 to analyse all of the film's audio */
+AudioDialog::AudioDialog (wxWindow* parent, shared_ptr<Film> film, shared_ptr<AudioContent> 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)
_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> (_playlist)->add (content);
+ } else {
+ _playlist = film->playlist ();
+ }
}
void
@@ -121,12 +130,12 @@ AudioDialog::try_to_load_analysis ()
shared_ptr<const Film> 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<AudioAnalysis> ());
_analysis.reset ();
- shared_ptr<AnalyseAudioJob> job (new AnalyseAudioJob (film, film->playlist ()));
+ shared_ptr<AnalyseAudioJob> 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<AnalyseAudioJob> job (new AnalyseAudioJob (film, film->playlist ()));
+ shared_ptr<AnalyseAudioJob> 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<const Film> 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 <boost/shared_ptr.hpp>
-#include <boost/signals2.hpp>
-#include <wx/wx.h>
#include "lib/film.h"
#include "lib/audio_analysis.h"
+#include "lib/playlist.h"
+#include <wx/wx.h>
+#include <boost/shared_ptr.hpp>
+#include <boost/signals2.hpp>
class AudioPlot;
class Film;
@@ -29,7 +30,7 @@ class Film;
class AudioDialog : public wxDialog
{
public:
- AudioDialog (wxWindow *, boost::shared_ptr<Film> film);
+ AudioDialog (wxWindow *, boost::shared_ptr<Film> film, boost::shared_ptr<AudioContent> content = boost::shared_ptr<AudioContent> ());
bool Show (bool show = true);
@@ -44,6 +45,7 @@ private:
boost::shared_ptr<AudioAnalysis> _analysis;
boost::weak_ptr<Film> _film;
+ boost::shared_ptr<const Playlist> _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 <wx/spinctrl.h>
#include <boost/lexical_cast.hpp>
#include <boost/foreach.hpp>
@@ -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<AudioContent> (
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<AudioContent>* _gain;
wxButton* _gain_calculate_button;
ContentSpinCtrl<AudioContent>* _delay;
AudioMappingView* _mapping;
wxStaticText* _description;
+ AudioDialog* _audio_dialog;
boost::signals2::scoped_connection _mapping_connection;
};