From 7755c2dbfefd40697ce390e2c2f254e2122a2a39 Mon Sep 17 00:00:00 2001 From: Sampo Savolainen Date: Fri, 31 Mar 2006 21:34:22 +0000 Subject: 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 --- libs/ardour/audio_playlist.cc | 27 +++++++++++++++++++++++---- libs/ardour/crossfade.cc | 14 +++++++++++--- libs/ardour/playlist.cc | 11 ++++------- 3 files changed, 38 insertions(+), 14 deletions(-) (limited to 'libs') 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(l); AudioRegion *right = dynamic_cast(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 (®ion, 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 (®ion, left, right); - in_set_state = false; - + if (remove_region_internal (®ion, true)) { + return; + } + maybe_save_state (_("split")); } -- cgit v1.2.3