From 5702637ee38f0349fd0b7f17f10bda581e795a9d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 25 Feb 2013 00:28:03 +0000 Subject: [PATCH] Respond to gain in the audio dialog. --- src/wx/audio_dialog.cc | 13 +++++++++++++ src/wx/audio_dialog.h | 7 ++++++- src/wx/audio_plot.cc | 12 ++++++++++-- src/wx/audio_plot.h | 3 +++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/wx/audio_dialog.cc b/src/wx/audio_dialog.cc index 11efc153c..32864ca15 100644 --- a/src/wx/audio_dialog.cc +++ b/src/wx/audio_dialog.cc @@ -54,6 +54,9 @@ AudioDialog::AudioDialog (wxWindow* parent, boost::shared_ptr film) void AudioDialog::set_film (boost::shared_ptr f) { + _film_connection.disconnect (); + _film = f; + shared_ptr a; try { @@ -70,6 +73,8 @@ AudioDialog::set_film (boost::shared_ptr f) } _channel->SetSelection (0); + + _film_connection = f->Changed.connect (bind (&AudioDialog::film_changed, this, _1)); } void @@ -77,3 +82,11 @@ AudioDialog::channel_changed (wxCommandEvent &) { _plot->set_channel (_channel->GetSelection ()); } + +void +AudioDialog::film_changed (Film::Property p) +{ + if (p == Film::AUDIO_GAIN) { + _plot->set_gain (_film->audio_gain ()); + } +} diff --git a/src/wx/audio_dialog.h b/src/wx/audio_dialog.h index 1e4563972..968fd0a12 100644 --- a/src/wx/audio_dialog.h +++ b/src/wx/audio_dialog.h @@ -18,7 +18,9 @@ */ #include +#include #include +#include "lib/film.h" class AudioPlot; class Film; @@ -31,8 +33,11 @@ public: void set_film (boost::shared_ptr); private: + void film_changed (Film::Property); void channel_changed (wxCommandEvent &); - + + boost::shared_ptr _film; AudioPlot* _plot; wxChoice* _channel; + boost::signals2::scoped_connection _film_connection; }; diff --git a/src/wx/audio_plot.cc b/src/wx/audio_plot.cc index cc2d8f6b4..d438426c7 100644 --- a/src/wx/audio_plot.cc +++ b/src/wx/audio_plot.cc @@ -36,6 +36,7 @@ using boost::shared_ptr; AudioPlot::AudioPlot (wxWindow* parent) : wxPanel (parent) , _channel (0) + , _gain (0) { Connect (wxID_ANY, wxEVT_PAINT, wxPaintEventHandler (AudioPlot::paint), 0, this); @@ -91,12 +92,12 @@ AudioPlot::paint (wxPaintEvent &) for (int i = 0; i < AudioPoint::COUNT; ++i) { path[i] = gc->CreatePath (); - path[i].MoveToPoint (0, height - (max (_analysis->get_point(_channel, 0)[i], -60.0f) + 60) * ys); + path[i].MoveToPoint (0, height - (max (_analysis->get_point(_channel, 0)[i], -60.0f) + 60 + _gain) * ys); } for (int i = 0; i < _analysis->points(_channel); ++i) { for (int j = 0; j < AudioPoint::COUNT; ++j) { - path[j].AddLineToPoint (i * xs, height - (max (_analysis->get_point(_channel, i)[j], -60.0f) + 60) * ys); + path[j].AddLineToPoint (i * xs, height - (max (_analysis->get_point(_channel, i)[j], -60.0f) + 60 + _gain) * ys); } } @@ -108,3 +109,10 @@ AudioPlot::paint (wxPaintEvent &) delete gc; } + +void +AudioPlot::set_gain (float g) +{ + _gain = g; + Refresh (); +} diff --git a/src/wx/audio_plot.h b/src/wx/audio_plot.h index 03bd79323..dfc1b18ae 100644 --- a/src/wx/audio_plot.h +++ b/src/wx/audio_plot.h @@ -30,10 +30,13 @@ public: void set_analysis (boost::shared_ptr); void set_channel (int c); + void set_gain (float); private: void paint (wxPaintEvent &); boost::shared_ptr _analysis; int _channel; + /** gain to apply in dB */ + float _gain; }; -- 2.30.2