diff audioio/AudioCallbackPlaySource.cpp @ 31:37af203dbd15

* Buffer size fixes in the time stretcher, to avoid running out of input data for large or small ratios
author Chris Cannam
date Thu, 21 Sep 2006 09:43:41 +0000
parents d88d117e0c34
children e3b32dc5180b
line wrap: on
line diff
--- a/audioio/AudioCallbackPlaySource.cpp	Wed Sep 20 16:02:42 2006 +0000
+++ b/audioio/AudioCallbackPlaySource.cpp	Thu Sep 21 09:43:41 2006 +0000
@@ -619,7 +619,7 @@
              channels,
              factor,
              sharpen,
-             lrintf(getTargetBlockSize() / factor));
+             getTargetBlockSize());
 
 	m_timeStretcher = newStretcher;
 
@@ -688,6 +688,21 @@
 
     size_t available;
 
+    int warned = 0;
+
+    
+
+    //!!!
+    // We want output blocks of e.g. 1024 (probably fixed, certainly
+    // bounded).  We can provide input blocks of any size (unbounded)
+    // at the timestretcher's request.  The input block for a given
+    // output is approx output / ratio, but we can't predict it
+    // exactly, for an adaptive timestretcher.  The stretcher will
+    // need some additional buffer space.
+
+
+
+
     while ((available = ts->getAvailableOutputSamples()) < count) {
 
         size_t reqd = lrintf((count - available) / ratio);
@@ -735,8 +750,8 @@
         if (got == 0) break;
 
         if (ts->getAvailableOutputSamples() == available) {
-            std::cerr << "WARNING: AudioCallbackPlaySource::getSamples: Added " << got << " samples to time stretcher, created no new available output samples" << std::endl;
-            break;
+            std::cerr << "WARNING: AudioCallbackPlaySource::getSamples: Added " << got << " samples to time stretcher, created no new available output samples (warned = " << warned << ")" << std::endl;
+            if (++warned == 5) break;
         }
     }