mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-07 06:05:43 +01:00
logic to copy audio region fade in/fade out into compound regions (one-way for now)
git-svn-id: svn://localhost/ardour2/branches/3.0@9588 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
04b54f8dd1
commit
9925ab554e
5 changed files with 122 additions and 33 deletions
|
|
@ -106,6 +106,9 @@ public:
|
|||
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_uncombine (std::vector<boost::shared_ptr<Region> >&, boost::shared_ptr<Region>);
|
||||
|
||||
private:
|
||||
CrossfadeListProperty _crossfades;
|
||||
Crossfades _pending_xfade_adds;
|
||||
|
|
|
|||
|
|
@ -390,6 +390,9 @@ public:
|
|||
framecnt_t length;
|
||||
framepos_t start;
|
||||
};
|
||||
|
||||
virtual void pre_combine (std::vector<boost::shared_ptr<Region> >&, boost::shared_ptr<Region>) {}
|
||||
virtual void pre_uncombine (std::vector<boost::shared_ptr<Region> >&, boost::shared_ptr<Region>) {}
|
||||
};
|
||||
|
||||
} /* namespace ARDOUR */
|
||||
|
|
|
|||
64
libs/ardour/ardour/region_sorters.h
Normal file
64
libs/ardour/ardour/region_sorters.h
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
Copyright (C) 2000-2011 Paul Davis
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __libardour_region_sorters_h__
|
||||
#define __libardour_region_sorters_h__
|
||||
|
||||
#include "ardour/region.h"
|
||||
|
||||
namespace ARDOUR {
|
||||
|
||||
struct RegionSortByPosition {
|
||||
bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
|
||||
return a->position() < b->position();
|
||||
}
|
||||
};
|
||||
|
||||
struct RegionSortByLastLayerOp {
|
||||
bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
|
||||
return a->last_layer_op() < b->last_layer_op();
|
||||
}
|
||||
};
|
||||
|
||||
struct RegionSortByLayer {
|
||||
bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
|
||||
return a->layer() < b->layer();
|
||||
}
|
||||
};
|
||||
|
||||
struct RegionSortByLayerWithPending {
|
||||
bool operator () (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
|
||||
|
||||
double p = a->layer ();
|
||||
if (a->pending_explicit_relayer()) {
|
||||
p += 0.5;
|
||||
}
|
||||
|
||||
double q = b->layer ();
|
||||
if (b->pending_explicit_relayer()) {
|
||||
q += 0.5;
|
||||
}
|
||||
|
||||
return p < q;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif /* __libardour_region_sorters_h__ */
|
||||
|
|
@ -27,6 +27,7 @@
|
|||
#include "ardour/audioplaylist.h"
|
||||
#include "ardour/audioregion.h"
|
||||
#include "ardour/crossfade.h"
|
||||
#include "ardour/region_sorters.h"
|
||||
#include "ardour/session.h"
|
||||
#include "pbd/enumwriter.h"
|
||||
|
||||
|
|
@ -1080,3 +1081,45 @@ AudioPlaylist::copy_dependents (const vector<TwoRegions>& old_and_new, boost::sh
|
|||
other_audio->add_crossfade (new_xfade);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AudioPlaylist::pre_combine (vector<boost::shared_ptr<Region> >& originals, boost::shared_ptr<Region> compound_region)
|
||||
{
|
||||
/* sort the originals into time order */
|
||||
|
||||
RegionSortByPosition cmp;
|
||||
boost::shared_ptr<AudioRegion> ar;
|
||||
boost::shared_ptr<AudioRegion> cr;
|
||||
|
||||
if ((cr = boost::dynamic_pointer_cast<AudioRegion> (compound_region)) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
sort (originals.begin(), originals.end(), cmp);
|
||||
|
||||
ar = boost::dynamic_pointer_cast<AudioRegion> (originals.front());
|
||||
|
||||
/* copy the fade in of the first into the compound region */
|
||||
|
||||
if (ar) {
|
||||
cr->set_fade_in (ar->fade_in());
|
||||
|
||||
/* disable the fade in of the first */
|
||||
|
||||
ar->set_fade_in_active (false);
|
||||
}
|
||||
|
||||
ar = boost::dynamic_pointer_cast<AudioRegion> (originals.front());
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AudioPlaylist::pre_uncombine (vector<boost::shared_ptr<Region> >& originals, boost::shared_ptr<Region> compound_region)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#include "ardour/session.h"
|
||||
#include "ardour/region.h"
|
||||
#include "ardour/region_factory.h"
|
||||
#include "ardour/region_sorters.h"
|
||||
#include "ardour/playlist_factory.h"
|
||||
#include "ardour/playlist_source.h"
|
||||
#include "ardour/transient_detector.h"
|
||||
|
|
@ -65,40 +66,7 @@ struct ShowMeTheList {
|
|||
string name;
|
||||
};
|
||||
|
||||
struct RegionSortByLayer {
|
||||
bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
|
||||
return a->layer() < b->layer();
|
||||
}
|
||||
};
|
||||
|
||||
struct RegionSortByLayerWithPending {
|
||||
bool operator () (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
|
||||
|
||||
double p = a->layer ();
|
||||
if (a->pending_explicit_relayer()) {
|
||||
p += 0.5;
|
||||
}
|
||||
|
||||
double q = b->layer ();
|
||||
if (b->pending_explicit_relayer()) {
|
||||
q += 0.5;
|
||||
}
|
||||
|
||||
return p < q;
|
||||
}
|
||||
};
|
||||
|
||||
struct RegionSortByPosition {
|
||||
bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
|
||||
return a->position() < b->position();
|
||||
}
|
||||
};
|
||||
|
||||
struct RegionSortByLastLayerOp {
|
||||
bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) {
|
||||
return a->last_layer_op() < b->last_layer_op();
|
||||
}
|
||||
};
|
||||
|
||||
void
|
||||
Playlist::make_property_quarks ()
|
||||
|
|
@ -3160,6 +3128,7 @@ Playlist::combine (const RegionList& r)
|
|||
uint32_t layer = 0;
|
||||
framepos_t earliest_position = max_framepos;
|
||||
vector<TwoRegions> old_and_new_regions;
|
||||
vector<boost::shared_ptr<Region> > originals;
|
||||
string parent_name;
|
||||
string child_name;
|
||||
uint32_t max_level = 0;
|
||||
|
|
@ -3193,6 +3162,7 @@ Playlist::combine (const RegionList& r)
|
|||
boost::shared_ptr<Region> copied_region = RegionFactory::create (original_region, false);
|
||||
|
||||
old_and_new_regions.push_back (TwoRegions (original_region,copied_region));
|
||||
originals.push_back (original_region);
|
||||
|
||||
RegionFactory::add_compound_association (original_region, copied_region);
|
||||
|
||||
|
|
@ -3254,6 +3224,12 @@ Playlist::combine (const RegionList& r)
|
|||
remove_region (*i);
|
||||
}
|
||||
|
||||
/* do type-specific stuff with the originals and the new compound
|
||||
region
|
||||
*/
|
||||
|
||||
pre_combine (originals, compound_region);
|
||||
|
||||
/* add the new region at the right location */
|
||||
|
||||
add_region (compound_region, earliest_position);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue