summaryrefslogtreecommitdiff
path: root/src/wx
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-03-01 23:36:22 +0000
committerCarl Hetherington <cth@carlh.net>2013-03-01 23:36:22 +0000
commitab1a666e724911c41dfe08fc96748b38ace839c1 (patch)
tree3b9bd2f9fe80156e5dfaf4e5cb72080e21ba9816 /src/wx
parentb1b3e2e30ce8152b03c9cd3502a00b1814c654ea (diff)
parentff950a024d0bfd892354d53e851c3915a68d2c89 (diff)
Merge.
Diffstat (limited to 'src/wx')
-rw-r--r--src/wx/audio_dialog.cc201
-rw-r--r--src/wx/audio_dialog.h51
-rw-r--r--src/wx/audio_plot.cc272
-rw-r--r--src/wx/audio_plot.h61
-rw-r--r--src/wx/film_editor.cc40
-rw-r--r--src/wx/film_editor.h5
-rw-r--r--src/wx/film_viewer.cc9
-rw-r--r--src/wx/job_manager_view.cc1
-rw-r--r--src/wx/wscript2
9 files changed, 626 insertions, 16 deletions
diff --git a/src/wx/audio_dialog.cc b/src/wx/audio_dialog.cc
new file mode 100644
index 000000000..5bac8eabe
--- /dev/null
+++ b/src/wx/audio_dialog.cc
@@ -0,0 +1,201 @@
+/*
+ Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <boost/filesystem.hpp>
+#include "audio_dialog.h"
+#include "audio_plot.h"
+#include "audio_analysis.h"
+#include "film.h"
+#include "wx_util.h"
+
+using boost::shared_ptr;
+using boost::bind;
+using boost::optional;
+
+AudioDialog::AudioDialog (wxWindow* parent)
+ : wxDialog (parent, wxID_ANY, _("Audio"), wxDefaultPosition, wxSize (640, 512), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
+ , _plot (0)
+{
+ wxBoxSizer* sizer = new wxBoxSizer (wxHORIZONTAL);
+
+ _plot = new AudioPlot (this);
+ sizer->Add (_plot, 1, wxALL, 12);
+
+ wxBoxSizer* side = new wxBoxSizer (wxVERTICAL);
+
+ {
+ wxStaticText* m = new wxStaticText (this, wxID_ANY, _("Channels"));
+ side->Add (m, 1, wxALIGN_CENTER_VERTICAL | wxTOP, 16);
+ }
+
+
+ for (int i = 0; i < MAX_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]->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (AudioDialog::channel_clicked), 0, this);
+ }
+
+ {
+ wxStaticText* m = new wxStaticText (this, wxID_ANY, _("Type"));
+ side->Add (m, 1, wxALIGN_CENTER_VERTICAL | wxTOP, 16);
+ }
+
+ wxString const types[] = {
+ _("Peak"),
+ _("RMS")
+ };
+
+ for (int i = 0; i < AudioPoint::COUNT; ++i) {
+ _type_checkbox[i] = new wxCheckBox (this, wxID_ANY, types[i]);
+ side->Add (_type_checkbox[i], 1, wxEXPAND | wxALL, 3);
+ _type_checkbox[i]->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (AudioDialog::type_clicked), 0, this);
+ }
+
+ {
+ wxStaticText* m = new wxStaticText (this, wxID_ANY, _("Smoothing"));
+ side->Add (m, 1, wxALIGN_CENTER_VERTICAL | wxTOP, 16);
+ }
+
+ _smoothing = new wxSlider (this, wxID_ANY, AudioPlot::max_smoothing / 2, 1, AudioPlot::max_smoothing);
+ _smoothing->Connect (wxID_ANY, wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler (AudioDialog::smoothing_changed), 0, this);
+ side->Add (_smoothing, 1, wxEXPAND);
+
+ sizer->Add (side, 0, wxALL, 12);
+
+ SetSizer (sizer);
+ sizer->Layout ();
+ sizer->SetSizeHints (this);
+}
+
+void
+AudioDialog::set_film (boost::shared_ptr<Film> f)
+{
+ _film_changed_connection.disconnect ();
+ _film_audio_analysis_finished_connection.disconnect ();
+
+ _film = f;
+
+ try_to_load_analysis ();
+ setup_channels ();
+ _plot->set_gain (_film->audio_gain ());
+
+ _film_changed_connection = _film->Changed.connect (bind (&AudioDialog::film_changed, this, _1));
+ _film_audio_analysis_finished_connection = _film->AudioAnalysisFinished.connect (bind (&AudioDialog::try_to_load_analysis, this));
+
+ SetTitle (std_to_wx (String::compose (wx_to_std (_("DVD-o-matic audio - %1")), _film->name())));
+}
+
+void
+AudioDialog::setup_channels ()
+{
+ if (!_film->audio_stream()) {
+ return;
+ }
+
+ AudioMapping m (_film->audio_stream()->channels ());
+
+ for (int i = 0; i < MAX_AUDIO_CHANNELS; ++i) {
+ if (m.dcp_to_source(static_cast<libdcp::Channel>(i))) {
+ _channel_checkbox[i]->Show ();
+ } else {
+ _channel_checkbox[i]->Hide ();
+ }
+ }
+}
+
+void
+AudioDialog::try_to_load_analysis ()
+{
+ shared_ptr<AudioAnalysis> a;
+
+ if (boost::filesystem::exists (_film->audio_analysis_path())) {
+ a.reset (new AudioAnalysis (_film->audio_analysis_path ()));
+ } else {
+ if (IsShown ()) {
+ _film->analyse_audio ();
+ }
+ }
+
+ _plot->set_analysis (a);
+
+ AudioMapping m (_film->audio_stream()->channels ());
+ optional<libdcp::Channel> c = m.source_to_dcp (0);
+ if (c) {
+ _channel_checkbox[c.get()]->SetValue (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);
+ }
+}
+
+void
+AudioDialog::channel_clicked (wxCommandEvent& ev)
+{
+ int c = 0;
+ while (c < MAX_AUDIO_CHANNELS && ev.GetEventObject() != _channel_checkbox[c]) {
+ ++c;
+ }
+
+ assert (c < MAX_AUDIO_CHANNELS);
+
+ AudioMapping m (_film->audio_stream()->channels ());
+ optional<int> s = m.dcp_to_source (static_cast<libdcp::Channel> (c));
+ if (s) {
+ _plot->set_channel_visible (s.get(), _channel_checkbox[c]->GetValue ());
+ }
+}
+
+void
+AudioDialog::film_changed (Film::Property p)
+{
+ switch (p) {
+ case Film::AUDIO_GAIN:
+ _plot->set_gain (_film->audio_gain ());
+ break;
+ case Film::CONTENT_AUDIO_STREAM:
+ case Film::EXTERNAL_AUDIO:
+ case Film::USE_CONTENT_AUDIO:
+ setup_channels ();
+ break;
+ default:
+ break;
+ }
+}
+
+void
+AudioDialog::type_clicked (wxCommandEvent& ev)
+{
+ int t = 0;
+ while (t < AudioPoint::COUNT && ev.GetEventObject() != _type_checkbox[t]) {
+ ++t;
+ }
+
+ assert (t < AudioPoint::COUNT);
+
+ _plot->set_type_visible (t, _type_checkbox[t]->GetValue ());
+}
+
+void
+AudioDialog::smoothing_changed (wxScrollEvent &)
+{
+ _plot->set_smoothing (_smoothing->GetValue ());
+}
diff --git a/src/wx/audio_dialog.h b/src/wx/audio_dialog.h
new file mode 100644
index 000000000..16cb356fe
--- /dev/null
+++ b/src/wx/audio_dialog.h
@@ -0,0 +1,51 @@
+/*
+ Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <boost/shared_ptr.hpp>
+#include <boost/signals2.hpp>
+#include <wx/wx.h>
+#include "lib/film.h"
+#include "lib/audio_analysis.h"
+
+class AudioPlot;
+class Film;
+
+class AudioDialog : public wxDialog
+{
+public:
+ AudioDialog (wxWindow *);
+
+ void set_film (boost::shared_ptr<Film>);
+
+private:
+ void film_changed (Film::Property);
+ void channel_clicked (wxCommandEvent &);
+ void type_clicked (wxCommandEvent &);
+ void smoothing_changed (wxScrollEvent &);
+ void try_to_load_analysis ();
+ void setup_channels ();
+
+ boost::shared_ptr<Film> _film;
+ AudioPlot* _plot;
+ wxCheckBox* _channel_checkbox[MAX_AUDIO_CHANNELS];
+ wxCheckBox* _type_checkbox[AudioPoint::COUNT];
+ wxSlider* _smoothing;
+ boost::signals2::scoped_connection _film_changed_connection;
+ boost::signals2::scoped_connection _film_audio_analysis_finished_connection;
+};
diff --git a/src/wx/audio_plot.cc b/src/wx/audio_plot.cc
new file mode 100644
index 000000000..af8460a16
--- /dev/null
+++ b/src/wx/audio_plot.cc
@@ -0,0 +1,272 @@
+/*
+ Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <iostream>
+#include <boost/bind.hpp>
+#include <wx/graphics.h>
+#include "audio_plot.h"
+#include "lib/decoder_factory.h"
+#include "lib/audio_decoder.h"
+#include "lib/audio_analysis.h"
+#include "wx/wx_util.h"
+
+using std::cout;
+using std::vector;
+using std::list;
+using std::max;
+using std::min;
+using boost::bind;
+using boost::shared_ptr;
+
+int const AudioPlot::_minimum = -70;
+int const AudioPlot::max_smoothing = 128;
+
+AudioPlot::AudioPlot (wxWindow* parent)
+ : wxPanel (parent)
+ , _gain (0)
+ , _smoothing (max_smoothing / 2)
+{
+ SetDoubleBuffered (true);
+
+ for (int i = 0; i < MAX_AUDIO_CHANNELS; ++i) {
+ _channel_visible[i] = false;
+ }
+
+ for (int i = 0; i < AudioPoint::COUNT; ++i) {
+ _type_visible[i] = false;
+ }
+
+ _colours.push_back (wxColour ( 0, 0, 0));
+ _colours.push_back (wxColour (255, 0, 0));
+ _colours.push_back (wxColour ( 0, 255, 0));
+ _colours.push_back (wxColour (139, 0, 204));
+ _colours.push_back (wxColour ( 0, 0, 255));
+ _colours.push_back (wxColour (100, 100, 100));
+
+ Connect (wxID_ANY, wxEVT_PAINT, wxPaintEventHandler (AudioPlot::paint), 0, this);
+
+ SetMinSize (wxSize (640, 512));
+}
+
+void
+AudioPlot::set_analysis (shared_ptr<AudioAnalysis> a)
+{
+ _analysis = a;
+
+ for (int i = 0; i < MAX_AUDIO_CHANNELS; ++i) {
+ _channel_visible[i] = false;
+ }
+
+ for (int i = 0; i < AudioPoint::COUNT; ++i) {
+ _type_visible[i] = false;
+ }
+
+ Refresh ();
+}
+
+void
+AudioPlot::set_channel_visible (int c, bool v)
+{
+ _channel_visible[c] = v;
+ Refresh ();
+}
+
+void
+AudioPlot::set_type_visible (int t, bool v)
+{
+ _type_visible[t] = v;
+ Refresh ();
+}
+
+void
+AudioPlot::paint (wxPaintEvent &)
+{
+ wxPaintDC dc (this);
+
+ wxGraphicsContext* gc = wxGraphicsContext::Create (dc);
+ if (!gc) {
+ return;
+ }
+
+ if (!_analysis || _analysis->channels() == 0) {
+ gc->SetFont (gc->CreateFont (*wxNORMAL_FONT));
+ gc->DrawText (_("Please wait; audio is being analysed..."), 32, 32);
+ return;
+ }
+
+ wxGraphicsPath grid = gc->CreatePath ();
+ gc->SetFont (gc->CreateFont (*wxSMALL_FONT));
+ wxDouble db_label_height;
+ wxDouble db_label_descent;
+ wxDouble db_label_leading;
+ gc->GetTextExtent ("-80dB", &_db_label_width, &db_label_height, &db_label_descent, &db_label_leading);
+
+ _db_label_width += 8;
+
+ int const data_width = GetSize().GetWidth() - _db_label_width;
+ /* Assume all channels have the same number of points */
+ _x_scale = data_width / float (_analysis->points (0));
+ _height = GetSize().GetHeight ();
+ _y_origin = 32;
+ _y_scale = (_height - _y_origin) / -_minimum;
+
+ for (int i = _minimum; i <= 0; i += 10) {
+ int const y = (_height - (i - _minimum) * _y_scale) - _y_origin;
+ grid.MoveToPoint (_db_label_width - 4, y);
+ grid.AddLineToPoint (_db_label_width + data_width, y);
+ gc->DrawText (std_to_wx (String::compose ("%1dB", i)), 0, y - (db_label_height / 2));
+ }
+
+ gc->SetPen (*wxLIGHT_GREY_PEN);
+ gc->StrokePath (grid);
+
+ gc->DrawText (_("Time"), data_width, _height - _y_origin + db_label_height / 2);
+
+
+ if (_type_visible[AudioPoint::PEAK]) {
+ for (int c = 0; c < MAX_AUDIO_CHANNELS; ++c) {
+ wxGraphicsPath p = gc->CreatePath ();
+ if (_channel_visible[c] && c < _analysis->channels()) {
+ plot_peak (p, c);
+ }
+ wxColour const col = _colours[c];
+#if wxMAJOR_VERSION == 2 && wxMINOR_VERSION >= 9
+ gc->SetPen (*wxThePenList->FindOrCreatePen (wxColour (col.Red(), col.Green(), col.Blue(), col.Alpha() / 2), 1, wxPENSTYLE_SOLID));
+#else
+ gc->SetPen (*wxThePenList->FindOrCreatePen (wxColour (col.Red(), col.Green(), col.Blue(), col.Alpha() / 2), 1, wxSOLID));
+#endif
+ gc->StrokePath (p);
+ }
+ }
+
+ if (_type_visible[AudioPoint::RMS]) {
+ for (int c = 0; c < MAX_AUDIO_CHANNELS; ++c) {
+ wxGraphicsPath p = gc->CreatePath ();
+ if (_channel_visible[c] && c < _analysis->channels()) {
+ plot_rms (p, c);
+ }
+ wxColour const col = _colours[c];
+#if wxMAJOR_VERSION == 2 && wxMINOR_VERSION >= 9
+ gc->SetPen (*wxThePenList->FindOrCreatePen (col, 1, wxPENSTYLE_SOLID));
+#else
+ gc->SetPen (*wxThePenList->FindOrCreatePen (col, 1, wxSOLID));
+#endif
+ gc->StrokePath (p);
+ }
+ }
+
+ wxGraphicsPath axes = gc->CreatePath ();
+ axes.MoveToPoint (_db_label_width, 0);
+ axes.AddLineToPoint (_db_label_width, _height - _y_origin);
+ axes.AddLineToPoint (_db_label_width + data_width, _height - _y_origin);
+ gc->SetPen (*wxBLACK_PEN);
+ gc->StrokePath (axes);
+
+ delete gc;
+}
+
+float
+AudioPlot::y_for_linear (float p) const
+{
+ return _height - (20 * log10(p) - _minimum + _gain) * _y_scale - _y_origin;
+}
+
+void
+AudioPlot::plot_peak (wxGraphicsPath& path, int channel) const
+{
+ path.MoveToPoint (_db_label_width, y_for_linear (_analysis->get_point(channel, 0)[AudioPoint::PEAK]));
+
+ float peak = 0;
+ int const N = _analysis->points(channel);
+ for (int i = 0; i < N; ++i) {
+ float const p = _analysis->get_point(channel, i)[AudioPoint::PEAK];
+ peak -= 0.01f * (1 - log10 (_smoothing) / log10 (max_smoothing));
+ if (p > peak) {
+ peak = p;
+ } else if (peak < 0) {
+ peak = 0;
+ }
+
+ path.AddLineToPoint (_db_label_width + i * _x_scale, y_for_linear (peak));
+ }
+}
+
+void
+AudioPlot::plot_rms (wxGraphicsPath& path, int channel) const
+{
+ path.MoveToPoint (_db_label_width, y_for_linear (_analysis->get_point(channel, 0)[AudioPoint::RMS]));
+
+ list<float> smoothing;
+
+ int const N = _analysis->points(channel);
+
+ float const first = _analysis->get_point(channel, 0)[AudioPoint::RMS];
+ float const last = _analysis->get_point(channel, N - 1)[AudioPoint::RMS];
+
+ int const before = _smoothing / 2;
+ int const after = _smoothing - before;
+
+ /* Pre-load the smoothing list */
+ for (int i = 0; i < before; ++i) {
+ smoothing.push_back (first);
+ }
+ for (int i = 0; i < after; ++i) {
+ if (i < N) {
+ smoothing.push_back (_analysis->get_point(channel, i)[AudioPoint::RMS]);
+ } else {
+ smoothing.push_back (last);
+ }
+ }
+
+ for (int i = 0; i < N; ++i) {
+
+ int const next_for_window = i + after;
+
+ if (next_for_window < N) {
+ smoothing.push_back (_analysis->get_point(channel, i)[AudioPoint::RMS]);
+ } else {
+ smoothing.push_back (last);
+ }
+
+ smoothing.pop_front ();
+
+ float p = 0;
+ for (list<float>::const_iterator j = smoothing.begin(); j != smoothing.end(); ++j) {
+ p += pow (*j, 2);
+ }
+
+ p = sqrt (p / smoothing.size ());
+
+ path.AddLineToPoint (_db_label_width + i * _x_scale, y_for_linear (p));
+ }
+}
+
+void
+AudioPlot::set_gain (float g)
+{
+ _gain = g;
+ Refresh ();
+}
+
+void
+AudioPlot::set_smoothing (int s)
+{
+ _smoothing = s;
+ Refresh ();
+}
diff --git a/src/wx/audio_plot.h b/src/wx/audio_plot.h
new file mode 100644
index 000000000..7b2955e27
--- /dev/null
+++ b/src/wx/audio_plot.h
@@ -0,0 +1,61 @@
+/*
+ Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include <vector>
+#include <boost/shared_ptr.hpp>
+#include <wx/wx.h>
+#include "util.h"
+#include "audio_analysis.h"
+
+class AudioPlot : public wxPanel
+{
+public:
+ AudioPlot (wxWindow *);
+
+ 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);
+
+ static const int max_smoothing;
+
+private:
+ void paint (wxPaintEvent &);
+
+ boost::shared_ptr<AudioAnalysis> _analysis;
+ bool _channel_visible[MAX_AUDIO_CHANNELS];
+ bool _type_visible[AudioPoint::COUNT];
+ /** gain to apply in dB */
+ float _gain;
+ int _smoothing;
+ std::vector<wxColour> _colours;
+
+ void plot_peak (wxGraphicsPath &, int) const;
+ void plot_rms (wxGraphicsPath &, int) const;
+ float y_for_linear (float) const;
+
+ double _db_label_width;
+ int _height;
+ int _y_origin;
+ float _x_scale;
+ float _y_scale;
+
+ static const int _minimum;
+};
diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc
index 850466445..362243ef3 100644
--- a/src/wx/film_editor.cc
+++ b/src/wx/film_editor.cc
@@ -45,6 +45,7 @@
#include "sound_processor.h"
#include "dci_metadata_dialog.h"
#include "scaler.h"
+#include "audio_dialog.h"
using std::string;
using std::cout;
@@ -62,6 +63,7 @@ FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent)
: wxPanel (parent)
, _film (f)
, _generally_sensitive (true)
+ , _audio_dialog (0)
{
wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
SetSizer (s);
@@ -204,6 +206,7 @@ FilmEditor::connect_to_widgets ()
_audio_gain_calculate_button->Connect (
wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::audio_gain_calculate_button_clicked), 0, this
);
+ _show_audio->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::show_audio_clicked), 0, this);
_audio_delay->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::audio_delay_changed), 0, this);
_use_content_audio->Connect (wxID_ANY, wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler (FilmEditor::use_audio_changed), 0, this);
_use_external_audio->Connect (wxID_ANY, wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler (FilmEditor::use_audio_changed), 0, this);
@@ -303,6 +306,10 @@ FilmEditor::make_audio_panel ()
wxFlexGridSizer* grid = new wxFlexGridSizer (2, 4, 4);
_audio_sizer->Add (grid, 0, wxALL, 8);
+ _show_audio = new wxButton (_audio_panel, wxID_ANY, _("Show Audio..."));
+ grid->Add (_show_audio, 1);
+ grid->AddSpacer (0);
+
{
video_control (add_label_to_sizer (grid, _audio_panel, _("Audio Gain")));
wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
@@ -340,21 +347,8 @@ FilmEditor::make_audio_panel ()
grid->Add (_use_external_audio);
grid->AddSpacer (0);
- assert (MAX_AUDIO_CHANNELS == 6);
-
- /// TRANSLATORS: these are the names of audio channels; Lfe (sub) is the low-frequency
- /// enhancement channel (sub-woofer).
- wxString const channels[] = {
- _("Left"),
- _("Right"),
- _("Centre"),
- _("Lfe (sub)"),
- _("Left surround"),
- _("Right surround"),
- };
-
for (int i = 0; i < MAX_AUDIO_CHANNELS; ++i) {
- add_label_to_sizer (grid, _audio_panel, channels[i]);
+ add_label_to_sizer (grid, _audio_panel, std_to_wx (audio_channel_name (i)));
_external_audio[i] = new wxFilePickerCtrl (_audio_panel, wxID_ANY, wxT (""), _("Select Audio File"), wxT ("*.wav"));
grid->Add (_external_audio[i], 1, wxEXPAND);
}
@@ -755,6 +749,10 @@ FilmEditor::set_film (shared_ptr<Film> f)
} else {
FileChanged (wx_to_std (N_("")));
}
+
+ if (_audio_dialog) {
+ _audio_dialog->set_film (_film);
+ }
film_changed (Film::NAME);
film_changed (Film::USE_DCI_NAME);
@@ -816,6 +814,7 @@ FilmEditor::set_things_sensitive (bool s)
_j2k_bandwidth->Enable (s);
_audio_gain->Enable (s);
_audio_gain_calculate_button->Enable (s);
+ _show_audio->Enable (s);
_audio_delay->Enable (s);
_still_duration->Enable (s);
@@ -1174,3 +1173,16 @@ FilmEditor::setup_dcp_name ()
_dcp_name->SetLabel (std_to_wx (s));
}
}
+
+void
+FilmEditor::show_audio_clicked (wxCommandEvent &)
+{
+ if (_audio_dialog) {
+ _audio_dialog->Destroy ();
+ _audio_dialog = 0;
+ }
+
+ _audio_dialog = new AudioDialog (this);
+ _audio_dialog->Show ();
+ _audio_dialog->set_film (_film);
+}
diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h
index 8cb90b481..2af747bb0 100644
--- a/src/wx/film_editor.h
+++ b/src/wx/film_editor.h
@@ -29,8 +29,8 @@
#include "lib/film.h"
class wxNotebook;
-
class Film;
+class AudioDialog;
/** @class FilmEditor
* @brief A wx widget to edit a film's metadata, and perform various functions.
@@ -70,6 +70,7 @@ private:
void scaler_changed (wxCommandEvent &);
void audio_gain_changed (wxCommandEvent &);
void audio_gain_calculate_button_clicked (wxCommandEvent &);
+ void show_audio_clicked (wxCommandEvent &);
void audio_delay_changed (wxCommandEvent &);
void with_subtitles_toggled (wxCommandEvent &);
void subtitle_offset_changed (wxCommandEvent &);
@@ -145,6 +146,7 @@ private:
wxSpinCtrl* _audio_gain;
/** A button to open the gain calculation dialogue */
wxButton* _audio_gain_calculate_button;
+ wxButton* _show_audio;
/** The Film's audio delay */
wxSpinCtrl* _audio_delay;
wxCheckBox* _with_subtitles;
@@ -177,4 +179,5 @@ private:
std::vector<Format const *> _formats;
bool _generally_sensitive;
+ AudioDialog* _audio_dialog;
};
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc
index 3705f38bb..5eba7fd80 100644
--- a/src/wx/film_viewer.cc
+++ b/src/wx/film_viewer.cc
@@ -101,7 +101,14 @@ FilmViewer::film_changed (Film::Property p)
o.decode_audio = false;
o.decode_subtitles = true;
o.video_sync = false;
- _decoders = decoder_factory (_film, o);
+
+ try {
+ _decoders = decoder_factory (_film, o);
+ } catch (StringError& e) {
+ error_dialog (this, wxString::Format (_("Could not open content file (%s)"), e.what()));
+ return;
+ }
+
if (_decoders.video == 0) {
break;
}
diff --git a/src/wx/job_manager_view.cc b/src/wx/job_manager_view.cc
index 7537da287..7361f29a8 100644
--- a/src/wx/job_manager_view.cc
+++ b/src/wx/job_manager_view.cc
@@ -109,6 +109,7 @@ JobManagerView::update ()
if ((*i)->finished() && !_job_records[*i].finalised) {
_job_records[*i].gauge->SetValue (100);
checked_set (_job_records[*i].message, st);
+ (*i)->Finished ();
_job_records[*i].finalised = true;
if (!(*i)->error_details().empty ()) {
_job_records[*i].details->Enable (true);
diff --git a/src/wx/wscript b/src/wx/wscript
index 92ff440cd..cc303f5e8 100644
--- a/src/wx/wscript
+++ b/src/wx/wscript
@@ -4,6 +4,8 @@ from waflib import Logs
import i18n
sources = """
+ audio_dialog.cc
+ audio_plot.cc
config_dialog.cc
dci_metadata_dialog.cc
dir_picker_ctrl.cc