Update of /cvsroot/audacity/audacity-src/src/effects
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv26547/src/effects

Modified Files:
        TruncSilence.cpp 
Log Message:
Fix handling of silent sections which span a block boundary

Index: TruncSilence.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/TruncSilence.cpp,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- TruncSilence.cpp    28 Aug 2009 15:19:05 -0000      1.30
+++ TruncSilence.cpp    10 Nov 2009 00:06:05 -0000      1.31
@@ -305,7 +305,13 @@
                // Include the cross-fade samples in the count to make the loop 
logic easier
                keep += rampInFrames;
                truncIndex -= rampInFrames;
-
+               if(truncIndex < 0) {
+                  // This happens when we have silence overlapping a block 
boundary
+                  keep += truncIndex;
+                  if(keep < 0)
+                     keep = 0;
+                  truncIndex = 0;
+               }
                // back up for cross-fade
                sampleCount curOffset = i - keep;
 
@@ -316,10 +322,6 @@
                      keep = mBlendFrameCount;
                   curOffset = 0;
                }
-               if(truncIndex < 0) {
-                  // This should never happen, but just in case...
-                  truncIndex = 0;
-               }
 
                for (tndx = 0; tndx < tcount; tndx++) {
                   // Cross fade the cut point
@@ -358,23 +360,41 @@
       }
 
       // If currently in a silent section, retain samples for the next pass
-      if(ignoringFrames) {
-         keep = consecutiveSilentFrames - truncInitialAllowedSilentSamples;
-         if(keep > (truncLongestAllowedSilentSamples+mBlendFrameCount))
-            keep = truncLongestAllowedSilentSamples+mBlendFrameCount;
-         for (tndx = 0; tndx < tcount; tndx++) {
-            for(fr = 0; fr < truncInitialAllowedSilentSamples; fr++) {
-               buffer[tndx][fr] = 
buffer[tndx][truncIndex-truncInitialAllowedSilentSamples+fr];
+      if(consecutiveSilentFrames > mBlendFrameCount) {
+         if (ignoringFrames == true) {
+            // Retain only what we need for truncating the silence
+            keep = consecutiveSilentFrames-truncInitialAllowedSilentSamples;
+            if(keep > (truncLongestAllowedSilentSamples+mBlendFrameCount))
+               keep = truncLongestAllowedSilentSamples+mBlendFrameCount;
+            for (tndx = 0; tndx < tcount; tndx++) {
+               // Cross fade the cut point
+               for(fr = 0; fr < mBlendFrameCount; fr++) {
+                  buffer[tndx][fr] = 
((mBlendFrameCount-fr)*buffer[tndx][truncIndex-mBlendFrameCount+fr]
+                                   + fr*buffer[tndx][i-keep+fr]) / 
mBlendFrameCount;
+               }
+               for( ; fr < keep; fr++) {
+                  buffer[tndx][fr] = buffer[tndx][i-keep+fr];
+               }
             }
-            for(fr = 0; fr < keep; fr++) {
-               buffer[tndx][truncInitialAllowedSilentSamples+fr] = 
buffer[tndx][i-keep+fr];
+            // Update the output index, less what we are retaining for next 
time
+            outTrackOffset += truncIndex - mBlendFrameCount;
+            // Append the following buffer to the existing data
+            i = keep;
+            truncIndex = mBlendFrameCount;
+         } else {
+            // Retain the silent samples for the next buffer
+            keep = consecutiveSilentFrames;
+            for (tndx = 0; tndx < tcount; tndx++) {
+               for(fr=0 ; fr < keep; fr++) {
+                  buffer[tndx][fr] = buffer[tndx][i-keep+fr];
+               }
             }
+            // Update the output index, less what we are retaining for next 
time
+            outTrackOffset += truncIndex - keep;
+            // Append the following buffer to the existing data
+            i = keep;
+            truncIndex = keep;
          }
-         // Update the output index, less what we are retaining for next time
-         outTrackOffset += truncIndex - truncInitialAllowedSilentSamples;
-         // Append the following buffer to the existing data
-         i = consecutiveSilentFrames = truncInitialAllowedSilentSamples + keep;
-         truncIndex = truncInitialAllowedSilentSamples;
       } else {
          // Maintain output index
          outTrackOffset += truncIndex;


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Audacity-cvs mailing list
Audacity-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to