changes to help strp silence
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 3 Mar 2010 23:39:26 +0000 (23:39 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 3 Mar 2010 23:39:26 +0000 (23:39 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@6725 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/audioregion.h
libs/ardour/audioregion.cc
libs/ardour/strip_silence.cc

index ec9a64002f95991a7d9aa76c0d8a38d204e6f7d1..59876d6e56d5caa1d67c3dbcf8173862a85c9af4 100644 (file)
@@ -178,7 +178,7 @@ class AudioRegion : public Region
        void resume_fade_out ();
 
        int get_transients (AnalysisFeatureList&, bool force_new = false);
-       std::list<std::pair<frameoffset_t, framecnt_t> > find_silence (Sample, framecnt_t) const;
+       std::list<std::pair<frameoffset_t, framecnt_t> > find_silence (Sample, framecnt_t, InterThreadInfo&) const;
 
   private:
        friend class RegionFactory;
index abddffc12e887dce54a7f7fbbf9b11469817a839..2cdb0dfbd12095e5745ed033446086b4f2ecdb5c 100644 (file)
@@ -1458,7 +1458,7 @@ then quit ardour and restart."));
  */
 
 std::list<std::pair<frameoffset_t, framecnt_t> >
-AudioRegion::find_silence (Sample threshold, framecnt_t min_length) const
+AudioRegion::find_silence (Sample threshold, framecnt_t min_length, InterThreadInfo& itt) const
 {
        framecnt_t const block_size = 64 * 1024;
        Sample loudest[block_size];
@@ -1473,7 +1473,7 @@ AudioRegion::find_silence (Sample threshold, framecnt_t min_length) const
        frameoffset_t silence_start = 0;
        bool silence;
 
-       while (pos < end) {
+       while (pos < end && !itt.cancel) {
 
                /* fill `loudest' with the loudest absolute sample at each instant, across all channels */
                memset (loudest, 0, sizeof (Sample) * block_size);
@@ -1502,6 +1502,7 @@ AudioRegion::find_silence (Sample threshold, framecnt_t min_length) const
                }
 
                pos += block_size;
+                itt.progress = (end-pos)/(double)_length;
        }
 
        if (in_silence && end - 1 - silence_start >= min_length) {
@@ -1509,6 +1510,8 @@ AudioRegion::find_silence (Sample threshold, framecnt_t min_length) const
                silent_periods.push_back (std::make_pair (silence_start, end));
        }
 
+        itt.done = true;
+
        return silent_periods;
 }
 
index 0f58ccf9a3efc81c8eb9b272c53c7dd23bf53179..ae35eebd8f537f431494313953a0f32b133f7d36 100644 (file)
@@ -46,14 +46,25 @@ StripSilence::run (boost::shared_ptr<Region> r)
        /* we only operate on AudioRegions, for now, though this could be adapted to MIDI
           as well I guess */
        boost::shared_ptr<AudioRegion> region = boost::dynamic_pointer_cast<AudioRegion> (r);
+        InterThreadInfo itt;
+        
        if (!region) {
                results.push_back (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);
+               region->find_silence (dB_to_coefficient (_threshold), _minimum_length, itt);
 
        if (silence.size () == 1 && silence.front().first == 0 && silence.front().second == region->length() - 1) {
                /* the region is all silence, so just return with nothing */