changeset 164:da3701a3953e

* Make resampler quality configurable * Fall back to linear resampling when playing very fast * Switch off transient detection in time stretcher when playing very very fast
author Chris Cannam
date Thu, 21 Sep 2006 11:17:19 +0000
parents 4148ad087959
children 5ae5885d6ce3
files base/Preferences.cpp base/Preferences.h
diffstat 2 files changed, 40 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/base/Preferences.cpp	Mon Sep 18 16:43:17 2006 +0000
+++ b/base/Preferences.cpp	Thu Sep 21 11:17:19 2006 +0000
@@ -38,7 +38,8 @@
     m_smoothSpectrogram(true),
     m_tuningFrequency(440),
     m_propertyBoxLayout(VerticallyStacked),
-    m_windowType(HanningWindow)
+    m_windowType(HanningWindow),
+    m_resampleQuality(1)
 {
     QSettings settings;
     settings.beginGroup("Preferences");
@@ -48,6 +49,7 @@
         (settings.value("property-box-layout", int(VerticallyStacked)).toInt());
     m_windowType = WindowType
         (settings.value("window-type", int(HanningWindow)).toInt());
+    m_resampleQuality = settings.value("resample-quality", 1).toInt();
     settings.endGroup();
 }
 
@@ -63,6 +65,7 @@
     props.push_back("Tuning Frequency");
     props.push_back("Property Box Layout");
     props.push_back("Window Type");
+    props.push_back("Resample Quality");
     return props;
 }
 
@@ -81,6 +84,9 @@
     if (name == "Window Type") {
         return tr("Spectral analysis window shape");
     }
+    if (name == "Resample Quality") {
+        return tr("Resampler quality");
+    }
     return name;
 }
 
@@ -99,6 +105,9 @@
     if (name == "Window Type") {
         return ValueProperty;
     }
+    if (name == "Resample Quality") {
+        return ValueProperty;
+    }
     return InvalidProperty;
 }
 
@@ -126,6 +135,12 @@
         return int(m_windowType);
     }
 
+    if (name == "Resample Quality") {
+        if (min) *min = 0;
+        if (max) *max = 2;
+        return m_resampleQuality;
+    }
+
     return 0;
 }
 
@@ -150,6 +165,13 @@
         case BlackmanHarrisWindow: return tr("Blackman-Harris");
         }
     }
+    if (name == "Resample Quality") {
+        switch (value) {
+        case 0: return tr("Fastest");
+        case 1: return tr("Medium quality");
+        case 2: return tr("Highest quality");
+        }
+    }
     return "";
 }
 
@@ -176,6 +198,8 @@
         setPropertyBoxLayout(value == 0 ? VerticallyStacked : Layered);
     } else if (name == "Window Type") {
         setWindowType(WindowType(value));
+    } else if (name == "Resample Quality") {
+        setResampleQuality(value);
     }
 }
 
@@ -231,3 +255,15 @@
     }
 }
 
+void
+Preferences::setResampleQuality(int q)
+{
+    if (m_resampleQuality != q) {
+        m_resampleQuality = q;
+        QSettings settings;
+        settings.beginGroup("Preferences");
+        settings.setValue("resample-quality", q);
+        settings.endGroup();
+        emit propertyChanged("Resample Quality");
+    }
+}
--- a/base/Preferences.h	Mon Sep 18 16:43:17 2006 +0000
+++ b/base/Preferences.h	Thu Sep 21 11:17:19 2006 +0000
@@ -38,6 +38,7 @@
     bool getSmoothSpectrogram() const { return m_smoothSpectrogram; }
     float getTuningFrequency() const { return m_tuningFrequency; }
     WindowType getWindowType() const { return m_windowType; }
+    int getResampleQuality() const { return m_resampleQuality; }
 
     //!!! harmonise with PaneStack
     enum PropertyBoxLayout {
@@ -53,6 +54,7 @@
     void setTuningFrequency(float freq);
     void setPropertyBoxLayout(PropertyBoxLayout layout);
     void setWindowType(WindowType type);
+    void setResampleQuality(int quality);
 
 private:
     Preferences(); // may throw DirectoryCreationFailed
@@ -64,6 +66,7 @@
     float m_tuningFrequency;
     PropertyBoxLayout m_propertyBoxLayout;
     WindowType m_windowType;
+    int m_resampleQuality;
 };
 
 #endif