add configurable clipping level to Canvas::WaveView
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 30 Dec 2013 20:46:44 +0000 (15:46 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 30 Dec 2013 20:46:44 +0000 (15:46 -0500)
libs/canvas/canvas/wave_view.h
libs/canvas/wave_view.cc

index 3272797e5a2672d6c727a8f26cceb61a5d3767f8..b80ae5183da5519b3bad7d301917e5ebf1595bb9 100644 (file)
@@ -115,6 +115,9 @@ public:
         void set_amplitude_above_axis (double v);
         double amplitude_above_axis () const { return _amplitude_above_axis; }
 
+       static void set_clip_level (double dB);
+       static PBD::Signal0<void> ClipLevelChanged;
+
 #ifdef CANVAS_COMPATIBILITY    
        void*& property_gain_src () {
                return _foo_void;
@@ -163,6 +166,7 @@ private:
         static bool   _global_logscaled;
         static Shape  _global_shape;
         static bool   _global_show_waveform_clipping;
+       static double _clip_level;
 
         static PBD::Signal0<void> VisualPropertiesChanged;
 
index 3467672b88accf5d04700b432cf4c47dd8ccfcd8..d73c906f3a78611f3c2316fea9aed798b3429ba6 100644 (file)
@@ -45,6 +45,7 @@ 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;
+double WaveView::_clip_level = 0.98853;
 
 PBD::Signal0<void> WaveView::VisualPropertiesChanged;
 
@@ -161,6 +162,13 @@ alt_log_meter (float power)
        return _log_meter (power, -192.0, 0.0, 8.0);
 }
 
+void
+WaveView::set_clip_level (double dB)
+{
+       _clip_level = dB_to_coefficient (dB);
+       ClipLevelChanged ();
+}
+
 struct LineTips {
     double top;
     double bot;
@@ -189,7 +197,7 @@ WaveView::draw_image (PeakData* _peaks, int n_peaks) const
           has been scaled by scale_amplitude() already.
        */
 
-       const double clip_level = 0.98853 * _region->scale_amplitude();
+       const double clip_level = _clip_level * _region->scale_amplitude();
 
        if (_shape == WaveView::Rectified) {