diff data/model/ReadOnlyWaveFileModel.cpp @ 1313:ff9697592bef 3.0-integration

Add gapless preference to prefs dialog; much work on audio read tests
author Chris Cannam
date Thu, 01 Dec 2016 17:45:40 +0000
parents c97a28a3baeb
children d4a28d1479a8 54af1e21705c
line wrap: on
line diff
--- a/data/model/ReadOnlyWaveFileModel.cpp	Tue Nov 29 17:09:07 2016 +0000
+++ b/data/model/ReadOnlyWaveFileModel.cpp	Thu Dec 01 17:45:40 2016 +0000
@@ -53,15 +53,31 @@
     m_lastDirectReadCount(0)
 {
     m_source.waitForData();
+
     if (m_source.isOK()) {
-        bool normalise = Preferences::getInstance()->getNormaliseAudio();
-        m_reader = AudioFileReaderFactory::createThreadingReader
-            (m_source, targetRate, normalise);
+
+        Preferences *prefs = Preferences::getInstance();
+        
+        AudioFileReaderFactory::Parameters params;
+        params.targetRate = targetRate;
+
+        params.normalisation = prefs->getNormaliseAudio() ?
+            AudioFileReaderFactory::Normalisation::Peak :
+            AudioFileReaderFactory::Normalisation::None;
+
+        params.gaplessMode = prefs->getUseGaplessMode() ?
+            AudioFileReaderFactory::GaplessMode::Gapless :
+            AudioFileReaderFactory::GaplessMode::Gappy;
+        
+        params.threadingMode = AudioFileReaderFactory::ThreadingMode::Threaded;
+
+        m_reader = AudioFileReaderFactory::createReader(m_source, params);
         if (m_reader) {
             SVDEBUG << "ReadOnlyWaveFileModel::ReadOnlyWaveFileModel: reader rate: "
                       << m_reader->getSampleRate() << endl;
         }
     }
+    
     if (m_reader) setObjectName(m_reader->getTitle());
     if (objectName() == "") setObjectName(QFileInfo(m_path).fileName());
     if (isOK()) fillCache();