changeset 258:96a6dd889c68

* Fix #1706924 updates not happening on derived waveform generation
author Chris Cannam
date Mon, 30 Apr 2007 09:07:42 +0000
parents 46398ab6ff58
children dc46851837d6
files data/fileio/WavFileReader.cpp data/model/WaveFileModel.cpp data/model/WaveFileModel.h data/model/WritableWaveFileModel.cpp
diffstat 4 files changed, 20 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/data/fileio/WavFileReader.cpp	Fri Apr 27 16:10:10 2007 +0000
+++ b/data/fileio/WavFileReader.cpp	Mon Apr 30 09:07:42 2007 +0000
@@ -90,7 +90,10 @@
         m_sampleRate = m_fileInfo.samplerate;
     }
 
-    if (m_frameCount != prevCount) emit frameCountChanged();
+    if (m_frameCount != prevCount) {
+//        std::cerr << "frameCountChanged" << std::endl;
+        emit frameCountChanged();
+    }
 }
 
 void
--- a/data/model/WaveFileModel.cpp	Fri Apr 27 16:10:10 2007 +0000
+++ b/data/model/WaveFileModel.cpp	Mon Apr 30 09:07:42 2007 +0000
@@ -148,8 +148,8 @@
     if (!m_reader || !m_reader->isOK()) return 0;
 
 #ifdef DEBUG_WAVE_FILE_MODEL
-    std::cerr << "WaveFileModel::getValues(" << channel << ", "
-              << start << ", " << end << "): calling reader" << std::endl;
+//    std::cerr << "WaveFileModel::getValues(" << channel << ", "
+//              << start << ", " << end << "): calling reader" << std::endl;
 #endif
 
     SampleBlock frames;
--- a/data/model/WaveFileModel.h	Fri Apr 27 16:10:10 2007 +0000
+++ b/data/model/WaveFileModel.h	Mon Apr 30 09:07:42 2007 +0000
@@ -75,7 +75,7 @@
 
 signals:
     void modelChanged();
-    void modelChanged(size_t startFrame, size_t endFrame);
+    void modelChanged(size_t, size_t);
     void completionChanged();
 
 protected slots:
--- a/data/model/WritableWaveFileModel.cpp	Fri Apr 27 16:10:10 2007 +0000
+++ b/data/model/WritableWaveFileModel.cpp	Mon Apr 30 09:07:42 2007 +0000
@@ -26,6 +26,7 @@
 #include <cassert>
 #include <iostream>
 
+//#define DEBUG_WRITABLE_WAVE_FILE_MODEL 1
 
 WritableWaveFileModel::WritableWaveFileModel(size_t sampleRate,
 					     size_t channels,
@@ -75,8 +76,8 @@
         return;
     }
 
-    connect(m_model, SLOT(modelChanged()), this, SIGNAL(modelChanged()));
-    connect(m_model, SLOT(modelChanged(size_t, size_t)),
+    connect(m_model, SIGNAL(modelChanged()), this, SIGNAL(modelChanged()));
+    connect(m_model, SIGNAL(modelChanged(size_t, size_t)),
             this, SIGNAL(modelChanged(size_t, size_t)));
 }
 
@@ -92,6 +93,10 @@
 {
     if (!m_writer) return false;
 
+#ifdef DEBUG_WRITABLE_WAVE_FILE_MODEL
+//    std::cerr << "WritableWaveFileModel::addSamples(" << count << ")" << std::endl;
+#endif
+
     if (!m_writer->writeSamples(samples, count)) {
         std::cerr << "ERROR: WritableWaveFileModel::addSamples: writer failed: " << m_writer->getError().toStdString() << std::endl;
         return false;
@@ -102,8 +107,14 @@
     static int updateCounter = 0;
 
     if (m_reader && m_reader->getChannelCount() == 0) {
+#ifdef DEBUG_WRITABLE_WAVE_FILE_MODEL
+        std::cerr << "WritableWaveFileModel::addSamples(" << count << "): calling updateFrameCount (initial)" << std::endl;
+#endif
         m_reader->updateFrameCount();
     } else if (++updateCounter == 100) {
+#ifdef DEBUG_WRITABLE_WAVE_FILE_MODEL
+        std::cerr << "WritableWaveFileModel::addSamples(" << count << "): calling updateFrameCount (periodic)" << std::endl;
+#endif
         if (m_reader) m_reader->updateFrameCount();
         updateCounter = 0;
     }