summaryrefslogtreecommitdiff
path: root/src/wx
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-02-26 08:15:51 +0000
committerCarl Hetherington <cth@carlh.net>2013-02-26 08:15:51 +0000
commit1fadfdf60bb2c02086c2c9689ea44c73bed41571 (patch)
tree2238c3bc011a545212e8a22f75d9af35cc300584 /src/wx
parent36fdb78ea9973d1a797171d762802e707577c960 (diff)
Pretty dumb smoothing.
Diffstat (limited to 'src/wx')
-rw-r--r--src/wx/audio_dialog.cc11
-rw-r--r--src/wx/audio_dialog.h2
-rw-r--r--src/wx/audio_plot.cc25
-rw-r--r--src/wx/audio_plot.h2
4 files changed, 38 insertions, 2 deletions
diff --git a/src/wx/audio_dialog.cc b/src/wx/audio_dialog.cc
index 701c8263a..bcec01332 100644
--- a/src/wx/audio_dialog.cc
+++ b/src/wx/audio_dialog.cc
@@ -61,6 +61,11 @@ AudioDialog::AudioDialog (wxWindow* parent)
_type_checkbox[i]->Connect (wxID_ANY, wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler (AudioDialog::type_clicked), 0, this);
}
+ _smoothing = new wxSlider (this, wxID_ANY, 1, 1, 128);
+ _smoothing->Connect (wxID_ANY, wxEVT_SCROLL_THUMBTRACK, wxScrollEventHandler (AudioDialog::smoothing_changed), 0, this);
+ table->Add (_smoothing, 1, wxEXPAND);
+ table->AddSpacer (0);
+
sizer->Add (table, 0, wxALL, 12);
SetSizer (sizer);
@@ -178,3 +183,9 @@ AudioDialog::type_clicked (wxCommandEvent& ev)
_plot->set_type_visible (t, _type_checkbox[t]->GetValue ());
}
+
+void
+AudioDialog::smoothing_changed (wxScrollEvent &)
+{
+ _plot->set_smoothing (_smoothing->GetValue ());
+}
diff --git a/src/wx/audio_dialog.h b/src/wx/audio_dialog.h
index c3875023f..16cb356fe 100644
--- a/src/wx/audio_dialog.h
+++ b/src/wx/audio_dialog.h
@@ -37,6 +37,7 @@ private:
void film_changed (Film::Property);
void channel_clicked (wxCommandEvent &);
void type_clicked (wxCommandEvent &);
+ void smoothing_changed (wxScrollEvent &);
void try_to_load_analysis ();
void setup_channels ();
@@ -44,6 +45,7 @@ private:
AudioPlot* _plot;
wxCheckBox* _channel_checkbox[MAX_AUDIO_CHANNELS];
wxCheckBox* _type_checkbox[AudioPoint::COUNT];
+ wxSlider* _smoothing;
boost::signals2::scoped_connection _film_changed_connection;
boost::signals2::scoped_connection _film_audio_analysis_finished_connection;
};
diff --git a/src/wx/audio_plot.cc b/src/wx/audio_plot.cc
index ad69b6e1d..d938d0c27 100644
--- a/src/wx/audio_plot.cc
+++ b/src/wx/audio_plot.cc
@@ -28,6 +28,7 @@
using std::cout;
using std::vector;
+using std::list;
using std::max;
using std::min;
using boost::bind;
@@ -38,6 +39,7 @@ int const AudioPlot::_minimum = -70;
AudioPlot::AudioPlot (wxWindow* parent)
: wxPanel (parent)
, _gain (0)
+ , _smoothing (1)
{
SetDoubleBuffered (true);
@@ -149,21 +151,33 @@ AudioPlot::paint (wxPaintEvent &)
}
path[i] = gc->CreatePath ();
+
+ float const val = 20 * log10 (_analysis->get_point(c, 0)[i]);
+
path[i].MoveToPoint (
db_label_width,
- height - (max (_analysis->get_point(c, 0)[i], float (_minimum)) - _minimum + _gain) * ys - yo
+ height - (max (val, float (_minimum)) - _minimum + _gain) * ys - yo
);
}
+ list<float> smoothing[AudioPoint::COUNT];
+
for (int i = 0; i < _analysis->points(c); ++i) {
for (int j = 0; j < AudioPoint::COUNT; ++j) {
if (!_type_visible[j]) {
continue;
}
+
+ smoothing[j].push_back (_analysis->get_point(c, i)[j]);
+ if (int(smoothing[j].size()) > _smoothing) {
+ smoothing[j].pop_front ();
+ }
+
+ float const val = 20 * log10 (_analysis->smooth (smoothing[j], static_cast<AudioPoint::Type> (j)));
path[j].AddLineToPoint (
i * xs + db_label_width,
- height - (max (_analysis->get_point(c, i)[j], float (_minimum)) - _minimum + _gain) * ys - yo
+ height - (max (val, float (_minimum)) - _minimum + _gain) * ys - yo
);
}
}
@@ -197,3 +211,10 @@ AudioPlot::set_gain (float g)
_gain = g;
Refresh ();
}
+
+void
+AudioPlot::set_smoothing (int s)
+{
+ _smoothing = s;
+ Refresh ();
+}
diff --git a/src/wx/audio_plot.h b/src/wx/audio_plot.h
index 4ac7f848c..fe8862d54 100644
--- a/src/wx/audio_plot.h
+++ b/src/wx/audio_plot.h
@@ -32,6 +32,7 @@ public:
void set_channel_visible (int c, bool v);
void set_type_visible (int t, bool v);
void set_gain (float);
+ void set_smoothing (int);
private:
void paint (wxPaintEvent &);
@@ -41,6 +42,7 @@ private:
bool _type_visible[AudioPoint::COUNT];
/** gain to apply in dB */
float _gain;
+ int _smoothing;
std::vector<wxColour> _colours;