- std::list<std::pair<framepos_t, framecnt_t > >::const_iterator s = silence.begin ();
- framepos_t const pos = region->position ();
- framepos_t const end = region->start () + region->length() - 1;
- framepos_t const start = region->start ();
-
- region = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create (region));
- region->set_name (session.new_region_name (region->name ()));
- boost::shared_ptr<AudioRegion> last_region = region;
- results.push_back (region);
-
- if (s->first == 0) {
- /* the region starts with some silence */
-
- /* we must set length to an intermediate value here, otherwise the call
- ** to set_start will fail */
- region->set_length (region->length() - s->second + _fade_length, 0);
- region->set_start (start + s->second - _fade_length, 0);
- region->set_position (pos + s->second - _fade_length, 0);
- region->set_fade_in_active (true);
- region->set_fade_in (AudioRegion::Linear, _fade_length);
- s++;
+ /* Turn the silence list into an `audible' list */
+ AudioIntervalResult audible;
+
+ /* Add the possible audible section at the start of the region */
+ AudioIntervalResult::const_iterator first_silence = silence.begin ();
+ if (first_silence->first != region->start()) {
+ audible.push_back (std::make_pair (r->start(), first_silence->first));