diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-02-26 08:15:51 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-02-26 08:15:51 +0000 |
| commit | 1fadfdf60bb2c02086c2c9689ea44c73bed41571 (patch) | |
| tree | 2238c3bc011a545212e8a22f75d9af35cc300584 /src/wx/audio_plot.cc | |
| parent | 36fdb78ea9973d1a797171d762802e707577c960 (diff) | |
Pretty dumb smoothing.
Diffstat (limited to 'src/wx/audio_plot.cc')
| -rw-r--r-- | src/wx/audio_plot.cc | 25 |
1 files changed, 23 insertions, 2 deletions
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 (); +} |
