summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-02-25 00:28:03 +0000
committerCarl Hetherington <cth@carlh.net>2013-02-25 00:28:03 +0000
commit5702637ee38f0349fd0b7f17f10bda581e795a9d (patch)
tree48ce4ccfd3f61590adb86a8ff542d999018c6c7f /src
parent32ae1f11a9d3e1530c3939190690b5a524997ccb (diff)
Respond to gain in the audio dialog.
Diffstat (limited to 'src')
-rw-r--r--src/wx/audio_dialog.cc13
-rw-r--r--src/wx/audio_dialog.h7
-rw-r--r--src/wx/audio_plot.cc12
-rw-r--r--src/wx/audio_plot.h3
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> film)
void
AudioDialog::set_film (boost::shared_ptr<Film> f)
{
+ _film_connection.disconnect ();
+ _film = f;
+
shared_ptr<AudioAnalysis> a;
try {
@@ -70,6 +73,8 @@ AudioDialog::set_film (boost::shared_ptr<Film> 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 <boost/shared_ptr.hpp>
+#include <boost/signals2.hpp>
#include <wx/wx.h>
+#include "lib/film.h"
class AudioPlot;
class Film;
@@ -31,8 +33,11 @@ public:
void set_film (boost::shared_ptr<Film>);
private:
+ void film_changed (Film::Property);
void channel_changed (wxCommandEvent &);
-
+
+ boost::shared_ptr<Film> _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<AudioAnalysis>);
void set_channel (int c);
+ void set_gain (float);
private:
void paint (wxPaintEvent &);
boost::shared_ptr<AudioAnalysis> _analysis;
int _channel;
+ /** gain to apply in dB */
+ float _gain;
};