changeset 553:98077b21a9e1

* Restore (better quality) y-axis interpolation in spectrogram * Make spectrogram x axis interpolation a preference
author Chris Cannam
date Fri, 06 Feb 2009 15:06:23 +0000
parents bbe503e368a9
children 60482f13e627
files base/Preferences.cpp base/Preferences.h
diffstat 2 files changed, 65 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/base/Preferences.cpp	Thu Feb 05 17:46:34 2009 +0000
+++ b/base/Preferences.cpp	Fri Feb 06 15:06:23 2009 +0000
@@ -35,7 +35,8 @@
 }
 
 Preferences::Preferences() :
-    m_spectrogramSmoothing(SpectrogramZeroPadded),
+    m_spectrogramSmoothing(SpectrogramInterpolated),
+    m_spectrogramXSmoothing(SpectrogramXInterpolated),
     m_tuningFrequency(440),
     m_propertyBoxLayout(VerticallyStacked),
     m_windowType(HanningWindow),
@@ -50,7 +51,9 @@
     QSettings settings;
     settings.beginGroup("Preferences");
     m_spectrogramSmoothing = SpectrogramSmoothing
-        (settings.value("spectrogram-smoothing", int(m_spectrogramSmoothing)).toInt());
+        (settings.value("spectrogram-y-smoothing", int(m_spectrogramSmoothing)).toInt());
+    m_spectrogramXSmoothing = SpectrogramXSmoothing
+        (settings.value("spectrogram-x-smoothing", int(m_spectrogramXSmoothing)).toInt());
     m_tuningFrequency = settings.value("tuning-frequency", 440.f).toDouble();
     m_propertyBoxLayout = PropertyBoxLayout
         (settings.value("property-box-layout", int(VerticallyStacked)).toInt());
@@ -77,7 +80,8 @@
 Preferences::getProperties() const
 {
     PropertyList props;
-    props.push_back("Spectrogram Smoothing");
+    props.push_back("Spectrogram Y Smoothing");
+    props.push_back("Spectrogram X Smoothing");
     props.push_back("Tuning Frequency");
     props.push_back("Property Box Layout");
     props.push_back("Window Type");
@@ -94,9 +98,12 @@
 QString
 Preferences::getPropertyLabel(const PropertyName &name) const
 {
-    if (name == "Spectrogram Smoothing") {
+    if (name == "Spectrogram Y Smoothing") {
         return tr("Spectrogram y-axis interpolation:");
     }
+    if (name == "Spectrogram X Smoothing") {
+        return tr("Spectrogram x-axis interpolation:");
+    }
     if (name == "Tuning Frequency") {
         return tr("Frequency of concert A");
     }
@@ -133,7 +140,10 @@
 Preferences::PropertyType
 Preferences::getPropertyType(const PropertyName &name) const
 {
-    if (name == "Spectrogram Smoothing") {
+    if (name == "Spectrogram Y Smoothing") {
+        return ValueProperty;
+    }
+    if (name == "Spectrogram X Smoothing") {
         return ValueProperty;
     }
     if (name == "Tuning Frequency") {
@@ -174,12 +184,18 @@
 Preferences::getPropertyRangeAndValue(const PropertyName &name,
                                       int *min, int *max, int *deflt) const
 {
-    if (name == "Spectrogram Smoothing") {
+    if (name == "Spectrogram Y Smoothing") {
         if (min) *min = 0;
-        if (max) *max = 2;
-        if (deflt) *deflt = int(SpectrogramZeroPadded);
+        if (max) *max = 3;
+        if (deflt) *deflt = int(SpectrogramInterpolated);
         return int(m_spectrogramSmoothing);
     }
+    if (name == "Spectrogram X Smoothing") {
+        if (min) *min = 0;
+        if (max) *max = 1;
+        if (deflt) *deflt = int(SpectrogramXInterpolated);
+        return int(m_spectrogramXSmoothing);
+    }
 
     //!!! freq mapping
 
@@ -257,11 +273,18 @@
         case 2: return tr("Highest quality");
         }
     }
-    if (name == "Spectrogram Smoothing") {
+    if (name == "Spectrogram Y Smoothing") {
         switch (value) {
-        case NoSpectrogramSmoothing: return tr("None - blocky but accurate");
-        case SpectrogramInterpolated: return tr("Linear - fast but fuzzy");
-        case SpectrogramZeroPadded: return tr("4 x Oversampled - slow but clear");
+        case NoSpectrogramSmoothing: return tr("None");
+        case SpectrogramInterpolated: return tr("Linear interpolation");
+        case SpectrogramZeroPadded: return tr("4 x Oversampling");
+        case SpectrogramZeroPaddedAndInterpolated: return tr("4 x Oversampling with interpolation");
+        }
+    }
+    if (name == "Spectrogram X Smoothing") {
+        switch (value) {
+        case NoSpectrogramXSmoothing: return tr("None");
+        case SpectrogramXInterpolated: return tr("Linear interpolation");
         }
     }
     if (name == "Background Mode") {
@@ -290,8 +313,10 @@
 void
 Preferences::setProperty(const PropertyName &name, int value) 
 {
-    if (name == "Spectrogram Smoothing") {
+    if (name == "Spectrogram Y Smoothing") {
         setSpectrogramSmoothing(SpectrogramSmoothing(value));
+    } else if (name == "Spectrogram X Smoothing") {
+        setSpectrogramXSmoothing(SpectrogramXSmoothing(value));
     } else if (name == "Tuning Frequency") {
         //!!!
     } else if (name == "Property Box Layout") {
@@ -322,9 +347,26 @@
 
         QSettings settings;
         settings.beginGroup("Preferences");
-        settings.setValue("spectrogram-smoothing", int(smoothing));
+        settings.setValue("spectrogram-y-smoothing", int(smoothing));
         settings.endGroup();
-        emit propertyChanged("Spectrogram Smoothing");
+        emit propertyChanged("Spectrogram Y Smoothing");
+    }
+}
+
+void
+Preferences::setSpectrogramXSmoothing(SpectrogramXSmoothing smoothing)
+{
+    if (m_spectrogramXSmoothing != smoothing) {
+
+        // "smoothing" is one of those words that looks increasingly
+        // ridiculous the more you see it.  Smoothing smoothing smoothing.
+        m_spectrogramXSmoothing = smoothing;
+
+        QSettings settings;
+        settings.beginGroup("Preferences");
+        settings.setValue("spectrogram-x-smoothing", int(smoothing));
+        settings.endGroup();
+        emit propertyChanged("Spectrogram X Smoothing");
     }
 }
 
--- a/base/Preferences.h	Thu Feb 05 17:46:34 2009 +0000
+++ b/base/Preferences.h	Fri Feb 06 15:06:23 2009 +0000
@@ -42,7 +42,13 @@
         SpectrogramZeroPaddedAndInterpolated
     };
 
+    enum SpectrogramXSmoothing {
+        NoSpectrogramXSmoothing,
+        SpectrogramXInterpolated
+    };
+
     SpectrogramSmoothing getSpectrogramSmoothing() const { return m_spectrogramSmoothing; }
+    SpectrogramXSmoothing getSpectrogramXSmoothing() const { return m_spectrogramXSmoothing; }
     float getTuningFrequency() const { return m_tuningFrequency; }
     WindowType getWindowType() const { return m_windowType; }
     int getResampleQuality() const { return m_resampleQuality; }
@@ -75,6 +81,7 @@
     virtual void setProperty(const PropertyName &, int);
 
     void setSpectrogramSmoothing(SpectrogramSmoothing smoothing);
+    void setSpectrogramXSmoothing(SpectrogramXSmoothing smoothing);
     void setTuningFrequency(float freq);
     void setPropertyBoxLayout(PropertyBoxLayout layout);
     void setWindowType(WindowType type);
@@ -93,6 +100,7 @@
     static Preferences *m_instance;
 
     SpectrogramSmoothing m_spectrogramSmoothing;
+    SpectrogramXSmoothing m_spectrogramXSmoothing;
     float m_tuningFrequency;
     PropertyBoxLayout m_propertyBoxLayout;
     WindowType m_windowType;