Mercurial > hg > svcore
changeset 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 | e88a15c25a4a |
children | f3cda3280398 |
files | base/Preferences.cpp base/Preferences.h |
diffstat | 2 files changed, 28 insertions(+), 0 deletions(-) [+] |
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) {
--- a/base/Preferences.h Tue Jun 03 11:14:17 2014 +0100 +++ b/base/Preferences.h Fri Jun 13 12:56:31 2014 +0100 @@ -66,6 +66,10 @@ QString getTemporaryDirectoryRoot() const { return m_tempDirRoot; } + /// If we should always resample audio to the same rate, return it; otherwise (the normal case) return 0 + int getFixedSampleRate() const { return m_fixedSampleRate; } + + /// True if we should resample second or subsequent audio file to match first audio file's rate bool getResampleOnLoad() const { return m_resampleOnLoad; } enum BackgroundMode { @@ -107,6 +111,7 @@ void setResampleQuality(int quality); void setOmitTempsFromRecentFiles(bool omit); void setTemporaryDirectoryRoot(QString tempDirRoot); + void setFixedSampleRate(int); void setResampleOnLoad(bool); void setBackgroundMode(BackgroundMode mode); void setTimeToTextMode(TimeToTextMode mode); @@ -141,6 +146,7 @@ int m_resampleQuality; bool m_omitRecentTemps; QString m_tempDirRoot; + int m_fixedSampleRate; bool m_resampleOnLoad; int m_viewFontSize; BackgroundMode m_backgroundMode;