Fix VST build.
[ardour.git] / libs / ardour / strip_silence.cc
index 3952311aa22449e38fc46596a3124c7704fd6b3e..cf03c2df8ba95b8e54bd473d851209f7f4419845 100644 (file)
@@ -24,6 +24,7 @@
 #include "ardour/region_factory.h"
 #include "ardour/session.h"
 #include "ardour/dB.h"
+#include "ardour/progress.h"
 
 using namespace ARDOUR;
 
@@ -34,14 +35,14 @@ using namespace ARDOUR;
  *  @param fade_length Length of fade in/out to apply to trimmed regions, in samples.
  */
 
-StripSilence::StripSilence (Session & s, double threshold, nframes_t minimum_length, nframes_t fade_length)
+StripSilence::StripSilence (Session & s, double threshold, framecnt_t minimum_length, framecnt_t fade_length)
        : Filter (s), _threshold (threshold), _minimum_length (minimum_length), _fade_length (fade_length)
 {
 
 }
 
 int
-StripSilence::run (boost::shared_ptr<Region> r)
+StripSilence::run (boost::shared_ptr<Region> r, Progress* progress)
 {
        results.clear ();
 
@@ -56,15 +57,6 @@ StripSilence::run (boost::shared_ptr<Region> r)
                return -1;
        }
 
-        /* we don't care about this but we need to fill out the fields
-           anyway. XXX should really be a default constructor for ITT
-        */
-
-        itt.done = false;
-        itt.cancel = false;
-        itt.progress = 0.0;
-        itt.thread = 0;
-
        /* find periods of silence in the region */
        std::list<std::pair<frameoffset_t, framecnt_t> > const silence =
                region->find_silence (dB_to_coefficient (_threshold), _minimum_length, itt);
@@ -97,6 +89,9 @@ StripSilence::run (boost::shared_ptr<Region> r)
                 in_silence = false;
         }
 
+       int n = 0;
+       int const N = silence.size ();
+
         while (s != silence.end()) {
 
                 framecnt_t interval_duration;
@@ -120,7 +115,7 @@ StripSilence::run (boost::shared_ptr<Region> r)
                                 copy->position() << std::endl;
 
                         copy->set_fade_in_active (true);
-                        copy->set_fade_in (AudioRegion::Linear, _fade_length);
+                        copy->set_fade_in (FadeLinear, _fade_length);
                         results.push_back (copy);
                 }
 
@@ -128,6 +123,11 @@ StripSilence::run (boost::shared_ptr<Region> r)
                 ++s;
                 end = s->first;
                 in_silence = !in_silence;
+
+               if (progress) {
+                       progress->set_progress (float (n) / N);
+               }
+               ++n;
         }
 
        return 0;