+
+void
+Playlist::duplicate (boost::shared_ptr<Region> region, framepos_t position, float times)
+{
+ duplicate(region, position, region->length(), times);
+}
+
+/** @param gap from the beginning of the region to the next beginning */
+void
+Playlist::duplicate (boost::shared_ptr<Region> region, framepos_t position, framecnt_t gap, float times)
+{
+ times = fabs (times);
+
+ RegionWriteLock rl (this);
+ int itimes = (int) floor (times);
+
+ while (itimes--) {
+ boost::shared_ptr<Region> copy = RegionFactory::create (region, true);
+ add_region_internal (copy, position);
+ set_layer (copy, DBL_MAX);
+ position += gap;
+ }
+
+ if (floor (times) != times) {
+ framecnt_t length = (framecnt_t) floor (region->length() * (times - floor (times)));
+ string name;
+ RegionFactory::region_name (name, region->name(), false);
+
+ {
+ PropertyList plist;
+
+ plist.add (Properties::start, region->start());
+ plist.add (Properties::length, length);
+ plist.add (Properties::name, name);
+
+ boost::shared_ptr<Region> sub = RegionFactory::create (region, plist);
+ add_region_internal (sub, position);
+ set_layer (sub, DBL_MAX);
+ }
+ }
+}
+
+/** @param gap from the beginning of the region to the next beginning */
+/** @param end the first frame that does _not_ contain a duplicated frame */
+void
+Playlist::duplicate_until (boost::shared_ptr<Region> region, framepos_t position, framecnt_t gap, framepos_t end)
+{