Separate audio panel out.
authorCarl Hetherington <cth@carlh.net>
Fri, 19 Jul 2013 22:10:40 +0000 (23:10 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 19 Jul 2013 22:10:40 +0000 (23:10 +0100)
src/wx/audio_panel.cc [new file with mode: 0644]
src/wx/audio_panel.h [new file with mode: 0644]
src/wx/film_editor.cc
src/wx/film_editor.h
src/wx/film_editor_panel.h
src/wx/subtitle_panel.cc
src/wx/subtitle_panel.h
src/wx/timing_panel.cc
src/wx/timing_panel.h
src/wx/wscript

diff --git a/src/wx/audio_panel.cc b/src/wx/audio_panel.cc
new file mode 100644 (file)
index 0000000..c27e51b
--- /dev/null
@@ -0,0 +1,284 @@
+/*
+    Copyright (C) 2012-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/lexical_cast.hpp>
+#include <wx/spinctrl.h>
+#include "lib/config.h"
+#include "lib/sound_processor.h"
+#include "audio_dialog.h"
+#include "audio_panel.h"
+#include "audio_mapping_view.h"
+#include "wx_util.h"
+#include "gain_calculator_dialog.h"
+#include "film_editor.h"
+
+using std::vector;
+using std::string;
+using boost::dynamic_pointer_cast;
+using boost::lexical_cast;
+using boost::shared_ptr;
+
+AudioPanel::AudioPanel (FilmEditor* e)
+       : FilmEditorPanel (e, _("Audio"))
+       , _audio_dialog (0)
+{
+       wxFlexGridSizer* grid = new wxFlexGridSizer (3, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
+       _sizer->Add (grid, 0, wxALL, 8);
+
+       _show = new wxButton (this, wxID_ANY, _("Show Audio..."));
+       grid->Add (_show, 1);
+       grid->AddSpacer (0);
+       grid->AddSpacer (0);
+
+       add_label_to_sizer (grid, this, _("Audio Gain"), true);
+       {
+               wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+               _gain = new wxSpinCtrl (this);
+               s->Add (_gain, 1);
+               add_label_to_sizer (s, this, _("dB"), false);
+               grid->Add (s, 1);
+       }
+       
+       _gain_calculate_button = new wxButton (this, wxID_ANY, _("Calculate..."));
+       grid->Add (_gain_calculate_button);
+
+       add_label_to_sizer (grid, this, _("Audio Delay"), false);
+       {
+               wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+               _delay = new wxSpinCtrl (this);
+               s->Add (_delay, 1);
+               /// TRANSLATORS: this is an abbreviation for milliseconds, the unit of time
+               add_label_to_sizer (s, this, _("ms"), false);
+               grid->Add (s);
+       }
+
+       grid->AddSpacer (0);
+
+       add_label_to_sizer (grid, this, _("Audio Stream"), true);
+       _stream = new wxChoice (this, wxID_ANY);
+       grid->Add (_stream, 1, wxEXPAND);
+       _description = new wxStaticText (this, wxID_ANY, wxT (""));
+       grid->AddSpacer (0);
+       
+       grid->Add (_description, 1, wxALIGN_CENTER_VERTICAL | wxLEFT, 8);
+       grid->AddSpacer (0);
+       grid->AddSpacer (0);
+       
+       _mapping = new AudioMappingView (this);
+       _sizer->Add (_mapping, 1, wxEXPAND | wxALL, 6);
+
+       _gain->SetRange (-60, 60);
+       _delay->SetRange (-1000, 1000);
+
+       _delay->Connect  (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (AudioPanel::delay_changed), 0, this);
+       _stream->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,  wxCommandEventHandler (AudioPanel::stream_changed), 0, this);
+       _show->Connect   (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,   wxCommandEventHandler (AudioPanel::show_clicked), 0, this);
+       _gain->Connect   (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (AudioPanel::gain_changed), 0, this);
+       _gain_calculate_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (AudioPanel::gain_calculate_button_clicked), 0, this);
+       _mapping->Changed.connect (boost::bind (&AudioPanel::mapping_changed, this, _1));
+}
+
+
+void
+AudioPanel::film_changed (Film::Property property)
+{
+       switch (property) {
+       case Film::CONTENT:
+               setup_sensitivity ();
+               break;
+       case Film::DCP_AUDIO_CHANNELS:
+               _mapping->set_channels (_editor->film()->dcp_audio_channels ());
+               break;
+       default:
+               break;
+       }
+}
+
+void
+AudioPanel::film_content_changed (
+       shared_ptr<Content>,
+       shared_ptr<AudioContent> audio_content,
+       shared_ptr<SubtitleContent>,
+       shared_ptr<FFmpegContent> ffmpeg_content,
+       int property
+       )
+{
+       if (property == AudioContentProperty::AUDIO_GAIN) {
+               checked_set (_gain, audio_content ? audio_content->audio_gain() : 0);
+       } else if (property == AudioContentProperty::AUDIO_DELAY) {
+               checked_set (_delay, audio_content ? audio_content->audio_delay() : 0);
+       } else if (property == AudioContentProperty::AUDIO_MAPPING) {
+               _mapping->set (audio_content ? audio_content->audio_mapping () : AudioMapping ());
+       } else if (property == FFmpegContentProperty::AUDIO_STREAMS) {
+               _stream->Clear ();
+               if (ffmpeg_content) {
+                       vector<shared_ptr<FFmpegAudioStream> > a = ffmpeg_content->audio_streams ();
+                       for (vector<shared_ptr<FFmpegAudioStream> >::iterator i = a.begin(); i != a.end(); ++i) {
+                               _stream->Append (std_to_wx ((*i)->name), new wxStringClientData (std_to_wx (lexical_cast<string> ((*i)->id))));
+                       }
+                       
+                       if (ffmpeg_content->audio_stream()) {
+                               checked_set (_stream, lexical_cast<string> (ffmpeg_content->audio_stream()->id));
+                       }
+               }
+               setup_sensitivity ();
+       } else if (property == FFmpegContentProperty::AUDIO_STREAM) {
+               setup_sensitivity ();
+       }
+}
+
+void
+AudioPanel::gain_changed (wxCommandEvent &)
+{
+       shared_ptr<AudioContent> ac = _editor->selected_audio_content ();
+       if (!ac) {
+               return;
+       }
+
+       ac->set_audio_gain (_gain->GetValue ());
+}
+
+void
+AudioPanel::delay_changed (wxCommandEvent &)
+{
+       shared_ptr<AudioContent> ac = _editor->selected_audio_content ();
+       if (!ac) {
+               return;
+       }
+
+       ac->set_audio_delay (_delay->GetValue ());
+}
+
+void
+AudioPanel::gain_calculate_button_clicked (wxCommandEvent &)
+{
+       GainCalculatorDialog* d = new GainCalculatorDialog (this);
+       d->ShowModal ();
+
+       if (d->wanted_fader() == 0 || d->actual_fader() == 0) {
+               d->Destroy ();
+               return;
+       }
+       
+       _gain->SetValue (
+               Config::instance()->sound_processor()->db_for_fader_change (
+                       d->wanted_fader (),
+                       d->actual_fader ()
+                       )
+               );
+
+       /* This appears to be necessary, as the change is not signalled,
+          I think.
+       */
+       wxCommandEvent dummy;
+       gain_changed (dummy);
+       
+       d->Destroy ();
+}
+
+void
+AudioPanel::show_clicked (wxCommandEvent &)
+{
+       if (_audio_dialog) {
+               _audio_dialog->Destroy ();
+               _audio_dialog = 0;
+       }
+
+       shared_ptr<Content> c = _editor->selected_content ();
+       if (!c) {
+               return;
+       }
+
+       shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (c);
+       if (!ac) {
+               return;
+       }
+       
+       _audio_dialog = new AudioDialog (this);
+       _audio_dialog->Show ();
+       _audio_dialog->set_content (ac);
+}
+
+
+void
+AudioPanel::setup_sensitivity ()
+{
+       _show->Enable (_editor->film ());
+       _gain->Enable (_editor->generally_sensitive ());
+       _gain_calculate_button->Enable (_editor->generally_sensitive ());
+       _delay->Enable (_editor->generally_sensitive ());
+}
+
+void
+AudioPanel::content_selection_changed ()
+{
+       if (_audio_dialog && _editor->selected_audio_content()) {
+               _audio_dialog->set_content (_editor->selected_audio_content ());
+       }
+}
+
+void
+AudioPanel::stream_changed (wxCommandEvent &)
+{
+       shared_ptr<Content> c = _editor->selected_content ();
+       if (!c) {
+               return;
+       }
+       
+       shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
+       if (!fc) {
+               return;
+       }
+       
+       vector<shared_ptr<FFmpegAudioStream> > a = fc->audio_streams ();
+       vector<shared_ptr<FFmpegAudioStream> >::iterator i = a.begin ();
+       string const s = string_client_data (_stream->GetClientObject (_stream->GetSelection ()));
+       while (i != a.end() && lexical_cast<string> ((*i)->id) != s) {
+               ++i;
+       }
+
+       if (i != a.end ()) {
+               fc->set_audio_stream (*i);
+       }
+
+       if (!fc->audio_stream ()) {
+               _description->SetLabel (wxT (""));
+       } else {
+               wxString s;
+               if (fc->audio_channels() == 1) {
+                       s << _("1 channel");
+               } else {
+                       s << fc->audio_channels() << wxT (" ") << _("channels");
+               }
+               s << wxT (", ") << fc->content_audio_frame_rate() << _("Hz");
+               _description->SetLabel (s);
+       }
+}
+
+void
+AudioPanel::mapping_changed (AudioMapping m)
+{
+       shared_ptr<AudioContent> c = _editor->selected_audio_content ();
+       if (!c) {
+               return;
+       }
+
+       c->set_audio_mapping (m);
+}
+
diff --git a/src/wx/audio_panel.h b/src/wx/audio_panel.h
new file mode 100644 (file)
index 0000000..69f6063
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+    Copyright (C) 2012-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 "film_editor_panel.h"
+
+class wxSpinCtrl;
+class wxButton;
+class wxChoice;
+class wxStaticText;
+class AudioMappingView;
+class AudioDialog;
+
+class AudioPanel : public FilmEditorPanel
+{
+public:
+       AudioPanel (FilmEditor *);
+
+       void film_changed (Film::Property);
+       void film_content_changed (
+               boost::shared_ptr<Content>,
+               boost::shared_ptr<AudioContent>,
+               boost::shared_ptr<SubtitleContent>,
+               boost::shared_ptr<FFmpegContent>,
+               int);
+       void content_selection_changed ();
+
+       void setup_sensitivity ();
+       
+private:
+       void gain_changed (wxCommandEvent &);
+       void gain_calculate_button_clicked (wxCommandEvent &);
+       void show_clicked (wxCommandEvent &);
+       void delay_changed (wxCommandEvent &);
+       void stream_changed (wxCommandEvent &);
+       void mapping_changed (AudioMapping);
+
+       wxSpinCtrl* _gain;
+       wxButton* _gain_calculate_button;
+       wxButton* _show;
+       wxSpinCtrl* _delay;
+       wxChoice* _stream;
+       wxStaticText* _description;
+       AudioMappingView* _mapping;
+       AudioDialog* _audio_dialog;
+};
index 3e2eaa8a282a05ef2d3ca794a303bb1d9b35b53b..94aea9b1a4512bfdcf6e079b3ae76ae6a4687585 100644 (file)
 #include "filter_dialog.h"
 #include "wx_util.h"
 #include "film_editor.h"
-#include "gain_calculator_dialog.h"
 #include "dci_metadata_dialog.h"
-#include "audio_dialog.h"
 #include "timeline_dialog.h"
-#include "audio_mapping_view.h"
 #include "timing_panel.h"
 #include "subtitle_panel.h"
+#include "audio_panel.h"
 
 using std::string;
 using std::cout;
@@ -72,7 +70,6 @@ FilmEditor::FilmEditor (shared_ptr<Film> f, wxWindow* parent)
        : wxPanel (parent)
        , _menu (f, this)
        , _generally_sensitive (true)
-       , _audio_dialog (0)
        , _timeline_dialog (0)
 {
        wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
@@ -228,17 +225,8 @@ FilmEditor::connect_to_widgets ()
        _best_dcp_frame_rate->Connect    (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED,       wxCommandEventHandler (FilmEditor::best_dcp_frame_rate_clicked), 0, this);
        _dcp_audio_channels->Connect     (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::dcp_audio_channels_changed), 0, this);
        _j2k_bandwidth->Connect          (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::j2k_bandwidth_changed), 0, this);
-       _audio_gain->Connect             (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED,     wxCommandEventHandler (FilmEditor::audio_gain_changed), 0, this);
-       _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);
-       _audio_stream->Connect           (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,      wxCommandEventHandler (FilmEditor::audio_stream_changed), 0, this);
        _dcp_resolution->Connect         (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED,      wxCommandEventHandler (FilmEditor::dcp_resolution_changed), 0, this);
        _sequence_video->Connect         (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED,     wxCommandEventHandler (FilmEditor::sequence_video_changed), 0, this);
-               
-       _audio_mapping->Changed.connect  (boost::bind (&FilmEditor::audio_mapping_changed, this, _1));
 }
 
 void
@@ -340,68 +328,11 @@ FilmEditor::make_content_panel ()
 
        make_video_panel ();
        _content_notebook->AddPage (_video_panel, _("Video"), false);
-       make_audio_panel ();
-       _content_notebook->AddPage (_audio_panel, _("Audio"), false);
+       _audio_panel = new AudioPanel (this);
        _subtitle_panel = new SubtitlePanel (this);
        _timing_panel = new TimingPanel (this);
 }
 
-void
-FilmEditor::make_audio_panel ()
-{
-       _audio_panel = new wxPanel (_content_notebook);
-       wxBoxSizer* audio_sizer = new wxBoxSizer (wxVERTICAL);
-       _audio_panel->SetSizer (audio_sizer);
-       
-       wxFlexGridSizer* grid = new wxFlexGridSizer (3, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
-       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);
-       grid->AddSpacer (0);
-
-       add_label_to_sizer (grid, _audio_panel, _("Audio Gain"), true);
-       {
-               wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
-               _audio_gain = new wxSpinCtrl (_audio_panel);
-               s->Add (_audio_gain, 1);
-               add_label_to_sizer (s, _audio_panel, _("dB"), false);
-               grid->Add (s, 1);
-       }
-       
-       _audio_gain_calculate_button = new wxButton (_audio_panel, wxID_ANY, _("Calculate..."));
-       grid->Add (_audio_gain_calculate_button);
-
-       add_label_to_sizer (grid, _audio_panel, _("Audio Delay"), false);
-       {
-               wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
-               _audio_delay = new wxSpinCtrl (_audio_panel);
-               s->Add (_audio_delay, 1);
-               /// TRANSLATORS: this is an abbreviation for milliseconds, the unit of time
-               add_label_to_sizer (s, _audio_panel, _("ms"), false);
-               grid->Add (s);
-       }
-
-       grid->AddSpacer (0);
-
-       add_label_to_sizer (grid, _audio_panel, _("Audio Stream"), true);
-       _audio_stream = new wxChoice (_audio_panel, wxID_ANY);
-       grid->Add (_audio_stream, 1, wxEXPAND);
-       _audio_description = new wxStaticText (_audio_panel, wxID_ANY, wxT (""));
-       grid->AddSpacer (0);
-       
-       grid->Add (_audio_description, 1, wxALIGN_CENTER_VERTICAL | wxLEFT, 8);
-       grid->AddSpacer (0);
-       grid->AddSpacer (0);
-       
-       _audio_mapping = new AudioMappingView (_audio_panel);
-       audio_sizer->Add (_audio_mapping, 1, wxEXPAND | wxALL, 6);
-
-       _audio_gain->SetRange (-60, 60);
-       _audio_delay->SetRange (-1000, 1000);
-}
-
 /** Called when the left crop widget has been changed */
 void
 FilmEditor::left_crop_changed (wxCommandEvent &)
@@ -521,6 +452,7 @@ FilmEditor::film_changed (Film::Property p)
 
        stringstream s;
 
+       _audio_panel->film_changed (p);
        _subtitle_panel->film_changed (p);
        _timing_panel->film_changed (p);
                
@@ -529,7 +461,6 @@ FilmEditor::film_changed (Film::Property p)
                break;
        case Film::CONTENT:
                setup_content ();
-               setup_show_audio_sensitivity ();
                break;
        case Film::CONTAINER:
                setup_container ();
@@ -582,7 +513,6 @@ FilmEditor::film_changed (Film::Property p)
        }
        case Film::DCP_AUDIO_CHANNELS:
                _dcp_audio_channels->SetValue (_film->dcp_audio_channels ());
-               _audio_mapping->set_channels (_film->dcp_audio_channels ());
                setup_dcp_name ();
                break;
        case Film::SEQUENCE_VIDEO:
@@ -619,8 +549,9 @@ FilmEditor::film_content_changed (weak_ptr<Content> weak_content, int property)
                ffmpeg_content = dynamic_pointer_cast<FFmpegContent> (content);
        }
 
-       _subtitle_panel->film_content_changed (content, subtitle_content, ffmpeg_content, property);
-       _timing_panel->film_content_changed   (content, subtitle_content, ffmpeg_content, property);
+       _audio_panel->film_content_changed    (content, audio_content, subtitle_content, ffmpeg_content, property);
+       _subtitle_panel->film_content_changed (content, audio_content, subtitle_content, ffmpeg_content, property);
+       _timing_panel->film_content_changed   (content, audio_content, subtitle_content, ffmpeg_content, property);
 
        /* We can't use case {} here */
        
@@ -649,28 +580,8 @@ FilmEditor::film_content_changed (weak_ptr<Content> weak_content, int property)
                        checked_set (_ratio, -1);
                }
                setup_scaling_description ();
-       } else if (property == AudioContentProperty::AUDIO_GAIN) {
-               checked_set (_audio_gain, audio_content ? audio_content->audio_gain() : 0);
-       } else if (property == AudioContentProperty::AUDIO_DELAY) {
-               checked_set (_audio_delay, audio_content ? audio_content->audio_delay() : 0);
-       } else if (property == AudioContentProperty::AUDIO_MAPPING) {
-               _audio_mapping->set (audio_content ? audio_content->audio_mapping () : AudioMapping ());
-       } else if (property == FFmpegContentProperty::AUDIO_STREAMS) {
-               _audio_stream->Clear ();
-               if (ffmpeg_content) {
-                       vector<shared_ptr<FFmpegAudioStream> > a = ffmpeg_content->audio_streams ();
-                       for (vector<shared_ptr<FFmpegAudioStream> >::iterator i = a.begin(); i != a.end(); ++i) {
-                               _audio_stream->Append (std_to_wx ((*i)->name), new wxStringClientData (std_to_wx (lexical_cast<string> ((*i)->id))));
-                       }
-                       
-                       if (ffmpeg_content->audio_stream()) {
-                               checked_set (_audio_stream, lexical_cast<string> (ffmpeg_content->audio_stream()->id));
-                       }
-               }
-               setup_show_audio_sensitivity ();
        } else if (property == FFmpegContentProperty::AUDIO_STREAM) {
                setup_dcp_name ();
-               setup_show_audio_sensitivity ();
        } else if (property == FFmpegContentProperty::FILTERS) {
                if (ffmpeg_content) {
                        pair<string, string> p = Filter::ffmpeg_strings (ffmpeg_content->filters ());
@@ -792,26 +703,15 @@ FilmEditor::set_things_sensitive (bool s)
        _name->Enable (s);
        _use_dci_name->Enable (s);
        _edit_dci_button->Enable (s);
-       _ratio->Enable (s);
        _content->Enable (s);
-       _left_crop->Enable (s);
-       _right_crop->Enable (s);
-       _top_crop->Enable (s);
-       _bottom_crop->Enable (s);
-       _filters_button->Enable (s);
-       _scaler->Enable (s);
        _dcp_content_type->Enable (s);
        _dcp_frame_rate->Enable (s);
        _dcp_audio_channels->Enable (s);
        _j2k_bandwidth->Enable (s);
-       _audio_gain->Enable (s);
-       _audio_gain_calculate_button->Enable (s);
-       _show_audio->Enable (s);
-       _audio_delay->Enable (s);
        _container->Enable (s);
 
        _subtitle_panel->setup_control_sensitivity ();
-       setup_show_audio_sensitivity ();
+       _audio_panel->setup_sensitivity ();
        setup_content_sensitivity ();
        _best_dcp_frame_rate->Enable (s && _film && _film->best_dcp_video_frame_rate () != _film->dcp_video_frame_rate ());
 }
@@ -850,55 +750,6 @@ FilmEditor::scaler_changed (wxCommandEvent &)
        }
 }
 
-void
-FilmEditor::audio_gain_changed (wxCommandEvent &)
-{
-       shared_ptr<AudioContent> ac = selected_audio_content ();
-       if (!ac) {
-               return;
-       }
-
-       ac->set_audio_gain (_audio_gain->GetValue ());
-}
-
-void
-FilmEditor::audio_delay_changed (wxCommandEvent &)
-{
-       shared_ptr<AudioContent> ac = selected_audio_content ();
-       if (!ac) {
-               return;
-       }
-
-       ac->set_audio_delay (_audio_delay->GetValue ());
-}
-
-void
-FilmEditor::audio_gain_calculate_button_clicked (wxCommandEvent &)
-{
-       GainCalculatorDialog* d = new GainCalculatorDialog (this);
-       d->ShowModal ();
-
-       if (d->wanted_fader() == 0 || d->actual_fader() == 0) {
-               d->Destroy ();
-               return;
-       }
-       
-       _audio_gain->SetValue (
-               Config::instance()->sound_processor()->db_for_fader_change (
-                       d->wanted_fader (),
-                       d->actual_fader ()
-                       )
-               );
-
-       /* This appears to be necessary, as the change is not signalled,
-          I think.
-       */
-       wxCommandEvent dummy;
-       audio_gain_changed (dummy);
-       
-       d->Destroy ();
-}
-
 void
 FilmEditor::setup_ratios ()
 {
@@ -953,29 +804,6 @@ FilmEditor::setup_dcp_name ()
        }
 }
 
-void
-FilmEditor::show_audio_clicked (wxCommandEvent &)
-{
-       if (_audio_dialog) {
-               _audio_dialog->Destroy ();
-               _audio_dialog = 0;
-       }
-
-       shared_ptr<Content> c = selected_content ();
-       if (!c) {
-               return;
-       }
-
-       shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (c);
-       if (!ac) {
-               return;
-       }
-       
-       _audio_dialog = new AudioDialog (this);
-       _audio_dialog->Show ();
-       _audio_dialog->set_content (ac);
-}
-
 void
 FilmEditor::best_dcp_frame_rate_clicked (wxCommandEvent &)
 {
@@ -986,12 +814,6 @@ FilmEditor::best_dcp_frame_rate_clicked (wxCommandEvent &)
        _film->set_dcp_video_frame_rate (_film->best_dcp_video_frame_rate ());
 }
 
-void
-FilmEditor::setup_show_audio_sensitivity ()
-{
-       _show_audio->Enable (_film);
-}
-
 void
 FilmEditor::setup_content ()
 {
@@ -1066,11 +888,9 @@ FilmEditor::content_selection_changed (wxListEvent &)
 {
        setup_content_sensitivity ();
        shared_ptr<Content> s = selected_content ();
-       
-       if (_audio_dialog && s && dynamic_pointer_cast<AudioContent> (s)) {
-               _audio_dialog->set_content (dynamic_pointer_cast<AudioContent> (s));
-       }
 
+       _audio_panel->content_selection_changed ();
+       
        film_content_changed (s, ContentProperty::START);
        film_content_changed (s, ContentProperty::LENGTH);
        film_content_changed (s, VideoContentProperty::VIDEO_CROP);
@@ -1228,60 +1048,6 @@ FilmEditor::content_timeline_clicked (wxCommandEvent &)
        _timeline_dialog->Show ();
 }
 
-void
-FilmEditor::audio_stream_changed (wxCommandEvent &)
-{
-       shared_ptr<Content> c = selected_content ();
-       if (!c) {
-               return;
-       }
-       
-       shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
-       if (!fc) {
-               return;
-       }
-       
-       vector<shared_ptr<FFmpegAudioStream> > a = fc->audio_streams ();
-       vector<shared_ptr<FFmpegAudioStream> >::iterator i = a.begin ();
-       string const s = string_client_data (_audio_stream->GetClientObject (_audio_stream->GetSelection ()));
-       while (i != a.end() && lexical_cast<string> ((*i)->id) != s) {
-               ++i;
-       }
-
-       if (i != a.end ()) {
-               fc->set_audio_stream (*i);
-       }
-
-       if (!fc->audio_stream ()) {
-               _audio_description->SetLabel (wxT (""));
-       } else {
-               wxString s;
-               if (fc->audio_channels() == 1) {
-                       s << _("1 channel");
-               } else {
-                       s << fc->audio_channels() << wxT (" ") << _("channels");
-               }
-               s << wxT (", ") << fc->content_audio_frame_rate() << _("Hz");
-               _audio_description->SetLabel (s);
-       }
-}
-
-void
-FilmEditor::audio_mapping_changed (AudioMapping m)
-{
-       shared_ptr<Content> c = selected_content ();
-       if (!c) {
-               return;
-       }
-       
-       shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (c);
-       if (!ac) {
-               return;
-       }
-
-       ac->set_audio_mapping (m);
-}
-
 void
 FilmEditor::set_selection (weak_ptr<Content> wc)
 {
index be4d14f99450731ba80c89a89f6b965ab42b517f..ff9198be42a60fc910110ea88b52ca054596097b 100644 (file)
@@ -33,13 +33,12 @@ class wxNotebook;
 class wxListCtrl;
 class wxListEvent;
 class Film;
-class AudioDialog;
 class TimelineDialog;
-class AudioMappingView;
 class Ratio;
 class Timecode;
 class TimingPanel;
 class SubtitlePanel;
+class AudioPanel;
 
 /** @class FilmEditor
  *  @brief A wx widget to edit a film's metadata, and perform various functions.
@@ -65,6 +64,8 @@ public:
        }
 
        boost::shared_ptr<Content> selected_content ();
+       boost::shared_ptr<VideoContent> selected_video_content ();
+       boost::shared_ptr<AudioContent> selected_audio_content ();
        boost::shared_ptr<SubtitleContent> selected_subtitle_content ();
        
        bool generally_sensitive () const {
@@ -75,7 +76,6 @@ private:
        void make_dcp_panel ();
        void make_content_panel ();
        void make_video_panel ();
-       void make_audio_panel ();
        void connect_to_widgets ();
        
        /* Handle changes to the view */
@@ -94,19 +94,11 @@ private:
        void container_changed (wxCommandEvent &);
        void dcp_content_type_changed (wxCommandEvent &);
        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 j2k_bandwidth_changed (wxCommandEvent &);
        void dcp_frame_rate_changed (wxCommandEvent &);
        void best_dcp_frame_rate_clicked (wxCommandEvent &);
        void edit_filters_clicked (wxCommandEvent &);
        void content_timeline_clicked (wxCommandEvent &);
-       void audio_stream_changed (wxCommandEvent &);
-       void audio_mapping_changed (AudioMapping);
-       void start_changed ();
-       void length_changed ();
        void ratio_changed (wxCommandEvent &);
        void dcp_audio_channels_changed (wxCommandEvent &);
        void dcp_resolution_changed (wxCommandEvent &);
@@ -120,16 +112,14 @@ private:
        void set_things_sensitive (bool);
        void setup_ratios ();
        void setup_dcp_name ();
-       void setup_show_audio_sensitivity ();
        void setup_scaling_description ();
        void setup_content ();
        void setup_container ();
        void setup_content_sensitivity ();
        
        void active_jobs_changed (bool);
-       boost::shared_ptr<VideoContent> selected_video_content ();
-       boost::shared_ptr<AudioContent> selected_audio_content ();
 
+       AudioPanel* _audio_panel;
        SubtitlePanel* _subtitle_panel;
        TimingPanel* _timing_panel;
 
@@ -140,7 +130,6 @@ private:
        wxPanel* _content_panel;
        wxSizer* _content_sizer;
        wxPanel* _video_panel;
-       wxPanel* _audio_panel;
 
        /** The film we are editing */
        boost::shared_ptr<Film> _film;
@@ -166,18 +155,11 @@ private:
        wxStaticText* _filters;
        wxButton* _filters_button;
        wxChoice* _scaler;
-       wxSpinCtrl* _audio_gain;
-       wxButton* _audio_gain_calculate_button;
-       wxButton* _show_audio;
-       wxSpinCtrl* _audio_delay;
-       wxSpinCtrl* _j2k_bandwidth;
+       wxSpinCtrl* _j2k_bandwidth;
        wxChoice* _dcp_content_type;
        wxChoice* _dcp_frame_rate;
        wxSpinCtrl* _dcp_audio_channels;
        wxButton* _best_dcp_frame_rate;
-       wxChoice* _audio_stream;
-       wxStaticText* _audio_description;
-       AudioMappingView* _audio_mapping;
        wxChoice* _dcp_resolution;
 
        ContentMenu _menu;
@@ -185,6 +167,5 @@ private:
        std::vector<Ratio const *> _ratios;
 
        bool _generally_sensitive;
-       AudioDialog* _audio_dialog;
        TimelineDialog* _timeline_dialog;
 };
index f238b7fb96eeb9aaf65e019cecd2aea632e51142..1ef4d9fc50f8c842b00a833c70fa2c4c94469414 100644 (file)
@@ -35,9 +35,11 @@ public:
        virtual void film_changed (Film::Property) {}
        virtual void film_content_changed (
                boost::shared_ptr<Content>,
+               boost::shared_ptr<AudioContent>,
                boost::shared_ptr<SubtitleContent>,
                boost::shared_ptr<FFmpegContent>,
                int) = 0;
+       virtual void content_selection_changed () {}
 
 protected:
        FilmEditor* _editor;
index 22b382ccdba3e849b60886d0205cc6806cf656ae..22e3ae7cc3917c1bab70e37fc0edfb1b0b97045a 100644 (file)
@@ -90,6 +90,7 @@ SubtitlePanel::film_changed (Film::Property property)
 void
 SubtitlePanel::film_content_changed (
        shared_ptr<Content>,
+       shared_ptr<AudioContent>,
        shared_ptr<SubtitleContent> subtitle_content,
        shared_ptr<FFmpegContent> ffmpeg_content,
        int property
index b4b20240e00798865ab72ff27670798fcac7741d..98c82b7c5463c7e4ff50225995bbdd45ef4e97cd 100644 (file)
@@ -30,6 +30,7 @@ public:
        void film_changed (Film::Property);
        void film_content_changed (
                boost::shared_ptr<Content>,
+               boost::shared_ptr<AudioContent>,
                boost::shared_ptr<SubtitleContent>,
                boost::shared_ptr<FFmpegContent>,
                int);
index 3f3788d1637fae7d978d94501e48e7fc39dc5439..88d6fffbc80ebaea50d489acf40998cc8f99b900 100644 (file)
@@ -45,7 +45,13 @@ TimingPanel::TimingPanel (FilmEditor* e)
 }
 
 void
-TimingPanel::film_content_changed (shared_ptr<Content> content, shared_ptr<SubtitleContent>, shared_ptr<FFmpegContent>, int property)
+TimingPanel::film_content_changed (
+       shared_ptr<Content> content,
+       shared_ptr<AudioContent>,
+       shared_ptr<SubtitleContent>,
+       shared_ptr<FFmpegContent>,
+       int property
+       )
 {
        if (property == ContentProperty::START) {
                if (content) {
index f9cd482d678ccae640eba9f5927689ea46978d25..0aaabcc659acc51fc2d66f7ccf47a41c5bec6609 100644 (file)
@@ -28,6 +28,7 @@ public:
 
        void film_content_changed (
                boost::shared_ptr<Content>,
+               boost::shared_ptr<AudioContent>,
                boost::shared_ptr<SubtitleContent>,
                boost::shared_ptr<FFmpegContent>,
                int);
index 8e3272ca4e054237e816b445fa3526be878744e4..3e750bb917b642ecb1e39630fe3130a2e348e2e8 100644 (file)
@@ -7,6 +7,7 @@ sources = """
           about_dialog.cc
           audio_dialog.cc
           audio_mapping_view.cc
+          audio_panel.cc
           audio_plot.cc
           config_dialog.cc
           content_menu.cc