diff base/Preferences.cpp @ 919:4c7b4040bd2d tonioni

For Tony, resample all audio to 44100 on load
author Chris Cannam
date Fri, 13 Jun 2014 12:56:31 +0100
parents 451f7f3ab6e7
children 2896b8872834
line wrap: on
line diff
--- a/base/Preferences.cpp	Tue Jun 03 11:14:17 2014 +0100
+++ b/base/Preferences.cpp	Fri Jun 13 12:56:31 2014 +0100
@@ -43,6 +43,7 @@
     m_resampleQuality(1),
     m_omitRecentTemps(true),
     m_tempDirRoot(""),
+    m_fixedSampleRate(0),
     m_resampleOnLoad(false),
     m_viewFontSize(10),
     m_backgroundMode(BackgroundFromTheme),
@@ -62,6 +63,7 @@
     m_windowType = WindowType
         (settings.value("window-type", int(HanningWindow)).toInt());
     m_resampleQuality = settings.value("resample-quality", 1).toInt();
+    m_fixedSampleRate = settings.value("fixed-sample-rate", 0).toInt();
     m_resampleOnLoad = settings.value("resample-on-load", false).toBool();
     m_backgroundMode = BackgroundMode
         (settings.value("background-mode", int(BackgroundFromTheme)).toInt());
@@ -93,6 +95,7 @@
     props.push_back("Resample Quality");
     props.push_back("Omit Temporaries from Recent Files");
     props.push_back("Resample On Load");
+    props.push_back("Fixed Sample Rate");
     props.push_back("Temporary Directory Root");
     props.push_back("Background Mode");
     props.push_back("Time To Text Mode");
@@ -129,6 +132,9 @@
     if (name == "Resample On Load") {
         return tr("Resample mismatching files on import");
     }
+    if (name == "Fixed Sample Rate") {
+        return tr("Single fixed sample rate to resample all files to");
+    }
     if (name == "Temporary Directory Root") {
         return tr("Location for cache file directory");
     }
@@ -177,6 +183,9 @@
     if (name == "Resample On Load") {
         return ToggleProperty;
     }
+    if (name == "Fixed Sample Rate") {
+        return ValueProperty;
+    }
     if (name == "Temporary Directory Root") {
         // It's an arbitrary string, we don't have a set of values for this
         return InvalidProperty;
@@ -525,6 +534,19 @@
 }
 
 void
+Preferences::setFixedSampleRate(int rate)
+{
+    if (m_fixedSampleRate != rate) {
+        m_fixedSampleRate = rate;
+        QSettings settings;
+        settings.beginGroup("Preferences");
+        settings.setValue("fixed-sample-rate", rate);
+        settings.endGroup();
+        emit propertyChanged("Fixed Sample Rate");
+    }
+}
+
+void
 Preferences::setBackgroundMode(BackgroundMode mode)
 {
     if (m_backgroundMode != mode) {