Update of /cvsroot/audacity/audacity-src/src/effects
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv26114

Modified Files:
        Repeat.cpp 
Log Message:
Just copies the selection over and over, including the envelope.  Keeps it as a 
clip if a clip is repeated, or not if not.  Selects the new bit.

Index: Repeat.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/effects/Repeat.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- Repeat.cpp  29 Jul 2007 11:02:34 -0000      1.19
+++ Repeat.cpp  18 Aug 2007 23:48:44 -0000      1.20
@@ -109,9 +109,7 @@
 {
    TrackListIterator iter(mWaveTracks);
    WaveTrack *track = (WaveTrack *) iter.First();
-   int count = 0;
-       double maxDestLen = 0.0; // used to change selection to original plus 
generated
-       double newDestLen = 0.0;
+       double maxDestLen = 0.0; // used to change selection to generated bit
    while (track) {
       double trackStart = track->GetStartTime();
       double trackEnd = track->GetEndTime();
@@ -124,102 +122,29 @@
       longSampleCount start = track->TimeToLongSamples(t0);
       longSampleCount end = track->TimeToLongSamples(t1);
       sampleCount len = (sampleCount)(end - start);
+      double tLen = track->LongSamplesToTime(len);
+      double tc = t0 + tLen;
 
       if (len <= 0)
          continue;
 
-      //
-      // Create a track that contains 1 or more copies of the
-      // selection, cleverly arranged so that every BlockFile
-      // is within the minimum and maxmimum lengths of a normal
-      // BlockFile.  That allows us to repeat the same sequence
-      // of identical BlockFiles, saving lots of disk space.
-      //
-
-      sampleFormat format = track->GetSampleFormat();
-      WaveTrack *unitTrack = mFactory->NewWaveTrack(format, track->GetRate());
-      WaveTrack *dest = mFactory->NewWaveTrack(format, track->GetRate());
-      sampleCount maxBlockSize = unitTrack->GetMaxBlockSize();
-      sampleCount minBlockSize = maxBlockSize / 2;
-      samplePtr buffer = NewSamples(maxBlockSize, format);
-
-      int numCopies = 1;
-      int chunkSize = len;
-      int j;
-
-      while (chunkSize * numCopies < minBlockSize)
-         numCopies++;
-      
-      if (chunkSize > maxBlockSize) {
-         j=2;
-
-         while(chunkSize/j >= maxBlockSize)
-            j++;
-
-         chunkSize = (chunkSize + (j-1)) / j;
-      }
-
-      sampleCount totalSamples = 0;
-      while(totalSamples < len * numCopies) {
-         sampleCount blockLen = chunkSize;
-         sampleCount blockStart = (totalSamples % len);
-
-         if (totalSamples + blockLen > len * numCopies)
-            blockLen = len * numCopies - totalSamples;
-
-         if (!track->Get(buffer, format, start+blockStart, blockLen)) {
-            delete unitTrack;
-            return false;
-         }
-
-         unitTrack->Append(buffer, format, blockLen);
-         if (numCopies == 1)
-            unitTrack->Flush();
-
-         totalSamples += blockLen;
+      Track *dest;
+      track->Copy(t0, t1, &dest);
+      for(int j=0; j<repeatCount; j++)
+      {
+         if(!track->Paste(tc, dest))
+            break;
+         tc += tLen;
       }
-      if (numCopies != 1)
-         unitTrack->Flush();
-
-      //
-      // Repeat the unit track enough times, possible creating a few
-      // more than desired
-      //
-
-      int desiredCopies = repeatCount+1;
-      int desiredUnitTracks = (desiredCopies + (numCopies-1)) / numCopies;
-      for(j=0; j<desiredUnitTracks; j++)
-         dest->Paste(dest->GetEndTime(), unitTrack);
-
-      //
-      // If necessary, delete a few copies from the end
-      //
-
-      int actualCopies = desiredUnitTracks * numCopies;
-      if (actualCopies > desiredCopies) {
-         double oneLen = unitTrack->GetEndTime() / numCopies;
-         double clearLen = oneLen * (actualCopies - desiredCopies);
-                       double oldDestLen = dest->GetEndTime();
-                       newDestLen = oldDestLen - clearLen;
-         dest->Clear(newDestLen, oldDestLen);
-      } else {
-                       newDestLen = dest->GetEndTime();
-               }
-
-               if (newDestLen > maxDestLen)
-                       maxDestLen = newDestLen;
-
-      track->Clear(t0, t1);
-      track->Paste(t0, dest);
-
-      delete unitTrack;
+      if (tc > maxDestLen)
+         maxDestLen = tc;
       delete dest;
 
       track = (WaveTrack *) iter.Next();
-      count++;
    }
-
-       mT1 = mT0 + maxDestLen; // Change selection to original plus generated.
+   // Change selection to just the generated bits.
+   mT0 = mT1;
+       mT1 = maxDestLen;
    return true;
 }
 


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to