diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index d7ed790c7f..52e470f1f5 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -1950,17 +1950,22 @@ Editor::create_region_from_selection (vector >& n void Editor::split_multichannel_region () { - vector v; - - AudioRegionView* clicked_arv = dynamic_cast(clicked_regionview); - - if (!clicked_arv || clicked_arv->audio_region()->n_channels() < 2) { + if (selection->regions.empty()) { return; } - clicked_arv->audio_region()->separate_by_channel (*session, v); + vector > v; - /* nothing else to do, really */ + for (list::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) { + + AudioRegionView* arv = dynamic_cast(*x); + + if (!arv || arv->audio_region()->n_channels() < 2) { + continue; + } + + (arv)->audio_region()->separate_by_channel (*session, v); + } } void diff --git a/gtk2_ardour/editor_region_list.cc b/gtk2_ardour/editor_region_list.cc index d2bcf5931d..d8c521da20 100644 --- a/gtk2_ardour/editor_region_list.cc +++ b/gtk2_ardour/editor_region_list.cc @@ -50,7 +50,6 @@ using namespace Editing; void Editor::handle_audio_region_removed (boost::weak_ptr wregion) { - cerr << "removed region\n"; ENSURE_GUI_THREAD (mem_fun (*this, &Editor::redisplay_regions)); redisplay_regions (); } diff --git a/libs/ardour/ardour/audioregion.h b/libs/ardour/ardour/audioregion.h index 7a88655afe..ef5f5dc6e7 100644 --- a/libs/ardour/ardour/audioregion.h +++ b/libs/ardour/ardour/audioregion.h @@ -118,7 +118,7 @@ class AudioRegion : public Region void set_envelope_active (bool yn); void set_default_envelope (); - int separate_by_channel (ARDOUR::Session&, vector&) const; + int separate_by_channel (ARDOUR::Session&, vector >&) const; /* filter */ diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 1fc7703cfa..9f76b0f19e 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -42,6 +42,7 @@ #include #include #include +#include #include "i18n.h" #include @@ -1020,25 +1021,44 @@ AudioRegion::recompute_at_start () } int -AudioRegion::separate_by_channel (Session& session, vector& v) const +AudioRegion::separate_by_channel (Session& session, vector >& v) const { SourceList srcs; string new_name; + int n; - for (SourceList::const_iterator i = master_sources.begin(); i != master_sources.end(); ++i) { + if (sources.size() < 2) { + return 0; + } + + n = 0; + + for (SourceList::const_iterator i = sources.begin(); i != sources.end(); ++i) { srcs.clear (); srcs.push_back (*i); - /* generate a new name */ - - if (session.region_name (new_name, _name)) { - return -1; + new_name = _name; + + if (sources.size() == 2) { + if (n == 0) { + new_name += "-L"; + } else { + new_name += "-R"; + } + } else { + new_name += '-'; + new_name += ('0' + n + 1); } /* create a copy with just one source */ - v.push_back (new AudioRegion (srcs, _start, _length, new_name, _layer, _flags)); + boost::shared_ptr r = RegionFactory::create (srcs, _start, _length, new_name, _layer, _flags); + boost::shared_ptr ar = boost::dynamic_pointer_cast (r); + + v.push_back (ar); + + ++n; } return 0;