changeset 1868:44dba7cd9ec3

Add record-mono preference
author Chris Cannam
date Tue, 16 Jun 2020 15:15:57 +0100
parents 2654bf447a84
children cb9209ef373a 1b8c4ee06f6d 48f50a4a82ea
files base/Preferences.cpp base/Preferences.h
diffstat 2 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/base/Preferences.cpp	Thu Jun 11 14:09:59 2020 +0100
+++ b/base/Preferences.cpp	Tue Jun 16 15:15:57 2020 +0100
@@ -44,6 +44,7 @@
     m_omitRecentTemps(true),
     m_tempDirRoot(""),
     m_fixedSampleRate(0),
+    m_recordMono(false),
     m_resampleOnLoad(false),
     m_gapless(true),
     m_normaliseAudio(false),
@@ -67,6 +68,7 @@
         (settings.value("window-type", int(HanningWindow)).toInt());
     m_runPluginsInProcess = settings.value("run-vamp-plugins-in-process", true).toBool();
     m_fixedSampleRate = settings.value("fixed-sample-rate", 0).toDouble();
+    m_recordMono = settings.value("record-mono", false).toBool();
     m_resampleOnLoad = settings.value("resample-on-load", false).toBool();
     m_gapless = settings.value("gapless", true).toBool();
     m_normaliseAudio = settings.value("normalise-audio", false).toBool();
@@ -100,6 +102,7 @@
     props.push_back("Window Type");
     props.push_back("Resample Quality");
     props.push_back("Omit Temporaries from Recent Files");
+    props.push_back("Record Mono");
     props.push_back("Resample On Load");
     props.push_back("Use Gapless Mode");
     props.push_back("Normalise Audio");
@@ -141,6 +144,9 @@
     if (name == "Omit Temporaries from Recent Files") {
         return tr("Omit temporaries from Recent Files menu");
     }
+    if (name == "Record Mono") {
+        return tr("Mix recorded channels to mono");
+    }
     if (name == "Resample On Load") {
         return tr("Resample mismatching files on import");
     }
@@ -201,6 +207,9 @@
     if (name == "Omit Temporaries from Recent Files") {
         return ToggleProperty;
     }
+    if (name == "Record Mono") {
+        return ToggleProperty;
+    }
     if (name == "Resample On Load") {
         return ToggleProperty;
     }
@@ -552,6 +561,19 @@
 }
 
 void
+Preferences::setRecordMono(bool mono)
+{
+    if (m_recordMono != mono) {
+        m_recordMono = mono;
+        QSettings settings;
+        settings.beginGroup("Preferences");
+        settings.setValue("record-mono", mono);
+        settings.endGroup();
+        emit propertyChanged("Record Mono");
+    }
+}
+
+void
 Preferences::setResampleOnLoad(bool resample)
 {
     if (m_resampleOnLoad != resample) {
--- a/base/Preferences.h	Thu Jun 11 14:09:59 2020 +0100
+++ b/base/Preferences.h	Tue Jun 16 15:15:57 2020 +0100
@@ -65,6 +65,10 @@
 
     QString getTemporaryDirectoryRoot() const { return m_tempDirRoot; }
 
+    /// True if we should always mix down recorded audio to a single
+    /// channel regardless of how many channels the device opens
+    bool getRecordMono() const { return m_recordMono; }
+    
     /// If we should always resample audio to the same rate, return it; otherwise (the normal case) return 0
     sv_samplerate_t getFixedSampleRate() const { return m_fixedSampleRate; }
 
@@ -119,6 +123,7 @@
     void setOmitTempsFromRecentFiles(bool omit);
     void setTemporaryDirectoryRoot(QString tempDirRoot);
     void setFixedSampleRate(sv_samplerate_t);
+    void setRecordMono(bool);
     void setResampleOnLoad(bool);
     void setUseGaplessMode(bool);
     void setNormaliseAudio(bool);
@@ -157,6 +162,7 @@
     bool m_omitRecentTemps;
     QString m_tempDirRoot;
     sv_samplerate_t m_fixedSampleRate;
+    bool m_recordMono;
     bool m_resampleOnLoad;
     bool m_gapless;
     bool m_normaliseAudio;