diff base/Preferences.cpp @ 933:d03b3d956358 warnfix_no_size_t

Merge from branch tony_integration
author Chris Cannam
date Wed, 18 Jun 2014 08:34:46 +0100
parents 2896b8872834
children 344c9ea90181
line wrap: on
line diff
--- a/base/Preferences.cpp	Tue Jun 17 16:42:51 2014 +0100
+++ b/base/Preferences.cpp	Wed Jun 18 08:34:46 2014 +0100
@@ -43,7 +43,9 @@
     m_resampleQuality(1),
     m_omitRecentTemps(true),
     m_tempDirRoot(""),
+    m_fixedSampleRate(0),
     m_resampleOnLoad(false),
+    m_normaliseAudio(false),
     m_viewFontSize(10),
     m_backgroundMode(BackgroundFromTheme),
     m_timeToTextMode(TimeToTextMs),
@@ -62,7 +64,9 @@
     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_normaliseAudio = settings.value("normalise-audio", false).toBool();
     m_backgroundMode = BackgroundMode
         (settings.value("background-mode", int(BackgroundFromTheme)).toInt());
     m_timeToTextMode = TimeToTextMode
@@ -93,6 +97,8 @@
     props.push_back("Resample Quality");
     props.push_back("Omit Temporaries from Recent Files");
     props.push_back("Resample On Load");
+    props.push_back("Normalise Audio");
+    props.push_back("Fixed Sample Rate");
     props.push_back("Temporary Directory Root");
     props.push_back("Background Mode");
     props.push_back("Time To Text Mode");
@@ -123,12 +129,18 @@
     if (name == "Resample Quality") {
         return tr("Playback resampler type");
     }
+    if (name == "Normalise Audio") {
+        return tr("Normalise audio signal when reading from audio file");
+    }
     if (name == "Omit Temporaries from Recent Files") {
         return tr("Omit temporaries from Recent Files menu");
     }
     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");
     }
@@ -171,12 +183,18 @@
     if (name == "Resample Quality") {
         return ValueProperty;
     }
+    if (name == "Normalise Audio") {
+        return ToggleProperty;
+    }
     if (name == "Omit Temporaries from Recent Files") {
         return ToggleProperty;
     }
     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 +543,32 @@
 }
 
 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::setNormaliseAudio(bool norm)
+{
+    if (m_normaliseAudio != norm) {
+        m_normaliseAudio = norm;
+        QSettings settings;
+        settings.beginGroup("Preferences");
+        settings.setValue("normalise-audio", norm);
+        settings.endGroup();
+        emit propertyChanged("Normalise Audio");
+    }
+}
+
+void
 Preferences::setBackgroundMode(BackgroundMode mode)
 {
     if (m_backgroundMode != mode) {