#include <wx/spinctrl.h>
#include "lib/config.h"
#include "lib/sound_processor.h"
+#include "lib/ffmpeg_content.h"
#include "audio_dialog.h"
#include "audio_panel.h"
#include "audio_mapping_view.h"
#include "film_editor.h"
using std::vector;
+using std::cout;
using std::string;
using boost::dynamic_pointer_cast;
using boost::lexical_cast;
_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);
+ _delay->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&AudioPanel::delay_changed, this));
+ _stream->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&AudioPanel::stream_changed, this));
+ _show->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&AudioPanel::show_clicked, this));
+ _gain->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&AudioPanel::gain_changed, this));
+ _gain_calculate_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&AudioPanel::gain_calculate_button_clicked, this));
+
_mapping->Changed.connect (boost::bind (&AudioPanel::mapping_changed, this, _1));
}
AudioPanel::film_changed (Film::Property property)
{
switch (property) {
- case Film::DCP_AUDIO_CHANNELS:
- _mapping->set_channels (_editor->film()->dcp_audio_channels ());
+ case Film::AUDIO_CHANNELS:
+ _mapping->set_channels (_editor->film()->audio_channels ());
+ _sizer->Layout ();
break;
default:
break;
checked_set (_delay, ac ? ac->audio_delay() : 0);
} else if (property == AudioContentProperty::AUDIO_MAPPING) {
_mapping->set (ac ? ac->audio_mapping () : AudioMapping ());
+ _sizer->Layout ();
+ } else if (property == FFmpegContentProperty::AUDIO_STREAM) {
+ setup_stream_description ();
} else if (property == FFmpegContentProperty::AUDIO_STREAMS) {
_stream->Clear ();
if (fc) {
if (fc->audio_stream()) {
checked_set (_stream, lexical_cast<string> (fc->audio_stream()->id));
+ setup_stream_description ();
}
}
}
}
void
-AudioPanel::gain_changed (wxCommandEvent &)
+AudioPanel::gain_changed ()
{
shared_ptr<AudioContent> ac = _editor->selected_audio_content ();
if (!ac) {
}
void
-AudioPanel::delay_changed (wxCommandEvent &)
+AudioPanel::delay_changed ()
{
shared_ptr<AudioContent> ac = _editor->selected_audio_content ();
if (!ac) {
}
void
-AudioPanel::gain_calculate_button_clicked (wxCommandEvent &)
+AudioPanel::gain_calculate_button_clicked ()
{
GainCalculatorDialog* d = new GainCalculatorDialog (this);
d->ShowModal ();
/* This appears to be necessary, as the change is not signalled,
I think.
*/
- wxCommandEvent dummy;
- gain_changed (dummy);
+ gain_changed ();
d->Destroy ();
}
void
-AudioPanel::show_clicked (wxCommandEvent &)
+AudioPanel::show_clicked ()
{
if (_audio_dialog) {
_audio_dialog->Destroy ();
}
void
-AudioPanel::stream_changed (wxCommandEvent &)
+AudioPanel::stream_changed ()
{
shared_ptr<Content> c = _editor->selected_content ();
if (!c) {
if (!fc) {
return;
}
+
+ if (_stream->GetSelection() == -1) {
+ return;
+ }
vector<shared_ptr<FFmpegAudioStream> > a = fc->audio_streams ();
vector<shared_ptr<FFmpegAudioStream> >::iterator i = a.begin ();
fc->set_audio_stream (*i);
}
+ setup_stream_description ();
+}
+
+void
+AudioPanel::setup_stream_description ()
+{
+ shared_ptr<Content> c = _editor->selected_content ();
+ if (!c) {
+ return;
+ }
+
+ shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c);
+ if (!fc) {
+ return;
+ }
+
if (!fc->audio_stream ()) {
_description->SetLabel (wxT (""));
} else {