2 Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "audio_dialog.h"
21 #include "audio_plot.h"
22 #include "audio_analysis.h"
26 using boost::shared_ptr;
28 AudioDialog::AudioDialog (wxWindow* parent, boost::shared_ptr<Film> film)
29 : wxDialog (parent, wxID_ANY, _("Audio"), wxDefaultPosition, wxSize (640, 512), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
32 wxBoxSizer* sizer = new wxBoxSizer (wxHORIZONTAL);
34 _plot = new AudioPlot (this);
35 sizer->Add (_plot, 1);
37 wxFlexGridSizer* table = new wxFlexGridSizer (2, 6, 6);
39 add_label_to_sizer (table, this, _("Channel"));
40 _channel = new wxChoice (this, wxID_ANY);
41 table->Add (_channel, 1, wxEXPAND | wxALL, 6);
49 sizer->SetSizeHints (this);
51 _channel->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (AudioDialog::channel_changed), 0, this);
55 AudioDialog::set_film (boost::shared_ptr<Film> f)
57 _film_connection.disconnect ();
60 shared_ptr<AudioAnalysis> a;
63 a.reset (new AudioAnalysis (f->audio_analysis_path ()));
68 _plot->set_analysis (a);
71 for (int i = 0; i < f->audio_stream()->channels(); ++i) {
72 _channel->Append (audio_channel_name (i));
75 _channel->SetSelection (0);
77 _film_connection = f->Changed.connect (bind (&AudioDialog::film_changed, this, _1));
81 AudioDialog::channel_changed (wxCommandEvent &)
83 _plot->set_channel (_channel->GetSelection ());
87 AudioDialog::film_changed (Film::Property p)
89 if (p == Film::AUDIO_GAIN) {
90 _plot->set_gain (_film->audio_gain ());