diff --git a/libs/ardour/ardour/crossfade.h b/libs/ardour/ardour/crossfade.h index 3e65e16901..b2d5b18566 100644 --- a/libs/ardour/ardour/crossfade.h +++ b/libs/ardour/ardour/crossfade.h @@ -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&); diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc index f6c6440ab0..72316e30e3 100644 --- a/libs/ardour/audio_playlist.cc +++ b/libs/ardour/audio_playlist.cc @@ -72,6 +72,47 @@ AudioPlaylist::AudioPlaylist (const AudioPlaylist& other, string name, bool hidd { save_state (_("initial state")); + list::const_iterator in_o = other.regions.begin(); + list::iterator in_n = regions.begin(); + + while (in_o != other.regions.end()) { + AudioRegion *ar = dynamic_cast( (*in_o) ); + + // We look only for crossfades which begin with the current region, so we don't get doubles + for (list::const_iterator xfades = other._crossfades.begin(); xfades != other._crossfades.end(); ++xfades) { + if ( &(*xfades)->in() == ar) { + // We found one! Now copy it! + + list::const_iterator out_o = other.regions.begin(); + list::const_iterator out_n = regions.begin(); + + while (out_o != other.regions.end()) { + + AudioRegion *ar2 = dynamic_cast( (*out_o) ); + + if ( &(*xfades)->out() == ar2) { + AudioRegion *in = dynamic_cast( (*in_n) ); + AudioRegion *out = dynamic_cast( (*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 */ } diff --git a/libs/ardour/crossfade.cc b/libs/ardour/crossfade.cc index c23689a3a3..53e59dafcb 100644 --- a/libs/ardour/crossfade.cc +++ b/libs/ardour/crossfade.cc @@ -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) { diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 7772fcbf82..dfe5731b85 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -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::iterator x = regions.begin(); x != regions.end(); ++x) {