diff data/model/WaveFileModel.cpp @ 297:c022976d18e8

* Merge from sv-match-alignment branch (excluding alignment-specific document). - add aggregate wave model (not yet complete enough to be added as a true model in a layer, but there's potential) - add play solo mode - add alignment model -- unused in plain SV - fix two plugin leaks - add m3u playlist support (opens all files at once, potentially hazardous) - fix retrieval of pre-encoded URLs - add ability to resample audio files on import, so as to match rates with other files previously loaded; add preference for same - add preliminary support in transform code for range and rate of transform input - reorganise preferences dialog, move dark-background option to preferences, add option for temporary directory location
author Chris Cannam
date Fri, 28 Sep 2007 13:56:38 +0000
parents 8c5762634f42
children 5877d68815c7
line wrap: on
line diff
--- a/data/model/WaveFileModel.cpp	Fri Sep 21 09:13:11 2007 +0000
+++ b/data/model/WaveFileModel.cpp	Fri Sep 28 13:56:38 2007 +0000
@@ -38,7 +38,7 @@
 PowerOfSqrtTwoZoomConstraint
 WaveFileModel::m_zoomConstraint;
 
-WaveFileModel::WaveFileModel(QString path) :
+WaveFileModel::WaveFileModel(QString path, size_t targetRate) :
     m_path(path),
     m_myReader(true),
     m_fillThread(0),
@@ -46,13 +46,14 @@
     m_lastFillExtent(0),
     m_exiting(false)
 {
-    m_reader = AudioFileReaderFactory::createReader(path);
+    m_reader = AudioFileReaderFactory::createReader(path, targetRate);
+    if (m_reader) std::cerr << "WaveFileModel::WaveFileModel: reader rate: " << m_reader->getSampleRate() << std::endl;
     if (m_reader) setObjectName(m_reader->getTitle());
     if (objectName() == "") setObjectName(QFileInfo(path).fileName());
     if (isOK()) fillCache();
 }
 
-WaveFileModel::WaveFileModel(QString path, QString originalLocation) :
+WaveFileModel::WaveFileModel(QString path, QString originalLocation, size_t targetRate) :
     m_path(originalLocation),
     m_myReader(true),
     m_fillThread(0),
@@ -60,7 +61,8 @@
     m_lastFillExtent(0),
     m_exiting(false)
 {
-    m_reader = AudioFileReaderFactory::createReader(path);
+    m_reader = AudioFileReaderFactory::createReader(path, targetRate);
+    if (m_reader) std::cerr << "WaveFileModel::WaveFileModel: reader rate: " << m_reader->getSampleRate() << std::endl;
     if (m_reader) setObjectName(m_reader->getTitle());
     if (objectName() == "") setObjectName(QFileInfo(originalLocation).fileName());
     if (isOK()) fillCache();
@@ -151,6 +153,15 @@
 }
 
 size_t
+WaveFileModel::getNativeRate() const 
+{
+    if (!m_reader) return 0;
+    size_t rate = m_reader->getNativeRate();
+    if (rate == 0) rate = getSampleRate();
+    return rate;
+}
+
+size_t
 WaveFileModel::getValues(int channel, size_t start, size_t end,
 			 float *buffer) const
 {