From 16c280e40582209e151f54ea7b9d0e9b67048b68 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 26 May 2011 13:56:19 +0000 Subject: turn off relevant fade in/out before creating peakfiles for compound region sources git-svn-id: svn://localhost/ardour2/branches/3.0@9596 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/audioplaylist.h | 3 ++- libs/ardour/ardour/playlist.h | 8 +++++++- libs/ardour/audio_playlist.cc | 29 +++++++++++++++++++++++------ libs/ardour/playlist.cc | 9 +++++++-- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/libs/ardour/ardour/audioplaylist.h b/libs/ardour/ardour/audioplaylist.h index a8426b5f51..a0da358777 100644 --- a/libs/ardour/ardour/audioplaylist.h +++ b/libs/ardour/ardour/audioplaylist.h @@ -106,7 +106,8 @@ public: void remove_dependents (boost::shared_ptr region); void copy_dependents (const std::vector&, boost::shared_ptr); - void pre_combine (std::vector >&, boost::shared_ptr); + void pre_combine (std::vector >&); + void post_combine (std::vector >&, boost::shared_ptr); void pre_uncombine (std::vector >&, boost::shared_ptr); private: diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h index 69f4963359..7635d004bc 100644 --- a/libs/ardour/ardour/playlist.h +++ b/libs/ardour/ardour/playlist.h @@ -390,7 +390,13 @@ public: framepos_t start; }; - virtual void pre_combine (std::vector >&, boost::shared_ptr) {} + /* this is called before we create a new compound region */ + virtual void pre_combine (std::vector >&) {} + /* this is called before we create a new compound region */ + virtual void post_combine (std::vector >&, boost::shared_ptr) {} + /* this is called before we remove a compound region and replace it + with its constituent regions + */ virtual void pre_uncombine (std::vector >&, boost::shared_ptr) {} }; diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc index 06eca9fb92..59c791b8fb 100644 --- a/libs/ardour/audio_playlist.cc +++ b/libs/ardour/audio_playlist.cc @@ -1083,10 +1083,31 @@ AudioPlaylist::copy_dependents (const vector& old_and_new, boost::sh } void -AudioPlaylist::pre_combine (vector >& originals, boost::shared_ptr compound_region) +AudioPlaylist::pre_combine (vector >& copies) { - /* sort the originals into time order */ + RegionSortByPosition cmp; + boost::shared_ptr ar; + + sort (copies.begin(), copies.end(), cmp); + + ar = boost::dynamic_pointer_cast (copies.front()); + + /* copy the fade in of the first into the compound region */ + + if (ar) { + ar->set_fade_in_active (false); + } + ar = boost::dynamic_pointer_cast (copies.back()); + + if (ar) { + ar->set_fade_out_active (false); + } +} + +void +AudioPlaylist::post_combine (vector >& originals, boost::shared_ptr compound_region) +{ RegionSortByPosition cmp; boost::shared_ptr ar; boost::shared_ptr cr; @@ -1103,9 +1124,6 @@ AudioPlaylist::pre_combine (vector >& originals, boost if (ar) { cr->set_fade_in (ar->fade_in()); - - /* disable the fade in of the first */ - ar->set_fade_in_active (false); } @@ -1114,7 +1132,6 @@ AudioPlaylist::pre_combine (vector >& originals, boost if (ar) { /* copy the fade out of the last into the compound region */ cr->set_fade_out (ar->fade_out()); - /* disable the fade out of the first */ ar->set_fade_out_active (false); } } diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 814278f0e5..3f7eb1852d 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -3071,6 +3071,7 @@ Playlist::combine (const RegionList& r) framepos_t earliest_position = max_framepos; vector old_and_new_regions; vector > originals; + vector > copies; string parent_name; string child_name; uint32_t max_level = 0; @@ -3105,6 +3106,7 @@ Playlist::combine (const RegionList& r) old_and_new_regions.push_back (TwoRegions (original_region,copied_region)); originals.push_back (original_region); + copies.push_back (copied_region); RegionFactory::add_compound_association (original_region, copied_region); @@ -3123,6 +3125,8 @@ Playlist::combine (const RegionList& r) pl->in_partition = false; + pre_combine (copies); + /* now create a new PlaylistSource for each channel in the new playlist */ SourceList sources; @@ -3131,6 +3135,7 @@ Playlist::combine (const RegionList& r) for (uint32_t chn = 0; chn < channels; ++chn) { sources.push_back (SourceFactory::createFromPlaylist (_type, _session, pl, parent_name, chn, 0, extent.second, false, false)); } + /* now a new whole-file region using the list of sources */ @@ -3169,8 +3174,8 @@ Playlist::combine (const RegionList& r) /* do type-specific stuff with the originals and the new compound region */ - - pre_combine (originals, compound_region); + + post_combine (originals, compound_region); /* add the new region at the right location */ -- cgit v1.2.3