diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-06-28 20:21:30 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-06-28 20:21:30 -0400 |
commit | af3056769cdc09d9ce3b21f9f8e0aa8145ed8f0e (patch) | |
tree | 287c6dcab08deaf4fb4f8ed2222532c18bb6ccbc /libs | |
parent | aa480b833800ad943ede17c26df3d7103f5da28d (diff) |
changes to waveform clipping display
* clip level is now -0.9dbFS
* display of clipping is optional (see Theme Manager window)
* clipping is based on disk data, unscaled by region gain
Diffstat (limited to 'libs')
-rw-r--r-- | libs/canvas/canvas/wave_view.h | 2 | ||||
-rw-r--r-- | libs/canvas/wave_view.cc | 82 |
2 files changed, 55 insertions, 29 deletions
diff --git a/libs/canvas/canvas/wave_view.h b/libs/canvas/canvas/wave_view.h index 250eeb3b94..fc39d7e555 100644 --- a/libs/canvas/canvas/wave_view.h +++ b/libs/canvas/canvas/wave_view.h @@ -106,6 +106,7 @@ public: static void set_global_gradient_depth (double); static void set_global_logscaled (bool); static void set_global_shape (Shape); + static void set_global_show_waveform_clipping (bool); static double global_gradient_depth() { return _global_gradient_depth; } static bool global_logscaled() { return _global_logscaled; } @@ -161,6 +162,7 @@ private: static double _global_gradient_depth; static bool _global_logscaled; static Shape _global_shape; + static bool _global_show_waveform_clipping; static PBD::Signal0<void> VisualPropertiesChanged; diff --git a/libs/canvas/wave_view.cc b/libs/canvas/wave_view.cc index ce5c87ccfd..4ea9ff9fd3 100644 --- a/libs/canvas/wave_view.cc +++ b/libs/canvas/wave_view.cc @@ -44,6 +44,7 @@ using namespace ArdourCanvas; double WaveView::_global_gradient_depth = 0.6; bool WaveView::_global_logscaled = false; WaveView::Shape WaveView::_global_shape = WaveView::Normal; +bool WaveView::_global_show_waveform_clipping = true; PBD::Signal0<void> WaveView::VisualPropertiesChanged; @@ -177,7 +178,18 @@ WaveView::draw_image (PeakData* _peaks, int n_peaks) const Cairo::RefPtr<Cairo::Context> context = Cairo::Context::create (_image); boost::scoped_array<LineTips> tips (new LineTips[n_peaks]); - const double clip_level = 1.0; + + /* Clip level nominally set to -0.9dBFS to account for inter-sample + interpolation possibly clipping (value may be too low). + + We adjust by the region's own gain (but note: not by any gain + automation or its gain envelope) so that clip indicators are closer + to providing data about on-disk data. This multiplication is + needed because the data we get from AudioRegion::read_peaks() + has been scaled by scale_amplitude() already. + */ + + const double clip_level = 0.98853 * _region->scale_amplitude(); if (_shape == WaveView::Rectified) { @@ -328,40 +340,43 @@ WaveView::draw_image (PeakData* _peaks, int n_peaks) const * modelled on pyramix, except that we add clipping indicators. */ - context->set_source_rgba (0, 0, 0, 1.0); - - /* the height of the clip-indicator should be at most 7 pixels, - or 5% of the height of the waveview item. - */ - const double clip_height = min (7.0, ceil (_height * 0.05)); - - for (int i = 0; i < n_peaks; ++i) { - context->move_to (i, tips[i].top); - - bool show_top_clip = (_shape == WaveView::Rectified && (tips[i].clip_max || tips[i].clip_min)) || - tips[i].clip_max; - - if (show_top_clip) { - context->set_source_rgba (1.0, 0, 0, 1.0); - context->rel_line_to (0, clip_height); - context->stroke (); - context->set_source_rgba (0.0, 0, 0, 1.0); - } else { - context->rel_line_to (0, 1.0); - context->stroke (); - } - - if (_shape != WaveView::Rectified) { - context->move_to (i, tips[i].bot); - if (tips[i].clip_min) { + if (_global_show_waveform_clipping) { + + context->set_source_rgba (0, 0, 0, 1.0); + + /* the height of the clip-indicator should be at most 7 pixels, + or 5% of the height of the waveview item. + */ + const double clip_height = min (7.0, ceil (_height * 0.05)); + + for (int i = 0; i < n_peaks; ++i) { + context->move_to (i, tips[i].top); + + bool show_top_clip = (_shape == WaveView::Rectified && (tips[i].clip_max || tips[i].clip_min)) || + tips[i].clip_max; + + if (show_top_clip) { context->set_source_rgba (1.0, 0, 0, 1.0); - context->rel_line_to (0, -clip_height); + context->rel_line_to (0, clip_height); context->stroke (); context->set_source_rgba (0.0, 0, 0, 1.0); } else { - context->rel_line_to (0, -1.0); + context->rel_line_to (0, 1.0); context->stroke (); } + + if (_shape != WaveView::Rectified) { + context->move_to (i, tips[i].bot); + if (tips[i].clip_min) { + context->set_source_rgba (1.0, 0, 0, 1.0); + context->rel_line_to (0, -clip_height); + context->stroke (); + context->set_source_rgba (0.0, 0, 0, 1.0); + } else { + context->rel_line_to (0, -1.0); + context->stroke (); + } + } } } @@ -662,3 +677,12 @@ WaveView::set_global_gradient_depth (double depth) VisualPropertiesChanged (); /* EMIT SIGNAL */ } } + +void +WaveView::set_global_show_waveform_clipping (bool yn) +{ + if (_global_show_waveform_clipping != yn) { + _global_show_waveform_clipping = yn; + VisualPropertiesChanged (); /* EMIT SIGNAL */ + } +} |