diff layer/SpectrogramLayer.cpp @ 134:13949a6970ab

* Use peaks instead of means for calculating display values in pixels that cover more than one bin
author Chris Cannam
date Wed, 16 Aug 2006 14:57:47 +0000
parents 9e6b3e239b9d
children e98130764635
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp	Fri Aug 04 17:01:37 2006 +0000
+++ b/layer/SpectrogramLayer.cpp	Wed Aug 16 14:57:47 2006 +0000
@@ -1953,8 +1953,11 @@
         displayMaxFreq = getEffectiveMaxFrequency();
     }
 
+    //!!! we will probably only want one of "ymag+ydiv" and "ypeak",
+    //but we leave them both calculated here for test purposes
     float ymag[h];
     float ydiv[h];
+    float ypeak[h];
     float yval[bins + 1]; //!!! cache this?
 
     size_t increment = getWindowIncrement();
@@ -1976,8 +1979,9 @@
     for (int x = 0; x < w; ++x) {
 
 	for (int y = 0; y < h; ++y) {
-	    ymag[y] = 0.0;
-	    ydiv[y] = 0.0;
+	    ymag[y] = 0.f;
+	    ydiv[y] = 0.f;
+            ypeak[y] = 0.f;
 	}
 
 	float s0 = 0, s1 = 0;
@@ -2064,6 +2068,7 @@
 		    if (y == y1i) yprop *= y1 - y;
 		    ymag[y] += yprop * value;
 		    ydiv[y] += yprop;
+                    if (value > ypeak[y]) ypeak[y] = value;
 		}
 	    }
 
@@ -2086,7 +2091,8 @@
 		unsigned char pixel = 0;
 
 		float avg = ymag[y] / ydiv[y];
-		pixel = getDisplayValue(v, avg);
+//!!!		pixel = getDisplayValue(v, avg);
+		pixel = getDisplayValue(v, ypeak[y]);
 
 		assert(x <= m_drawBuffer.width());
 		QColor c = m_colourMap.getColour(pixel);