diff layer/WaveformLayer.cpp @ 76:45ba0b381c5d

* Fix long-standing off-by-1 bug in WaveFileModel that was getting us the wrong values for almost all audio data when merging channels (channel == -1) * Implement cut, copy and paste * Make draw mode work properly in time value layer * Minor fixes to CSV import
author Chris Cannam
date Fri, 07 Apr 2006 17:50:33 +0000
parents 72fa239a4880
children 19bf27e4fb29
line wrap: on
line diff
--- a/layer/WaveformLayer.cpp	Thu Apr 06 12:12:41 2006 +0000
+++ b/layer/WaveformLayer.cpp	Fri Apr 07 17:50:33 2006 +0000
@@ -892,18 +892,31 @@
 	    else label = tr("Channel %1").arg(ch + 1);
 	}
 
-	int min = int(range.min * 1000);
-	int max = int(range.max * 1000);
+        bool singleValue = false;
+        float min, max;
+
+        if (fabs(range.min) < 0.01) {
+            min = range.min;
+            max = range.max;
+            singleValue = (min == max);
+        } else {
+            int imin = int(range.min * 1000);
+            int imax = int(range.max * 1000);
+            singleValue = (imin == imax);
+            min = float(imin)/1000;
+            max = float(imax)/1000;
+        }
+
 	int db = int(AudioLevel::multiplier_to_dB(std::max(fabsf(range.min),
 							   fabsf(range.max)))
 		     * 100);
 
-	if (min != max) {
+	if (!singleValue) {
 	    text += tr("\n%1\t%2 - %3 (%4 dB peak)")
-		.arg(label).arg(float(min)/1000).arg(float(max)/1000).arg(float(db)/100);
+		.arg(label).arg(min).arg(max).arg(float(db)/100);
 	} else {
 	    text += tr("\n%1\t%2 (%3 dB peak)")
-		.arg(label).arg(float(min)/1000).arg(float(db)/100);
+		.arg(label).arg(min).arg(float(db)/100);
 	}
     }