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

Modified Files:
        WaveClip.cpp WaveClip.h Menus.cpp WaveTrack.cpp WaveTrack.h 
Log Message:
Adds a progress dialog to the Track->Resample function

Index: WaveTrack.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/WaveTrack.h,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- WaveTrack.h 25 Jul 2006 18:50:21 -0000      1.42
+++ WaveTrack.h 7 Sep 2006 05:27:56 -0000       1.43
@@ -294,7 +294,7 @@
    virtual void Merge(const Track &orig);
    
    // Resample track (i.e. all clips in the track)
-   bool Resample(int rate);
+   bool Resample(int rate, bool progress = false);
 
    //
    // The following code will eventually become part of a GUIWaveTrack

Index: WaveTrack.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/WaveTrack.cpp,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- WaveTrack.cpp       25 Aug 2006 05:12:16 -0000      1.88
+++ WaveTrack.cpp       7 Sep 2006 05:27:56 -0000       1.89
@@ -1505,10 +1505,10 @@
    return true;
 }
 
-bool WaveTrack::Resample(int rate)
+bool WaveTrack::Resample(int rate, bool progress)
 {
    for (WaveClipList::Node* it=GetClipIterator(); it; it=it->GetNext())
-      if (!it->GetData()->Resample(rate))
+      if (!it->GetData()->Resample(rate, progress))
       {
          // FIXME: The track is now in an inconsistent state since some
          //        clips are resampled and some are not

Index: Menus.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Menus.cpp,v
retrieving revision 1.271
retrieving revision 1.272
diff -u -d -r1.271 -r1.272
--- Menus.cpp   5 Sep 2006 23:44:21 -0000       1.271
+++ Menus.cpp   7 Sep 2006 05:27:56 -0000       1.272
@@ -4359,13 +4359,22 @@
       else
          break;
    }
-      
+
+   int ndx = 0;
    for (Track *t = iter.First(); t; t = iter.Next())
    {
+      wxString msg;
+      
+      msg.Printf(_("Resampling track %d"), ++ndx);
+
+      GetActiveProject()->ProgressShow(_("Resample"),
+                                       msg);
+
       if (t->GetSelected() && t->GetKind() == Track::Wave)
-         if (!((WaveTrack*)t)->Resample(newRate))
+         if (!((WaveTrack*)t)->Resample(newRate, true))
             break;
    }
+   GetActiveProject()->ProgressHide();
    
    PushState(_("Resampled audio track(s)"), _("Resample Track"));
    RedrawProject();

Index: WaveClip.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/WaveClip.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- WaveClip.cpp        24 Jul 2006 14:58:57 -0000      1.19
+++ WaveClip.cpp        7 Sep 2006 05:27:56 -0000       1.20
@@ -34,6 +34,7 @@
 #include "WaveClip.h"
 #include "Envelope.h"
 #include "Resample.h"
+#include "Project.h"
 
 #include <wx/listimpl.cpp>
 WX_DEFINE_LIST(WaveClipList);
@@ -1003,7 +1004,7 @@
       it->GetData()->Unlock();
 }
 
-bool WaveClip::Resample(int rate)
+bool WaveClip::Resample(int rate, bool progress)
 {
    if (rate == mRate)
       return true; // Nothing to do
@@ -1016,17 +1017,18 @@
    float* outBuffer = new float[bufsize];
    int pos = 0;
    bool error = false;
-   
+   sampleCount numSamples = mSequence->GetNumSamples();
+
    Sequence* newSequence =
       new Sequence(mSequence->GetDirManager(), mSequence->GetSampleFormat());
    
-   while (pos < mSequence->GetNumSamples())
+   while (pos < numSamples)
    {
-      int inLen = mSequence->GetNumSamples() - pos;
+      int inLen = numSamples - pos;
       if (inLen > bufsize)
          inLen = bufsize;
          
-      bool isLast = ((pos + inLen) == mSequence->GetNumSamples());
+      bool isLast = ((pos + inLen) == numSamples);
       
       if (!mSequence->Get((samplePtr)inBuffer, floatSample, pos, inLen))
       {
@@ -1052,6 +1054,15 @@
          error = true;
          break;
       }
+
+      if (progress)
+      {
+         error = !GetActiveProject()->ProgressUpdate((int) (1000 * ((float)pos 
/ numSamples)));
+         if (error)
+         {
+            break;
+         }
+      }
    }
    
    delete[] inBuffer;

Index: WaveClip.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/WaveClip.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- WaveClip.h  24 Jul 2006 14:58:57 -0000      1.13
+++ WaveClip.h  7 Sep 2006 05:27:56 -0000       1.14
@@ -61,7 +61,7 @@
    
    // Resample clip. This also will set the rate, but without changing
    // the length of the clip
-   bool Resample(int rate);
+   bool Resample(int rate, bool progress = false);
    
    void SetOffset(double offset);
    double GetOffset() const { return mOffset; }


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to