restore compound region fade, where possible, to constituent regions, after uncombine
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 25 May 2011 22:44:30 +0000 (22:44 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 25 May 2011 22:44:30 +0000 (22:44 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@9593 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/audio_playlist.cc
libs/ardour/playlist.cc

index f73bbf17e59170e75667dcd79452e3ba731b89bb..06eca9fb92120cf02eb3ad029c6fe205fa95bde8 100644 (file)
@@ -1109,7 +1109,7 @@ AudioPlaylist::pre_combine (vector<boost::shared_ptr<Region> >& originals, boost
                ar->set_fade_in_active (false);
        }
 
-       ar = boost::dynamic_pointer_cast<AudioRegion> (originals.front());
+       ar = boost::dynamic_pointer_cast<AudioRegion> (originals.back());
 
        if (ar) {
                /* copy the fade out of the last into the compound region */
@@ -1122,4 +1122,48 @@ AudioPlaylist::pre_combine (vector<boost::shared_ptr<Region> >& originals, boost
 void
 AudioPlaylist::pre_uncombine (vector<boost::shared_ptr<Region> >& originals, boost::shared_ptr<Region> compound_region)
 {
+       boost::shared_ptr<AudioRegion> ar;
+       boost::shared_ptr<AudioRegion> cr = boost::dynamic_pointer_cast<AudioRegion>(compound_region);
+
+       if (!cr) {
+               return;
+       }
+
+       /* no need to call clear_changes() on the originals because that is
+        * done within Playlist::uncombine ()
+        */
+
+       if ((ar = boost::dynamic_pointer_cast<AudioRegion> (originals.front())) != 0) {
+
+               /* copy the compound region's fade in back into the first
+                  original region.
+               */
+
+               if (cr->fade_in()->back()->when <= ar->length()) {
+                       /* don't do this if the fade is longer than the
+                        * region
+                        */
+                       ar->set_fade_in (cr->fade_in());
+               }
+
+               ar->set_fade_in_active (true);
+               _session.add_command (new StatefulDiffCommand (originals.front()));
+       }
+
+       if ((ar = boost::dynamic_pointer_cast<AudioRegion> (originals.back())) != 0) {
+
+               /* copy the compound region's fade out back into the last
+                  original region.
+               */
+
+               if (cr->fade_out()->back()->when <= ar->length()) {
+                       /* don't do this if the fade is longer than the
+                        * region
+                        */
+                       ar->set_fade_out (cr->fade_out());
+               }
+
+               ar->set_fade_out_active (true);
+               _session.add_command (new StatefulDiffCommand (originals.back()));
+       }
 }
index 3ca4fddfb12a743cab9ac3e8684363db749908e9..3c241cf846a05d0d55277515c76fb298bf915f2f 100644 (file)
@@ -3281,7 +3281,6 @@ Playlist::uncombine (boost::shared_ptr<Region> target)
 
                boost::shared_ptr<Region> current (*i);
 
-
                RegionFactory::CompoundAssociations::iterator ca = cassocs.find (*i);
 
                if (ca == cassocs.end()) {
@@ -3384,6 +3383,8 @@ Playlist::uncombine (boost::shared_ptr<Region> target)
                originals.push_back (original);
        }
 
+       pre_uncombine (originals, target);
+
        in_partition = true;
        freeze ();