Fix --no-nls (4/5), i18n include order in libs/*
[ardour.git] / libs / ardour / strip_silence.cc
index ff79371b966551bbc54fcd2dc1ce6751316e04f6..8aa703740bdc707705a807134e2c4b9c1f2c9b61 100644 (file)
@@ -32,7 +32,7 @@ using namespace ARDOUR;
  *  @param fade_length Length of fade in/out to apply to trimmed regions, in samples.
  */
 
-StripSilence::StripSilence (Session & s, const AudioIntervalMap& sm, framecnt_t fade_length)
+StripSilence::StripSilence (Session & s, const AudioIntervalMap& sm, samplecnt_t fade_length)
        : Filter (s)
         , _smap (sm)
         , _fade_length (fade_length)
@@ -98,7 +98,7 @@ StripSilence::run (boost::shared_ptr<Region> r, Progress* progress)
        AudioIntervalResult::const_iterator last_silence = silence.end ();
        --last_silence;
 
-       frameoffset_t const end_of_region = r->start() + r->length();
+       sampleoffset_t const end_of_region = r->start() + r->length();
 
        if (last_silence->second < end_of_region - 1) {
                audible.push_back (std::make_pair (last_silence->second, end_of_region - 1));
@@ -116,16 +116,22 @@ StripSilence::run (boost::shared_ptr<Region> r, Progress* progress)
                plist.add (Properties::position, r->position() + (i->first - r->start()));
 
                copy = boost::dynamic_pointer_cast<AudioRegion> (
-                       RegionFactory::create (region, (i->first - r->start()), plist)
+                       RegionFactory::create (region, MusicSample (i->first - r->start(), 0), plist)
                        );
 
                copy->set_name (RegionFactory::new_region_name (region->name ()));
 
-               framecnt_t const f = std::min (_fade_length, (i->second - i->first));
+               samplecnt_t const f = std::min (_fade_length, (i->second - i->first) / 2);
 
-               copy->set_fade_in_active (true);
-               copy->set_fade_in (FadeLinear, f);
-               copy->set_fade_out (FadeLinear, f);
+               if (f > 0) {
+                       copy->set_fade_in_active (true);
+                       copy->set_fade_out_active (true);
+                       copy->set_fade_in (FadeLinear, f);
+                       copy->set_fade_out (FadeLinear, f);
+               } else {
+                       copy->set_fade_in_active (false);
+                       copy->set_fade_out_active (false);
+               }
                results.push_back (copy);
 
                if (progress && (n <= N)) {