summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorSampo Savolainen <v2@iki.fi>2006-03-14 21:35:00 +0000
committerSampo Savolainen <v2@iki.fi>2006-03-14 21:35:00 +0000
commitec461de3a8fce8de51da56aa4f5f69224abc3dce (patch)
treebb9baa62c95c9bf987d1dd02e701dcb8f929f946 /libs
parent8d3fdc3c5b87f6d1444830d82f28d18a2201afea (diff)
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
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/ardour/crossfade.h5
-rw-r--r--libs/ardour/audio_playlist.cc41
-rw-r--r--libs/ardour/crossfade.cc22
-rw-r--r--libs/ardour/playlist.cc4
4 files changed, 72 insertions, 0 deletions
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<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 */
}
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<Region*>::iterator x = regions.begin(); x != regions.end(); ++x) {