Update of /cvsroot/audacity/audacity-src/src
In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv591/src

Modified Files:
        AudioIO.cpp Resample.h 
Log Message:
Provide more docs on resampling class. Use it correctly when resampling in real 
time during recording at a rate the sound device cannot provide. This fixes a 
problem when using libsamplerate for resampling which causes recording to stop 
short


Index: AudioIO.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/AudioIO.cpp,v
retrieving revision 1.241
retrieving revision 1.242
diff -u -d -r1.241 -r1.242
--- AudioIO.cpp 10 Dec 2009 02:26:44 -0000      1.241
+++ AudioIO.cpp 8 Jan 2010 22:33:52 -0000       1.242
@@ -2258,8 +2258,11 @@
                samplePtr temp1 = NewSamples(avail, floatSample);
                samplePtr temp2 = NewSamples(size, floatSample);
                mCaptureBuffers[i]->Get(temp1, floatSample, avail);
-
-               size = mResample[i]->Process(mFactor, (float *)temp1, avail, 
true,
+               /* we are re-sampling on the fly. The last resampling call
+                * must flush any samples left in the rate conversion buffer
+                * so that they get recorded
+                */
+               size = mResample[i]->Process(mFactor, (float *)temp1, avail, 
!IsStreamActive(),
                                             &size, (float *)temp2, size);
                mCaptureTracks[i]-> Append(temp2, floatSample, size, 1, 
                                           &appendLog);

Index: Resample.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Resample.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Resample.h  11 Feb 2009 03:09:23 -0000      1.3
+++ Resample.h  8 Jan 2010 22:33:55 -0000       1.4
@@ -73,14 +73,28 @@
    /// Returns true if the constructor succeeded.
    bool Ok();
 
-   /// Main processing function.  Reads up to inBufferLen samples
-   /// from the input buffer, and writes up to outBufferLen samples
-   /// to the output buffer.  Pass true in lastFlag if this is the
-   /// end of the input; otherwise not all of the input samples will
-   /// be used.  The number of input samples used is returned in
-   /// inBufferUsed, and the number of output samples generated
-   /// is the return value of the function.  This function may do
-   /// nothing if you don't pass a large enough output buffer.
+   /** @brief Main processing function. Resamples from the input buffer to the 
+    * output buffer.
+    *
+    * Reads samples from the input buffer, and writes samples to the output
+    * buffer. Stops when either is exhaughsted, or we reach a convenient block
+    * end, unless lastFlag is set to force emptying the input buffer.
+    * The number of input samples used is returned in inBufferUsed, and the
+    * number of output samples generated is the return value of the function. 
+    * This function may do nothing if you don't pass a large enough output
+    * buffer (i.e. there is no where to put a full block of output data)
+    @param factor The scaling factor to resample by.
+    @param inBuffer Buffer of input samples to be processed (mono)
+    @param inBufferLen Length of the input buffer, in samples.
+    @param lastFlag Flag to indicate this is the last lot of input samples and
+    the buffer needs to be emptied out into the rate converter.
+    @param inBufferUsed Number of samples from inBuffer that have been used 
+    (unless lastFlag is true, we don't garuntee to process all the samples in
+    the input this time, we may leave some for next time)
+    @param outBuffer Buffer to write output (converted) samples to.
+    @param outBufferLen How big outBuffer is.
+    @return Number of output samples created by this call
+   */
    int Process(double  factor,
                float  *inBuffer,
                int     inBufferLen,


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Audacity-cvs mailing list
Audacity-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to