13
0

fix "make mono regions", mostly

git-svn-id: svn://localhost/ardour2/trunk@1392 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2007-01-26 03:54:12 +00:00
parent 5ee3e58718
commit fccc2229ea
4 changed files with 40 additions and 16 deletions

View File

@ -1950,17 +1950,22 @@ Editor::create_region_from_selection (vector<boost::shared_ptr<AudioRegion> >& n
void
Editor::split_multichannel_region ()
{
vector<AudioRegion*> v;
AudioRegionView* clicked_arv = dynamic_cast<AudioRegionView*>(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<boost::shared_ptr<AudioRegion> > v;
/* nothing else to do, really */
for (list<RegionView*>::iterator x = selection->regions.begin(); x != selection->regions.end(); ++x) {
AudioRegionView* arv = dynamic_cast<AudioRegionView*>(*x);
if (!arv || arv->audio_region()->n_channels() < 2) {
continue;
}
(arv)->audio_region()->separate_by_channel (*session, v);
}
}
void

View File

@ -50,7 +50,6 @@ using namespace Editing;
void
Editor::handle_audio_region_removed (boost::weak_ptr<AudioRegion> wregion)
{
cerr << "removed region\n";
ENSURE_GUI_THREAD (mem_fun (*this, &Editor::redisplay_regions));
redisplay_regions ();
}

View File

@ -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<AudioRegion*>&) const;
int separate_by_channel (ARDOUR::Session&, vector<boost::shared_ptr<AudioRegion> >&) const;
/* filter */

View File

@ -42,6 +42,7 @@
#include <ardour/audiofilter.h>
#include <ardour/audiofilesource.h>
#include <ardour/destructive_filesource.h>
#include <ardour/region_factory.h>
#include "i18n.h"
#include <locale.h>
@ -1020,25 +1021,44 @@ AudioRegion::recompute_at_start ()
}
int
AudioRegion::separate_by_channel (Session& session, vector<AudioRegion*>& v) const
AudioRegion::separate_by_channel (Session& session, vector<boost::shared_ptr<AudioRegion> >& 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<Region> r = RegionFactory::create (srcs, _start, _length, new_name, _layer, _flags);
boost::shared_ptr<AudioRegion> ar = boost::dynamic_pointer_cast<AudioRegion> (r);
v.push_back (ar);
++n;
}
return 0;