summaryrefslogtreecommitdiff
path: root/libs/ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-05-25 12:19:24 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-05-25 12:19:24 +0000
commite984220eaaa318d9b51ebb20995d1bccae389389 (patch)
tree9e1eb88a532f642c2f5682817198ea0ae6414cb9 /libs/ardour
parent49785b8fbb3f21080c75bb1162f387db914faae2 (diff)
correct the logic used when building a compound region to include a whole-file (whole-source) region as a parent for the region list
git-svn-id: svn://localhost/ardour2/branches/3.0@9584 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r--libs/ardour/ardour/playlist.h2
-rw-r--r--libs/ardour/ardour/region_factory.h2
-rw-r--r--libs/ardour/playlist.cc42
-rw-r--r--libs/ardour/region_factory.cc8
4 files changed, 41 insertions, 13 deletions
diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h
index 5eaf10273d..5406886faa 100644
--- a/libs/ardour/ardour/playlist.h
+++ b/libs/ardour/ardour/playlist.h
@@ -139,7 +139,7 @@ public:
void partition (framepos_t start, framepos_t end, bool cut = false);
void duplicate (boost::shared_ptr<Region>, framepos_t position, float times);
void nudge_after (framepos_t start, framecnt_t distance, bool forwards);
- boost::shared_ptr<Region> combine (const RegionList&, const std::string&);
+ boost::shared_ptr<Region> combine (const RegionList&);
void uncombine (boost::shared_ptr<Region>);
void shuffle (boost::shared_ptr<Region>, int dir);
diff --git a/libs/ardour/ardour/region_factory.h b/libs/ardour/ardour/region_factory.h
index 7feca25495..90716f8718 100644
--- a/libs/ardour/ardour/region_factory.h
+++ b/libs/ardour/ardour/region_factory.h
@@ -91,7 +91,7 @@ public:
static int region_name (std::string &, std::string, bool new_level = false);
static std::string new_region_name (std::string);
- static std::string compound_region_name (const std::string& playlist, uint32_t compound_ops, uint32_t depth);
+ static std::string compound_region_name (const std::string& playlist, uint32_t compound_ops, uint32_t depth, bool whole_source);
/* when we make a compound region, for every region involved there
* are two "instances" - the original, which is removed from this
diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc
index 4157ab4459..4a5405841f 100644
--- a/libs/ardour/playlist.cc
+++ b/libs/ardour/playlist.cc
@@ -3153,15 +3153,27 @@ Playlist::find_next_top_layer_position (framepos_t t) const
}
boost::shared_ptr<Region>
-Playlist::combine (const RegionList& r, const std::string& name)
+Playlist::combine (const RegionList& r)
{
PropertyList plist;
uint32_t channels = 0;
uint32_t layer = 0;
framepos_t earliest_position = max_framepos;
vector<TwoRegions> old_and_new_regions;
+ string parent_name;
+ string child_name;
+ uint32_t max_level = 0;
- boost::shared_ptr<Playlist> pl = PlaylistFactory::create (_type, _session, name, true);
+ /* find the maximum depth of all the regions we're combining */
+
+ for (RegionList::const_iterator i = r.begin(); i != r.end(); ++i) {
+ max_level = max (max_level, (*i)->max_source_level());
+ }
+
+ parent_name = RegionFactory::compound_region_name (name(), combine_ops(), max_level, true);
+ child_name = RegionFactory::compound_region_name (name(), combine_ops(), max_level, false);
+
+ boost::shared_ptr<Playlist> pl = PlaylistFactory::create (_type, _session, parent_name, true);
for (RegionList::const_iterator i = r.begin(); i != r.end(); ++i) {
earliest_position = min (earliest_position, (*i)->position());
@@ -3205,17 +3217,29 @@ Playlist::combine (const RegionList& r, const std::string& name)
pair<framepos_t,framepos_t> extent = pl->get_extent();
for (uint32_t chn = 0; chn < channels; ++chn) {
- sources.push_back (SourceFactory::createFromPlaylist (_type, _session, pl, name, chn, 0, extent.second, false, false));
+ sources.push_back (SourceFactory::createFromPlaylist (_type, _session, pl, parent_name, chn, 0, extent.second, false, false));
}
- /* now a new region using the list of sources */
+ /* now a new whole-file region using the list of sources */
plist.add (Properties::start, 0);
plist.add (Properties::length, extent.second);
- plist.add (Properties::name, name);
+ plist.add (Properties::name, parent_name);
+ plist.add (Properties::whole_file, true);
+
+ boost::shared_ptr<Region> parent_region = RegionFactory::create (sources, plist, true);
+
+ /* now the non-whole-file region that we will actually use in the
+ * playlist
+ */
+
+ plist.clear ();
+ plist.add (Properties::start, 0);
+ plist.add (Properties::length, extent.second);
+ plist.add (Properties::name, child_name);
plist.add (Properties::layer, layer+1);
-
- boost::shared_ptr<Region> compound_region = RegionFactory::create (sources, plist, true);
+
+ boost::shared_ptr<Region> compound_region = RegionFactory::create (parent_region, plist, true);
/* add any dependent regions to the new playlist */
@@ -3256,8 +3280,8 @@ Playlist::uncombine (boost::shared_ptr<Region> target)
pl = pls->playlist();
- framepos_t adjusted_start;
- framepos_t adjusted_end;
+ framepos_t adjusted_start = 0; // gcc isn't smart enough
+ framepos_t adjusted_end = 0; // gcc isn't smart enough
/* the leftmost (earliest) edge of the compound region
starts at zero in its source, or larger if it
diff --git a/libs/ardour/region_factory.cc b/libs/ardour/region_factory.cc
index 9dbd0ded37..f4fd209fea 100644
--- a/libs/ardour/region_factory.cc
+++ b/libs/ardour/region_factory.cc
@@ -488,9 +488,13 @@ RegionFactory::region_name (string& result, string base, bool newlevel)
}
string
-RegionFactory::compound_region_name (const string& playlist, uint32_t compound_ops, uint32_t depth)
+RegionFactory::compound_region_name (const string& playlist, uint32_t compound_ops, uint32_t depth, bool whole_source)
{
- return string_compose (_("%1 compound-%2.1 (%3)"), playlist, compound_ops+1, depth+1);
+ if (whole_source) {
+ return string_compose (_("%1 compound-%2 (%3)"), playlist, compound_ops+1, depth+1);
+ } else {
+ return string_compose (_("%1 compound-%2.1 (%3)"), playlist, compound_ops+1, depth+1);
+ }
}
string