- if (silence.back().second == end) {
- /* the last region we created is zero-sized, so just remove it */
- results.pop_back ();
- } else {
- /* finish off the last region */
- last_region->trim_end (end, 0);
- }
+ int n = 0;
+ int const N = audible.size ();
+
+ for (AudioIntervalResult::const_iterator i = audible.begin(); i != audible.end(); ++i, ++n) {
+
+ PBD::PropertyList plist;
+ boost::shared_ptr<AudioRegion> copy;
+
+ plist.add (Properties::length, i->second - i->first);
+ plist.add (Properties::position, r->position() + (i->first - r->start()));
+
+ copy = boost::dynamic_pointer_cast<AudioRegion> (
+ RegionFactory::create (region, MusicFrame (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) / 2);
+
+ 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)) {
+ progress->set_progress (float (n) / N);
+ }
+ }