diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/audioplaylist.h | 3 | ||||
-rw-r--r-- | libs/ardour/ardour/playlist.h | 3 | ||||
-rw-r--r-- | libs/ardour/ardour/region_sorters.h | 64 | ||||
-rw-r--r-- | libs/ardour/audio_playlist.cc | 43 | ||||
-rw-r--r-- | libs/ardour/playlist.cc | 42 |
5 files changed, 122 insertions, 33 deletions
diff --git a/libs/ardour/ardour/audioplaylist.h b/libs/ardour/ardour/audioplaylist.h index b9ed739a79..a8426b5f51 100644 --- a/libs/ardour/ardour/audioplaylist.h +++ b/libs/ardour/ardour/audioplaylist.h @@ -106,6 +106,9 @@ public: void remove_dependents (boost::shared_ptr<Region> region); void copy_dependents (const std::vector<TwoRegions>&, boost::shared_ptr<Playlist>); + void pre_combine (std::vector<boost::shared_ptr<Region> >&, boost::shared_ptr<Region>); + void pre_uncombine (std::vector<boost::shared_ptr<Region> >&, boost::shared_ptr<Region>); + private: CrossfadeListProperty _crossfades; Crossfades _pending_xfade_adds; diff --git a/libs/ardour/ardour/playlist.h b/libs/ardour/ardour/playlist.h index 5406886faa..dfb16d79bc 100644 --- a/libs/ardour/ardour/playlist.h +++ b/libs/ardour/ardour/playlist.h @@ -390,6 +390,9 @@ public: framecnt_t length; framepos_t start; }; + + virtual void pre_combine (std::vector<boost::shared_ptr<Region> >&, boost::shared_ptr<Region>) {} + virtual void pre_uncombine (std::vector<boost::shared_ptr<Region> >&, boost::shared_ptr<Region>) {} }; } /* namespace ARDOUR */ diff --git a/libs/ardour/ardour/region_sorters.h b/libs/ardour/ardour/region_sorters.h new file mode 100644 index 0000000000..ca09f194b1 --- /dev/null +++ b/libs/ardour/ardour/region_sorters.h @@ -0,0 +1,64 @@ +/* + Copyright (C) 2000-2011 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __libardour_region_sorters_h__ +#define __libardour_region_sorters_h__ + +#include "ardour/region.h" + +namespace ARDOUR { + +struct RegionSortByPosition { + bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) { + return a->position() < b->position(); + } +}; + +struct RegionSortByLastLayerOp { + bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) { + return a->last_layer_op() < b->last_layer_op(); + } +}; + +struct RegionSortByLayer { + bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) { + return a->layer() < b->layer(); + } +}; + +struct RegionSortByLayerWithPending { + bool operator () (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) { + + double p = a->layer (); + if (a->pending_explicit_relayer()) { + p += 0.5; + } + + double q = b->layer (); + if (b->pending_explicit_relayer()) { + q += 0.5; + } + + return p < q; + } +}; + +} // namespace + +#endif /* __libardour_region_sorters_h__ */ diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc index ebff10f49e..f73bbf17e5 100644 --- a/libs/ardour/audio_playlist.cc +++ b/libs/ardour/audio_playlist.cc @@ -27,6 +27,7 @@ #include "ardour/audioplaylist.h" #include "ardour/audioregion.h" #include "ardour/crossfade.h" +#include "ardour/region_sorters.h" #include "ardour/session.h" #include "pbd/enumwriter.h" @@ -1080,3 +1081,45 @@ AudioPlaylist::copy_dependents (const vector<TwoRegions>& old_and_new, boost::sh other_audio->add_crossfade (new_xfade); } } + +void +AudioPlaylist::pre_combine (vector<boost::shared_ptr<Region> >& originals, boost::shared_ptr<Region> compound_region) +{ + /* sort the originals into time order */ + + RegionSortByPosition cmp; + boost::shared_ptr<AudioRegion> ar; + boost::shared_ptr<AudioRegion> cr; + + if ((cr = boost::dynamic_pointer_cast<AudioRegion> (compound_region)) == 0) { + return; + } + + sort (originals.begin(), originals.end(), cmp); + + ar = boost::dynamic_pointer_cast<AudioRegion> (originals.front()); + + /* copy the fade in of the first into the compound region */ + + if (ar) { + cr->set_fade_in (ar->fade_in()); + + /* disable the fade in of the first */ + + ar->set_fade_in_active (false); + } + + ar = boost::dynamic_pointer_cast<AudioRegion> (originals.front()); + + 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); + } +} + +void +AudioPlaylist::pre_uncombine (vector<boost::shared_ptr<Region> >& originals, boost::shared_ptr<Region> compound_region) +{ +} diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc index 4a5405841f..3ca4fddfb1 100644 --- a/libs/ardour/playlist.cc +++ b/libs/ardour/playlist.cc @@ -38,6 +38,7 @@ #include "ardour/session.h" #include "ardour/region.h" #include "ardour/region_factory.h" +#include "ardour/region_sorters.h" #include "ardour/playlist_factory.h" #include "ardour/playlist_source.h" #include "ardour/transient_detector.h" @@ -65,40 +66,7 @@ struct ShowMeTheList { string name; }; -struct RegionSortByLayer { - bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) { - return a->layer() < b->layer(); - } -}; - -struct RegionSortByLayerWithPending { - bool operator () (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) { - - double p = a->layer (); - if (a->pending_explicit_relayer()) { - p += 0.5; - } - - double q = b->layer (); - if (b->pending_explicit_relayer()) { - q += 0.5; - } - - return p < q; - } -}; - -struct RegionSortByPosition { - bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) { - return a->position() < b->position(); - } -}; -struct RegionSortByLastLayerOp { - bool operator() (boost::shared_ptr<Region> a, boost::shared_ptr<Region> b) { - return a->last_layer_op() < b->last_layer_op(); - } -}; void Playlist::make_property_quarks () @@ -3160,6 +3128,7 @@ Playlist::combine (const RegionList& r) uint32_t layer = 0; framepos_t earliest_position = max_framepos; vector<TwoRegions> old_and_new_regions; + vector<boost::shared_ptr<Region> > originals; string parent_name; string child_name; uint32_t max_level = 0; @@ -3193,6 +3162,7 @@ Playlist::combine (const RegionList& r) boost::shared_ptr<Region> copied_region = RegionFactory::create (original_region, false); old_and_new_regions.push_back (TwoRegions (original_region,copied_region)); + originals.push_back (original_region); RegionFactory::add_compound_association (original_region, copied_region); @@ -3254,6 +3224,12 @@ Playlist::combine (const RegionList& r) remove_region (*i); } + /* do type-specific stuff with the originals and the new compound + region + */ + + pre_combine (originals, compound_region); + /* add the new region at the right location */ add_region (compound_region, earliest_position); |