summaryrefslogtreecommitdiff
path: root/libs/ardour/audio_playlist.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-05-26 17:22:22 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-05-26 17:22:22 +0000
commitd6be900da002cde17570e742bcc48f1588f73dc9 (patch)
tree8996b368649d87610329a54385960ee3c013204f /libs/ardour/audio_playlist.cc
parent92ede6153eaf7eaae359a456307f697d04e2fcb7 (diff)
more combine/uncombine fixes including making uncombine push the compound region gain level into the constituents and doing the right thing when we uncombine in a playlist other than the one in which the compound region was created
git-svn-id: svn://localhost/ardour2/branches/3.0@9601 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/audio_playlist.cc')
-rw-r--r--libs/ardour/audio_playlist.cc67
1 files changed, 40 insertions, 27 deletions
diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc
index 59c791b8fb..7e60930e2d 100644
--- a/libs/ardour/audio_playlist.cc
+++ b/libs/ardour/audio_playlist.cc
@@ -1092,7 +1092,7 @@ AudioPlaylist::pre_combine (vector<boost::shared_ptr<Region> >& copies)
ar = boost::dynamic_pointer_cast<AudioRegion> (copies.front());
- /* copy the fade in of the first into the compound region */
+ /* disable fade in of the first region */
if (ar) {
ar->set_fade_in_active (false);
@@ -1100,6 +1100,8 @@ AudioPlaylist::pre_combine (vector<boost::shared_ptr<Region> >& copies)
ar = boost::dynamic_pointer_cast<AudioRegion> (copies.back());
+ /* disable fade out of the last region */
+
if (ar) {
ar->set_fade_out_active (false);
}
@@ -1124,7 +1126,6 @@ AudioPlaylist::post_combine (vector<boost::shared_ptr<Region> >& originals, boos
if (ar) {
cr->set_fade_in (ar->fade_in());
- ar->set_fade_in_active (false);
}
ar = boost::dynamic_pointer_cast<AudioRegion> (originals.back());
@@ -1132,13 +1133,13 @@ AudioPlaylist::post_combine (vector<boost::shared_ptr<Region> >& originals, boos
if (ar) {
/* copy the fade out of the last into the compound region */
cr->set_fade_out (ar->fade_out());
- ar->set_fade_out_active (false);
}
}
void
AudioPlaylist::pre_uncombine (vector<boost::shared_ptr<Region> >& originals, boost::shared_ptr<Region> compound_region)
{
+ RegionSortByPosition cmp;
boost::shared_ptr<AudioRegion> ar;
boost::shared_ptr<AudioRegion> cr = boost::dynamic_pointer_cast<AudioRegion>(compound_region);
@@ -1146,41 +1147,53 @@ AudioPlaylist::pre_uncombine (vector<boost::shared_ptr<Region> >& originals, boo
return;
}
+ sort (originals.begin(), originals.end(), cmp);
+
/* 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) {
+ for (vector<boost::shared_ptr<Region> >::iterator i = originals.begin(); i != originals.end(); ++i) {
- /* 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());
+ if ((ar = boost::dynamic_pointer_cast<AudioRegion> (*i)) == 0) {
+ continue;
}
- ar->set_fade_in_active (true);
- _session.add_command (new StatefulDiffCommand (originals.front()));
- }
+ /* scale the uncombined regions by any gain setting for the
+ * compound one.
+ */
- if ((ar = boost::dynamic_pointer_cast<AudioRegion> (originals.back())) != 0) {
+ ar->set_scale_amplitude (ar->scale_amplitude() * cr->scale_amplitude());
- /* copy the compound region's fade out back into the last
- original region.
- */
+ if (i == originals.begin()) {
+
+ /* 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());
+ }
+
+
+ } else if (*i == originals.back()) {
+
+ /* 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());
+ }
- 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()));
+ _session.add_command (new StatefulDiffCommand (*i));
}
}