13
0

Add function to duplicate until a certain frame.

This excludes the 'end' frame.
This commit is contained in:
André Nusser 2015-11-26 17:25:13 +01:00 committed by Paul Davis
parent add37c6b96
commit ba4db8f6cb
2 changed files with 34 additions and 0 deletions

View File

@ -141,6 +141,7 @@ public:
void partition (framepos_t start, framepos_t end, bool cut = false); void partition (framepos_t start, framepos_t end, bool cut = false);
void duplicate (boost::shared_ptr<Region>, framepos_t position, float times); void duplicate (boost::shared_ptr<Region>, framepos_t position, float times);
void duplicate (boost::shared_ptr<Region>, framepos_t position, framecnt_t gap, float times); void duplicate (boost::shared_ptr<Region>, framepos_t position, framecnt_t gap, float times);
void duplicate_until (boost::shared_ptr<Region>, framepos_t position, framecnt_t gap, framepos_t end);
void nudge_after (framepos_t start, framecnt_t distance, bool forwards); void nudge_after (framepos_t start, framecnt_t distance, bool forwards);
boost::shared_ptr<Region> combine (const RegionList&); boost::shared_ptr<Region> combine (const RegionList&);
void uncombine (boost::shared_ptr<Region>); void uncombine (boost::shared_ptr<Region>);

View File

@ -1283,6 +1283,39 @@ Playlist::flush_notifications (bool from_undo)
} }
} }
/** @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)
{
RegionWriteLock rl (this);
while (position + region->length() - 1 < end) {
boost::shared_ptr<Region> copy = RegionFactory::create (region, true);
add_region_internal (copy, position);
set_layer (copy, DBL_MAX);
position += gap;
}
if (position < end) {
framecnt_t length = min (region->length(), end - position);
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);
}
}
}
void void
Playlist::shift (framepos_t at, frameoffset_t distance, bool move_intersected, bool ignore_music_glue) Playlist::shift (framepos_t at, frameoffset_t distance, bool move_intersected, bool ignore_music_glue)
{ {