13
0

Crossfade copy-constructor + copy crossfades when creating a copy of a

playlist.


git-svn-id: svn://localhost/trunk/ardour2@393 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Sampo Savolainen 2006-03-14 21:35:00 +00:00
parent 8d3fdc3c5b
commit ec461de3a8
4 changed files with 72 additions and 0 deletions

View File

@ -73,6 +73,11 @@ class Crossfade : public Stateful, public StateManager
Crossfade (ARDOUR::AudioRegion& in, ARDOUR::AudioRegion& out, CrossfadeModel, bool active);
/* copy constructor to copy a crossfade with new regions. used (for example)
when a playlist copy is made */
Crossfade (const Crossfade &, ARDOUR::AudioRegion *, ARDOUR::AudioRegion *);
/* the usual XML constructor */
Crossfade (const ARDOUR::Playlist&, XMLNode&);

View File

@ -72,6 +72,47 @@ AudioPlaylist::AudioPlaylist (const AudioPlaylist& other, string name, bool hidd
{
save_state (_("initial state"));
list<Region*>::const_iterator in_o = other.regions.begin();
list<Region*>::iterator in_n = regions.begin();
while (in_o != other.regions.end()) {
AudioRegion *ar = dynamic_cast<AudioRegion *>( (*in_o) );
// We look only for crossfades which begin with the current region, so we don't get doubles
for (list<Crossfade *>::const_iterator xfades = other._crossfades.begin(); xfades != other._crossfades.end(); ++xfades) {
if ( &(*xfades)->in() == ar) {
// We found one! Now copy it!
list<Region*>::const_iterator out_o = other.regions.begin();
list<Region*>::const_iterator out_n = regions.begin();
while (out_o != other.regions.end()) {
AudioRegion *ar2 = dynamic_cast<AudioRegion *>( (*out_o) );
if ( &(*xfades)->out() == ar2) {
AudioRegion *in = dynamic_cast<AudioRegion*>( (*in_n) );
AudioRegion *out = dynamic_cast<AudioRegion*>( (*out_n) );
Crossfade *new_fade = new Crossfade( *(*xfades), in, out);
add_crossfade(*new_fade);
cerr << "Here we go!" << endl;
break;
}
out_o++;
out_n++;
}
// cerr << "HUH!? second region in the crossfade not found!" << endl;
}
}
in_o++;
in_n++;
}
if (!hidden) {
PlaylistCreated (this); /* EMIT SIGNAL */
}

View File

@ -161,6 +161,28 @@ Crossfade::Crossfade (const Playlist& playlist, XMLNode& node)
save_state ("initial");
}
Crossfade::Crossfade (const Crossfade &orig, ARDOUR::AudioRegion *newin, ARDOUR::AudioRegion *newout)
: _fade_in(orig._fade_in),
_fade_out(orig._fade_out)
{
// Signals?
_active = orig._active;
_in_update = orig._in_update;
overlap_type = orig.overlap_type;
_length = orig._length;
_position = orig._position;
_anchor_point = orig._anchor_point;
_follow_overlap = orig._follow_overlap;
_fixed = orig._fixed;
_follow_overlap = orig._follow_overlap;
_short_xfade_length = orig._short_xfade_length;
_in = newin;
_out = newout;
}
Crossfade::~Crossfade ()
{
for (StateMap::iterator i = states.begin(); i != states.end(); ++i) {

View File

@ -98,6 +98,10 @@ Playlist::Playlist (const Playlist& other, string namestr, bool hide)
{
init (hide);
_edit_mode = other._edit_mode;
_splicing = other._splicing;
_nudging = other._nudging;
other.copy_regions (regions);
for (list<Region*>::iterator x = regions.begin(); x != regions.end(); ++x) {