diff layer/WaveformLayer.cpp @ 1366:c2a3ac0a6688

Fix the mix/merge channels behaviour in pixels-per-frame zone
author Chris Cannam
date Tue, 30 Oct 2018 16:23:03 +0000
parents 4949061fcb8c
children f5566f7271fe
line wrap: on
line diff
--- a/layer/WaveformLayer.cpp	Tue Oct 30 15:32:05 2018 +0000
+++ b/layer/WaveformLayer.cpp	Tue Oct 30 16:23:03 2018 +0000
@@ -663,7 +663,7 @@
     
     if (mixingOrMerging) {
         if (minChannel != 0 || maxChannel != 0) {
-            SVCERR << "Internal error: min & max channels should be 0 when merging or mixing all channels" << endl;
+            throw std::logic_error("Internal error: min & max channels should be 0 when merging or mixing all channels");
         } else if (m_model->getChannelCount() > 1) {
             ranges.push_back({});
             m_model->getSummaries
@@ -674,11 +674,24 @@
 
 void
 WaveformLayer::getOversampledRanges(int minChannel, int maxChannel,
-                                    bool /* mixingOrMerging */,
+                                    bool mixingOrMerging,
                                     sv_frame_t frame0, sv_frame_t frame1,
                                     int oversampleBy, RangeVec &ranges)
     const
 {
+    if (mixingOrMerging) {
+        if (minChannel != 0 || maxChannel != 0) {
+            throw std::logic_error("Internal error: min & max channels should be 0 when merging or mixing all channels");
+        }
+        if (m_model->getChannelCount() > 1) {
+            // call back on self for the individual channels with
+            // mixingOrMerging false
+            getOversampledRanges
+                (0, 1, false, frame0, frame1, oversampleBy, ranges);
+            return;
+        }
+    }
+    
     // These frame values, tail length, etc variables are at the model
     // sample rate, not the oversampled rate
 
@@ -721,8 +734,6 @@
                << ", from which returning " << rr.size() << " ranges" << endl;
 #endif    
     }
-
-    //!!! + channel modes
     
     return;
 }
@@ -970,6 +981,9 @@
         if (showIndividualSample) {
             paint->setPen(baseColour);
             paint->drawRect(x-1, rangeTop-1, 2, 2);
+            if (rangeTop != rangeBottom) { // e.g. for "butterfly" merging mode
+                paint->drawRect(x-1, rangeBottom-1, 2, 2);
+            }
         }
         
         if (x != x0 && prevRangeBottom != -1) {