void remove_dependents (boost::shared_ptr<Region> region);
void copy_dependents (const std::vector<TwoRegions>&, boost::shared_ptr<Playlist>);
- void pre_combine (std::vector<boost::shared_ptr<Region> >&, boost::shared_ptr<Region>);
+ void pre_combine (std::vector<boost::shared_ptr<Region> >&);
+ void post_combine (std::vector<boost::shared_ptr<Region> >&, boost::shared_ptr<Region>);
void pre_uncombine (std::vector<boost::shared_ptr<Region> >&, boost::shared_ptr<Region>);
private:
framepos_t start;
};
- virtual void pre_combine (std::vector<boost::shared_ptr<Region> >&, boost::shared_ptr<Region>) {}
+ /* this is called before we create a new compound region */
+ virtual void pre_combine (std::vector<boost::shared_ptr<Region> >&) {}
+ /* this is called before we create a new compound region */
+ virtual void post_combine (std::vector<boost::shared_ptr<Region> >&, boost::shared_ptr<Region>) {}
+ /* this is called before we remove a compound region and replace it
+ with its constituent regions
+ */
virtual void pre_uncombine (std::vector<boost::shared_ptr<Region> >&, boost::shared_ptr<Region>) {}
};
}
void
-AudioPlaylist::pre_combine (vector<boost::shared_ptr<Region> >& originals, boost::shared_ptr<Region> compound_region)
+AudioPlaylist::pre_combine (vector<boost::shared_ptr<Region> >& copies)
{
- /* sort the originals into time order */
+ RegionSortByPosition cmp;
+ boost::shared_ptr<AudioRegion> ar;
+
+ sort (copies.begin(), copies.end(), cmp);
+
+ ar = boost::dynamic_pointer_cast<AudioRegion> (copies.front());
+
+ /* copy the fade in of the first into the compound region */
+
+ if (ar) {
+ ar->set_fade_in_active (false);
+ }
+ ar = boost::dynamic_pointer_cast<AudioRegion> (copies.back());
+
+ if (ar) {
+ ar->set_fade_out_active (false);
+ }
+}
+
+void
+AudioPlaylist::post_combine (vector<boost::shared_ptr<Region> >& originals, boost::shared_ptr<Region> compound_region)
+{
RegionSortByPosition cmp;
boost::shared_ptr<AudioRegion> ar;
boost::shared_ptr<AudioRegion> cr;
if (ar) {
cr->set_fade_in (ar->fade_in());
-
- /* disable the fade in of the first */
-
ar->set_fade_in_active (false);
}
if (ar) {
/* copy the fade out of the last into the compound region */
cr->set_fade_out (ar->fade_out());
- /* disable the fade out of the first */
ar->set_fade_out_active (false);
}
}
framepos_t earliest_position = max_framepos;
vector<TwoRegions> old_and_new_regions;
vector<boost::shared_ptr<Region> > originals;
+ vector<boost::shared_ptr<Region> > copies;
string parent_name;
string child_name;
uint32_t max_level = 0;
old_and_new_regions.push_back (TwoRegions (original_region,copied_region));
originals.push_back (original_region);
+ copies.push_back (copied_region);
RegionFactory::add_compound_association (original_region, copied_region);
pl->in_partition = false;
+ pre_combine (copies);
+
/* now create a new PlaylistSource for each channel in the new playlist */
SourceList sources;
for (uint32_t chn = 0; chn < channels; ++chn) {
sources.push_back (SourceFactory::createFromPlaylist (_type, _session, pl, parent_name, chn, 0, extent.second, false, false));
}
+
/* now a new whole-file region using the list of sources */
/* do type-specific stuff with the originals and the new compound
region
*/
-
- pre_combine (originals, compound_region);
+
+ post_combine (originals, compound_region);
/* add the new region at the right location */