summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorSampo Savolainen <v2@iki.fi>2006-03-31 21:34:22 +0000
committerSampo Savolainen <v2@iki.fi>2006-03-31 21:34:22 +0000
commit7755c2dbfefd40697ce390e2c2f254e2122a2a39 (patch)
tree60fea9f94cc2200ce07da4db962ba5c7ea5510d1 /libs
parent6f1208036fe7eb9278b2708843c6bce817bbdf8d (diff)
Splitting a regon now retains crossfades, even if the split happens
within a crossfade. git-svn-id: svn://localhost/trunk/ardour2@435 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/audio_playlist.cc27
-rw-r--r--libs/ardour/crossfade.cc14
-rw-r--r--libs/ardour/playlist.cc11
3 files changed, 38 insertions, 14 deletions
diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc
index 6f4217c3ec..53aa173ffd 100644
--- a/libs/ardour/audio_playlist.cc
+++ b/libs/ardour/audio_playlist.cc
@@ -351,17 +351,36 @@ AudioPlaylist::finalize_split_region (Region *o, Region *l, Region *r)
AudioRegion *left = dynamic_cast<AudioRegion*>(l);
AudioRegion *right = dynamic_cast<AudioRegion*>(r);
- for (Crossfades::iterator x = _crossfades.begin(); x != _crossfades.end(); ++x) {
+ for (Crossfades::iterator x = _crossfades.begin(); x != _crossfades.end();) {
Crossfades::iterator tmp;
+ tmp = x;
+ ++tmp;
+ Crossfade *fade = 0;
+
if ((*x)->_in == orig) {
- (*x)->_in = left;
+ if (! (*x)->covers(right->position())) {
+ fade = new Crossfade( *(*x), left, (*x)->_out);
+ } else {
+ // Overlap, the crossfade is copied on the left side of the right region instead
+ fade = new Crossfade( *(*x), right, (*x)->_out);
+ }
}
-
+
if ((*x)->_out == orig) {
- (*x)->_out = right;
+ if (! (*x)->covers(right->position())) {
+ fade = new Crossfade( *(*x), (*x)->_in, right);
+ } else {
+ // Overlap, the crossfade is copied on the right side of the left region instead
+ fade = new Crossfade( *(*x), (*x)->_in, left);
+ }
}
+ if (fade) {
+ _crossfades.remove( (*x) );
+ add_crossfade (*fade);
+ }
+ x = tmp;
}
}
diff --git a/libs/ardour/crossfade.cc b/libs/ardour/crossfade.cc
index 53e59dafcb..767fdd85e6 100644
--- a/libs/ardour/crossfade.cc
+++ b/libs/ardour/crossfade.cc
@@ -165,11 +165,8 @@ Crossfade::Crossfade (const Crossfade &orig, ARDOUR::AudioRegion *newin, ARDOUR:
: _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;
@@ -180,9 +177,20 @@ Crossfade::Crossfade (const Crossfade &orig, ARDOUR::AudioRegion *newin, ARDOUR:
_in = newin;
_out = newout;
+
+ // copied from Crossfade::initialize()
+ _in_update = false;
+ _out->suspend_fade_out ();
+ _in->suspend_fade_in ();
+
+ overlap_type = _in->coverage (_out->position(), _out->last_frame());
+
+ // Let's make sure the fade isn't too long
+ set_length(_length);
}
+
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 a0b6cedde4..1c34099c7e 100644
--- a/libs/ardour/playlist.cc
+++ b/libs/ardour/playlist.cc
@@ -982,10 +982,6 @@ Playlist::split_region (Region& region, jack_nframes_t playlist_position)
return;
}
- if (remove_region_internal (&region, true)) {
- return;
- }
-
Region *left;
Region *right;
jack_nframes_t before;
@@ -996,7 +992,6 @@ Playlist::split_region (Region& region, jack_nframes_t playlist_position)
before = playlist_position - region.position();
after = region.length() - before;
- in_set_state = true;
_session.region_name (before_name, region.name(), false);
left = createRegion (region, 0, before, before_name, region.layer(), Region::Flag (region.flags()|Region::LeftOfSplit));
@@ -1009,8 +1004,10 @@ Playlist::split_region (Region& region, jack_nframes_t playlist_position)
finalize_split_region (&region, left, right);
- in_set_state = false;
-
+ if (remove_region_internal (&region, true)) {
+ return;
+ }
+
maybe_save_state (_("split"));
}