changeset 118:853a7fc542d0

* fledgling preferences stuff
author Chris Cannam
date Mon, 10 Jul 2006 13:54:49 +0000
parents 782142eaaa84
children 508276c923ba
files layer/SpectrogramLayer.cpp
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp	Fri Jul 07 11:22:32 2006 +0000
+++ b/layer/SpectrogramLayer.cpp	Mon Jul 10 13:54:49 2006 +0000
@@ -20,6 +20,7 @@
 #include "base/AudioLevel.h"
 #include "base/Window.h"
 #include "base/Pitch.h"
+#include "base/Preferences.h"
 #include "fileio/FFTDataServer.h"
 
 #include <QPainter>
@@ -1390,6 +1391,7 @@
     //!!! tidy all this stuff
 
     if (m_binDisplay != AllBins) return 0;
+    if (!Preferences::getInstance()->getSmoothSpectrogram()) return 0;
     if (m_frequencyScale == LogFrequencyScale) return 3;
 
     int sr = m_model->getSampleRate();
@@ -1407,10 +1409,16 @@
 	if (minbin >= bins) minbin = bins - 1;
     }
 
-    if (v->height() / 1.5 > (bins - minbin) / (m_zeroPadLevel + 1)) {
-        return 3;
+    float perPixel =
+        float(v->height()) /
+        float((bins - minbin) / (m_zeroPadLevel + 1));
+
+    if (perPixel > 2.8) {
+        return 3; // 4x oversampling
+    } else if (perPixel > 1.5) {
+        return 1; // 2x
     } else {
-        return 0;
+        return 0; // 1x
     }
 }