summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/route_time_axis.cc13
-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
5 files changed, 45 insertions, 22 deletions
diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc
index bbdc369ede..f1e00978e9 100644
--- a/gtk2_ardour/route_time_axis.cc
+++ b/gtk2_ardour/route_time_axis.cc
@@ -2480,10 +2480,9 @@ RouteTimeAxisView::create_gain_automation_child (const Evoral::Parameter& param,
}
static
-void add_region_to_list (RegionView* rv, Playlist::RegionList* l, uint32_t* max_level)
+void add_region_to_list (RegionView* rv, Playlist::RegionList* l)
{
l->push_back (rv->region());
- *max_level = max (*max_level, rv->region()->max_source_level());
}
RegionView*
@@ -2497,14 +2496,11 @@ RouteTimeAxisView::combine_regions ()
Playlist::RegionList selected_regions;
boost::shared_ptr<Playlist> playlist = track()->playlist();
- uint32_t max_level = 0;
- _view->foreach_selected_regionview (sigc::bind (sigc::ptr_fun (add_region_to_list), &selected_regions, &max_level));
+ _view->foreach_selected_regionview (sigc::bind (sigc::ptr_fun (add_region_to_list), &selected_regions));
- string name = RegionFactory::compound_region_name (playlist->name(), playlist->combine_ops(), max_level);
-
playlist->clear_changes ();
- boost::shared_ptr<Region> compound_region = playlist->combine (selected_regions, name);
+ boost::shared_ptr<Region> compound_region = playlist->combine (selected_regions);
_session->add_command (new StatefulDiffCommand (playlist));
/* make the new region be selected */
@@ -2523,13 +2519,12 @@ RouteTimeAxisView::uncombine_regions ()
Playlist::RegionList selected_regions;
boost::shared_ptr<Playlist> playlist = track()->playlist();
- uint32_t max_level = 0;
/* have to grab selected regions first because the uncombine is going
* to change that in the middle of the list traverse
*/
- _view->foreach_selected_regionview (sigc::bind (sigc::ptr_fun (add_region_to_list), &selected_regions, &max_level));
+ _view->foreach_selected_regionview (sigc::bind (sigc::ptr_fun (add_region_to_list), &selected_regions));
playlist->clear_changes ();
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