Fix up gain envelope handling with region split. Fixes #3306.
authorCarl Hetherington <carl@carlh.net>
Tue, 27 Jul 2010 02:11:15 +0000 (02:11 +0000)
committerCarl Hetherington <carl@carlh.net>
Tue, 27 Jul 2010 02:11:15 +0000 (02:11 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@7510 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/audioregion.cc
libs/ardour/playlist.cc
libs/ardour/region.cc

index 8c66591fa771a0730b0e812854ab4351ce3b491a..f0219ce729aa362c978e4bf999223a469d33bdff 100644 (file)
@@ -160,8 +160,10 @@ AudioRegion::AudioRegion (boost::shared_ptr<const AudioRegion> other, nframes64_
        , _automatable (other->session())
        , _fade_in (new AutomationList (*other->_fade_in))
        , _fade_out (new AutomationList (*other->_fade_out))
-         /* XXX is this guaranteed to work for all values of offset+offset_relative? */
-       , _envelope (new AutomationList (*other->_envelope, _start, _start + _length))
+         /* As far as I can see, the _envelope's times are relative to region position, and have nothing
+            to do with sources (and hence _start).  So when we copy the envelope, we just use the supplied offset.
+         */
+       , _envelope (new AutomationList (*other->_envelope, offset, other->_length))
        , _fade_in_suspended (0)
        , _fade_out_suspended (0)
 {
index e55b82c06b819a6f34528638f1acd6cd276547e3..8ea84b96bfc0219223ca2ae9a816a973cad2ea57 100644 (file)
@@ -1401,12 +1401,15 @@ Playlist::_split_region (boost::shared_ptr<Region> region, framepos_t playlist_p
        {
                PropertyList plist;
                
-               plist.add (Properties::start, region->start());
                plist.add (Properties::length, before);
                plist.add (Properties::name, before_name);
                plist.add (Properties::left_of_split, true);
-               
-               left = RegionFactory::create (region, plist);
+
+               /* note: we must use the version of ::create with an offset here,
+                  since it supplies that offset to the Region constructor, which
+                  is necessary to get audio region gain envelopes right.
+               */
+               left = RegionFactory::create (region, 0, plist);
        }
 
        RegionFactory::region_name (after_name, region->name(), false);
@@ -1414,12 +1417,12 @@ Playlist::_split_region (boost::shared_ptr<Region> region, framepos_t playlist_p
        {
                PropertyList plist;
                
-               plist.add (Properties::start, region->start() + before);
                plist.add (Properties::length, after);
                plist.add (Properties::name, after_name);
                plist.add (Properties::right_of_split, true);
 
-               right = RegionFactory::create (region, plist);
+               /* same note as above */
+               right = RegionFactory::create (region, before, plist);
        }
 
        add_region_internal (left, region->position());
index 6dc090ce3cc7b8588fedfe92f5adf62453f20ca0..234dddcc45bef1fa7ecca300df020cd15e303f11 100644 (file)
@@ -247,10 +247,10 @@ Region::Region (const SourceList& srcs)
 
 /** Create a new Region from part of an existing one, starting at one of two places:
 
-    if @param offset_relative is true, then the start within @param other is given by @param offset
-    (i.e. relative to the start of @param other's sources, the start is @param offset + @param other.start()
+    if \a offset_relative is true, then the start within \a other is given by \a offset
+    (i.e. relative to the start of \a other's sources, the start is \a offset + \a other.start()
 
-    if @param offset_relative is false, then the start within the source is given @param offset.
+    if @param offset_relative is false, then the start within the source is given \a offset.
 */
 Region::Region (boost::shared_ptr<const Region> other, frameoffset_t offset, bool offset_relative)
        : SessionObject(other->session(), other->name())