try using threaded waveviews in tracks also
[ardour.git] / libs / canvas / wave_view.cc
index 1a969d60e3f063584c7110b5989696f8a6f979c4..e8db7d8c6a3055a8a6056f94d94aa91e5d7a7dcc 100644 (file)
@@ -152,7 +152,7 @@ WaveView::debug_name() const
 void
 WaveView::image_ready ()
 {
-        DEBUG_TRACE (DEBUG::WaveView, string_compose ("queue draw for %1 at %2 (vis = %3 bbox = %4 CR %5)\n", this, g_get_monotonic_time(), visible(), _bounding_box, current_request));
+        DEBUG_TRACE (DEBUG::WaveView, string_compose ("queue draw for %1 at %2 (vis = %3 CR %4)\n", this, g_get_monotonic_time(), visible(), current_request));
        redraw ();
 }
 
@@ -575,7 +575,7 @@ WaveView::draw_image (Cairo::RefPtr<Cairo::ImageSurface>& image, PeakData* _peak
                outline_context->stroke ();
 
        } else {
-               const double height_2 = _height * .5;
+               const int height_zero = floor( _height * .5);
 
                for (int i = 0; i < n_peaks; ++i) {
 
@@ -601,10 +601,11 @@ WaveView::draw_image (Cairo::RefPtr<Cairo::ImageSurface>& image, PeakData* _peak
                                }
                        }
 
-                       /* zero line, show only if there is enough spread */
+                       /* zero line, show only if there is enough spread 
+                       or the waveform line does not cross zero line */
 
-                       if (tips[i].spread >= 5.0 && show_zero_line()) {
-                               zero_context->move_to (i, floor(height_2));
+                       if (show_zero_line() && ((tips[i].spread >= 5.0) || (tips[i].top > height_zero ) || (tips[i].bot < height_zero)) ) {
+                               zero_context->move_to (i, height_zero);
                                zero_context->rel_line_to (1.0, 0);
                        }
 
@@ -736,6 +737,7 @@ WaveView::draw_image (Cairo::RefPtr<Cairo::ImageSurface>& image, PeakData* _peak
 boost::shared_ptr<WaveViewCache::Entry>
 WaveView::cache_request_result (boost::shared_ptr<WaveViewThreadRequest> req) const
 {
+       
        boost::shared_ptr<WaveViewCache::Entry> ret (new WaveViewCache::Entry (req->channel,
                                                                               req->height,
                                                                               req->amplitude,
@@ -982,6 +984,12 @@ WaveView::generate_image (boost::shared_ptr<WaveViewThreadRequest> req, bool in_
                
                if (peaks_read > 0) {
 
+                       /* region amplitude will have been used to generate the
+                        * peak values already, but not the visual-only
+                        * amplitude_above_axis. So apply that here before
+                        * rendering.
+                        */
+                       
                        if (_amplitude_above_axis != 1.0) {
                                for (framecnt_t i = 0; i < n_peaks; ++i) {
                                        peaks[i].max *= _amplitude_above_axis;