summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorBen Loftis <ben@glw.com>2011-05-09 18:33:33 +0000
committerBen Loftis <ben@glw.com>2011-05-09 18:33:33 +0000
commit4ffb67a4df9761a2067de74f894299a631795057 (patch)
tree4492fe2452b80cff0ce31dc63ee97a90895e0573 /libs
parent86e1bcb6b3a0736df6860805280a3676fbae7930 (diff)
fix old issue where copy-pasting a range selection from region(s), each region would inherit the parents full fade-in or -out even when the region excerpt didnt include the fade
git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@9487 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/ardour/audio_playlist.cc88
1 files changed, 88 insertions, 0 deletions
diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc
index 9c331af610..f5f275ba2a 100644
--- a/libs/ardour/audio_playlist.cc
+++ b/libs/ardour/audio_playlist.cc
@@ -26,6 +26,7 @@
#include <ardour/types.h>
#include <ardour/configuration.h>
#include <ardour/audioplaylist.h>
+#include <ardour/region_factory.h>
#include <ardour/audioregion.h>
#include <ardour/crossfade.h>
#include <ardour/crossfade_compare.h>
@@ -96,6 +97,93 @@ AudioPlaylist::AudioPlaylist (boost::shared_ptr<const AudioPlaylist> other, stri
AudioPlaylist::AudioPlaylist (boost::shared_ptr<const AudioPlaylist> other, nframes_t start, nframes_t cnt, string name, bool hidden)
: Playlist (other, start, cnt, name, hidden)
{
+ clear(); //we need to remove any regions that the parent constructor added
+
+ RegionLock rlock2 (const_cast<AudioPlaylist*> (other.get()));
+
+ nframes_t end = start + cnt - 1;
+
+ Playlist::init (hidden);
+
+ in_set_state++;
+
+ //now re-add the regions with the correct fade in/out
+ for (RegionList::const_iterator i = other->regions.begin(); i != other->regions.end(); i++) {
+
+ boost::shared_ptr<AudioRegion> region = boost::dynamic_pointer_cast<AudioRegion> (*i);
+ boost::shared_ptr<AudioRegion> new_region;
+ nframes64_t offset = 0;
+ nframes64_t trim = 0;
+ nframes64_t position = 0;
+ nframes64_t len = 0;
+ string new_name;
+ OverlapType overlap;
+
+ nframes_t fade_in_len = 64;
+ nframes_t fade_out_len = 64;
+
+ overlap = region->coverage (start, end+1);
+
+ switch (overlap) {
+ case OverlapNone:
+ continue;
+
+ case OverlapInternal:
+ offset = start - region->position();
+ trim = region->last_frame() -end;
+ position = 0;
+ len = cnt;
+ if (region->fade_in().back()->when > offset)
+ fade_in_len = region->fade_in().back()->when - offset;
+ if (region->fade_out().back()->when > trim)
+ fade_out_len = region->fade_out().back()->when - trim;
+ break;
+
+ case OverlapStart:
+ offset = 0;
+ position = region->position() - start;
+ len = end - region->position();
+ if (region->fade_in().back()->when > offset)
+ fade_in_len = region->fade_in().back()->when - offset;
+ if (start > region->last_frame() - region->fade_out().back()->when)
+ fade_out_len = region->last_frame() - start;
+ break;
+
+ case OverlapEnd:
+ offset = start - region->position();
+ trim = region->last_frame() -end;
+ position = 0;
+ len = region->length() - offset;
+ if (region->fade_in().back()->when > offset)
+ fade_in_len = region->fade_in().back()->when - offset;
+ if (start > region->last_frame() - region->fade_out().back()->when)
+ fade_out_len = region->last_frame() - start;
+ else
+ fade_out_len = region->fade_out().back()->when;
+ break;
+
+ case OverlapExternal:
+ offset = 0;
+ trim = region->last_frame() -end;
+ position = region->position() - start;
+ len = region->length();
+ fade_in_len = region->fade_in().back()->when;
+ fade_out_len = region->fade_out().back()->when;
+ break;
+ }
+
+ _session.region_name (new_name, region->name(), false);
+
+ new_region = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::RegionFactory::create (region, offset, len, new_name, region->layer(), region->flags()));
+ new_region->set_fade_in_length(fade_in_len > 64 ? fade_in_len : 64);
+ new_region->set_fade_out_length(fade_out_len > 64 ? fade_out_len : 64);
+
+ add_region_internal (new_region, position);
+ }
+
+ in_set_state--;
+ first_set_state = false;
+
/* this constructor does NOT notify others (session) */
}