changeset 210:748985c7e2c1

* Fix incorrect meter-scaling value for 0dB; some tidying
author Chris Cannam
date Wed, 28 Feb 2007 11:20:14 +0000
parents b6af2eb00780
children e2baee498ec8
files layer/SpectrogramLayer.cpp layer/SpectrogramLayer.h
diffstat 2 files changed, 8 insertions(+), 88 deletions(-) [+]
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp	Tue Feb 27 17:51:52 2007 +0000
+++ b/layer/SpectrogramLayer.cpp	Wed Feb 28 11:20:14 2007 +0000
@@ -490,7 +490,7 @@
 	case 0: setColourScale(LinearColourScale); break;
 	case 1: setColourScale(MeterColourScale); break;
 	case 2: setColourScale(dBColourScale); break;
-	case 3: setColourScale(OtherColourScale); break;
+	case 3: setColourScale(dBSquaredColourScale); break;
 	case 4: setColourScale(PhaseColourScale); break;
 	}
     } else if (name == "Frequency Scale") {
@@ -1097,15 +1097,12 @@
 	
     default:
     case LinearColourScale:
-//	value = int
-//	    (input * (m_normalizeColumns ? 1.0 : 50.0) * 255.0) + 1;
         value = int(((input - min) / (max - min)) * 255.f) + 1;
 	break;
 	
     case MeterColourScale:
-//	value = AudioLevel::multiplier_to_preview
-//	    (input * (m_normalizeColumns ? 1.0 : 50.0), 255) + 1;
-        value = AudioLevel::multiplier_to_preview((input - min) / (max - min), 255) + 1;
+        value = AudioLevel::multiplier_to_preview
+            ((input - min) / (max - min), 254) + 1;
 	break;
 	
     case dBColourScale:
@@ -1128,9 +1125,7 @@
 	value = int(input * 255.f) + 1;
 	break;
 
-    case OtherColourScale:
-        //!!! the "Other" scale is just where our current experiments go
-        //!!! power rather than v
+    case dBSquaredColourScale:
         input = (input * input) / (max * max);
         if (input > 0.f) {
             input = 10.f * log10f(input);
@@ -1146,22 +1141,12 @@
 	if (input > 1.f) input = 1.f;
 	value = int(input * 255.f) + 1;
 	break;
-        
-/*!!!
-	input = 10.f * log10f(input * input);
-        input = 1.f / (1.f + expf(- (input + 20.f) / 10.f));
-
-	if (input < 0.f) input = 0.f;
-	if (input > 1.f) input = 1.f;
-	value = int(input * 255.f) + 1;
-*/
-	break;
 	
     case PhaseColourScale:
 	value = int((input * 127.0 / M_PI) + 128);
 	break;
     }
-    
+
     if (value > UCHAR_MAX) value = UCHAR_MAX;
     if (value < 0) value = 0;
     return value;
@@ -1196,7 +1181,7 @@
 	value = int(input);
 	break;
 
-    case OtherColourScale:
+    case dBSquaredColourScale:
 	input = float(value - 1) / 255.0;
 	input = (input * 80.0) - 80.0;
 	input = powf(10.0, input) / 20.0;
@@ -2260,10 +2245,6 @@
 SpectrogramLayer::getValueExtents(float &min, float &max,
                                   bool &logarithmic, QString &unit) const
 {
-//!!!
-//    min = getEffectiveMinFrequency();
-//    max = getEffectiveMaxFrequency();
-
     if (!m_model) return false;
 
     int sr = m_model->getSampleRate();
@@ -2511,27 +2492,6 @@
 
     cw = paint.fontMetrics().width("-80dB");
 
-/*!!!
-    switch (m_colourScale) {
-    default:
-    case LinearColourScale:
-	cw = paint.fontMetrics().width(QString("0.00"));
-	break;
-
-    case MeterColourScale:
-    case dBColourScale:
-    case OtherColourScale:
-	cw = std::max(paint.fontMetrics().width(tr("-Inf")),
-		      paint.fontMetrics().width(tr("-90")));
-	break;
-
-    case PhaseColourScale:
-	cw = paint.fontMetrics().width(QString("-") + QChar(0x3c0));
-	break;
-    }
-*/
-
-
     return cw;
 }
 
@@ -2596,34 +2556,6 @@
 	paint.drawRect(4 + cw - cbw, textHeight * topLines + 4, cbw - 1, ch + 1);
 
 	QString top, bottom;
-/*!!!
-	switch (m_colourScale) {
-	default:
-	case LinearColourScale:
-	    top = (m_normalizeColumns ? "1.0" : "0.02");
-	    bottom = (m_normalizeColumns ? "0.0" : "0.00");
-	    break;
-
-	case MeterColourScale:
-	    top = (m_normalizeColumns ? QString("0") :
-		   QString("%1").arg(int(AudioLevel::multiplier_to_dB(0.02))));
-	    bottom = QString("%1").
-		arg(int(AudioLevel::multiplier_to_dB
-			(AudioLevel::preview_to_multiplier(0, 255))));
-	    break;
-
-	case dBColourScale:
-	case OtherColourScale:
-	    top = "0";
-	    bottom = "-80";
-	    break;
-
-	case PhaseColourScale:
-	    top = QChar(0x3c0);
-	    bottom = "-" + top;
-	    break;
-	}
-*/
         float min = m_viewMags[v].getMin();
         float max = m_viewMags[v].getMax();
 
@@ -2663,24 +2595,13 @@
 
             float value = AudioLevel::dB_to_multiplier(dBval);
             int colour = getDisplayValue(v, value * m_gain);
-/*
-            float value = min + (((max - min) * i) / (ch - 1));
-            if (value < m_threshold) value = 0.f;
-            int colour = getDisplayValue(v, value * m_gain);
-*/
-/*
-	    int colour = (i * 255) / ch + 1;
-*/
+
 	    paint.setPen(m_palette.getColour(colour));
 
             int y = textHeight * topLines + 4 + ch - i;
 
             paint.drawLine(5 + cw - cbw, y, cw + 2, y);
 
-//	    paint.drawLine(5, 4 + textHeight + ch - i,
-//			   cw + 2, 4 + textHeight + ch - i);
-
-
             if (i == 0) {
                 lasty = y;
                 lastdb = idb;
@@ -2801,7 +2722,6 @@
 {
 public:
     SpectrogramRangeMapper(int sr, int fftsize) :
-//        m_dist((float(sr) / 2) - (float(sr) / fftsize)),
         m_dist(float(sr) / 2),
         m_s2(sqrtf(sqrtf(2))) { }
     ~SpectrogramRangeMapper() { }
--- a/layer/SpectrogramLayer.h	Tue Feb 27 17:51:52 2007 +0000
+++ b/layer/SpectrogramLayer.h	Wed Feb 28 11:20:14 2007 +0000
@@ -130,7 +130,7 @@
 	LinearColourScale,
 	MeterColourScale,
 	dBColourScale,
-        OtherColourScale,
+        dBSquaredColourScale,
 	PhaseColourScale
     };