changeset 429:6036b38177e2

* Fix crash when running Generator
author Chris Cannam
date Wed, 18 Jun 2008 13:40:10 +0000
parents 3e1d190048f4
children 304fd0223fa6
files data/model/WaveFileModel.cpp transform/FeatureExtractionModelTransformer.cpp transform/RealTimeEffectModelTransformer.cpp
diffstat 3 files changed, 23 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/data/model/WaveFileModel.cpp	Tue Jun 17 16:07:56 2008 +0000
+++ b/data/model/WaveFileModel.cpp	Wed Jun 18 13:40:10 2008 +0000
@@ -188,6 +188,10 @@
     // This is used for e.g. audio playback.
     // Could be much more efficient (although compiler optimisation will help)
 
+#ifdef DEBUG_WAVE_FILE_MODEL
+    std::cout << "WaveFileModel::getData[" << this << "]: " << channel << ", " << start << ", " << count << ", " << buffer << std::endl;
+#endif
+
     if (start >= m_startFrame) {
         start -= m_startFrame;
     } else {
@@ -246,6 +250,10 @@
 WaveFileModel::getData(int channel, size_t start, size_t count,
                        double *buffer) const
 {
+#ifdef DEBUG_WAVE_FILE_MODEL
+    std::cout << "WaveFileModel::getData(double)[" << this << "]: " << channel << ", " << start << ", " << count << ", " << buffer << std::endl;
+#endif
+
     if (start > m_startFrame) {
         start -= m_startFrame;
     } else {
@@ -300,6 +308,10 @@
                        size_t start, size_t count,
                        float **buffer) const
 {
+#ifdef DEBUG_WAVE_FILE_MODEL
+    std::cout << "WaveFileModel::getData[" << this << "]: " << fromchannel << "," << tochannel << ", " << start << ", " << count << ", " << buffer << std::endl;
+#endif
+
     size_t channels = getChannelCount();
 
     if (fromchannel > tochannel) {
--- a/transform/FeatureExtractionModelTransformer.cpp	Tue Jun 17 16:07:56 2008 +0000
+++ b/transform/FeatureExtractionModelTransformer.cpp	Wed Jun 18 13:40:10 2008 +0000
@@ -150,6 +150,7 @@
     }
     
     for (size_t i = 0; i < outputs.size(); ++i) {
+//        std::cerr << "comparing output " << i << " name \"" << outputs[i].identifier << "\" with expected \"" << m_transform.getOutput().toStdString() << "\"" << std::endl;
 	if (m_transform.getOutput() == "" ||
             outputs[i].identifier == m_transform.getOutput().toStdString()) {
 	    m_outputFeatureNo = i;
--- a/transform/RealTimeEffectModelTransformer.cpp	Tue Jun 17 16:07:56 2008 +0000
+++ b/transform/RealTimeEffectModelTransformer.cpp	Wed Jun 18 13:40:10 2008 +0000
@@ -196,15 +196,17 @@
                 }
             }
 	} else {
-            got = input->getData(0, channelCount - 1,
-                                 blockFrame, blockSize,
-                                 inbufs);
-            while (got < blockSize) {
-                for (size_t ch = 0; ch < channelCount; ++ch) {
-                    inbufs[ch][got] = 0.0;
+            if (inbufs && inbufs[0]) {
+                got = input->getData(0, channelCount - 1,
+                                     blockFrame, blockSize,
+                                     inbufs);
+                while (got < blockSize) {
+                    for (size_t ch = 0; ch < channelCount; ++ch) {
+                        inbufs[ch][got] = 0.0;
+                    }
+                    ++got;
                 }
-                ++got;
-	    }
+            }
             for (size_t ch = channelCount; ch < m_plugin->getAudioInputCount(); ++ch) {
                 for (long i = 0; i < blockSize; ++i) {
                     inbufs[ch][i] = inbufs[ch % channelCount][i];