permit different sizes for audio playback & capture buffers
[ardour.git] / libs / ardour / audioregion.cc
index 3430eb5128a7761ef315da1e485b4ed1cff9d478..0ef79b7018807e234b0c64201c80f009f4893d77 100644 (file)
@@ -243,6 +243,9 @@ AudioRegion::post_set ()
                set_default_fade_in ();
                _right_of_split = false;
        }
+
+       /* If _length changed, adjust our gain envelope accordingly */
+       _envelope->truncate_end (_length);
 }
 
 void
@@ -314,12 +317,6 @@ AudioRegion::read (Sample* buf, framepos_t timeline_position, framecnt_t cnt, in
        return _read_at (_sources, _length, buf, 0, 0, _position + timeline_position, cnt, channel, 0, 0, ReadOps (0));
 }
 
-framecnt_t
-AudioRegion::read_with_ops (Sample* buf, framepos_t file_position, framecnt_t cnt, int channel, ReadOps rops) const
-{
-       return _read_at (_sources, _length, buf, 0, 0, file_position, cnt, channel, 0, 0, rops);
-}
-
 framecnt_t
 AudioRegion::read_at (Sample *buf, Sample *mixdown_buffer, float *gain_buffer,
                      framepos_t file_position, framecnt_t cnt, uint32_t chan_n,
@@ -691,54 +688,6 @@ AudioRegion::_set_state (const XMLNode& node, int version, PropertyChange& what_
        return 0;
 }
 
-bool
-AudioRegion::set_property (const PropertyBase& prop)
-{
-       DEBUG_TRACE (DEBUG::Properties,  string_compose ("audio region %1 set property %2\n", _name.val(), prop.property_name()));
-
-       if (prop == Properties::envelope_active.property_id) {
-               bool val = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
-               if (val != _envelope_active) {
-                       _envelope_active = val;
-                       return true;
-               }
-       } else if (prop == Properties::default_fade_in.property_id) {
-               bool val = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
-               if (val != _default_fade_in) {
-                       _default_fade_in = val;
-                       return true;
-               }
-       } else if (prop == Properties::default_fade_out.property_id) {
-               bool val = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
-               if (val != _default_fade_out) {
-                       _default_fade_out = val;
-                       return true;
-               }
-       } else if (prop == Properties::fade_in_active.property_id) {
-               bool val = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
-               if (val != _fade_in_active) {
-                       _fade_in_active = val;
-                       return true;
-               }
-       } else if (prop == Properties::fade_out_active.property_id) {
-               bool val = dynamic_cast<const PropertyTemplate<bool>*>(&prop)->val();
-               if (val != _fade_out_active) {
-                       _fade_out_active = val;
-                       return true;
-               }
-       } else if (prop == Properties::scale_amplitude.property_id) {
-               gain_t val = dynamic_cast<const PropertyTemplate<gain_t>*>(&prop)->val();
-               if (val != _scale_amplitude) {
-                       _scale_amplitude = val;
-                       return true;
-               }
-       } else {
-               return Region::set_property (prop);
-       }
-       
-       return false;
-}
-
 int
 AudioRegion::set_state (const XMLNode& node, int version)
 {
@@ -996,15 +945,18 @@ AudioRegion::recompute_at_end ()
        _envelope->set_max_xval (_length);
         _envelope->thaw ();
 
+        if (_left_of_split) {
+                set_default_fade_out ();
+                _left_of_split = false;
+        } else if (_fade_out->back()->when > _length) {
+                _fade_out->extend_to (_length);
+                send_change (PropertyChange (Properties::fade_out));
+        }
+        
        if (_fade_in->back()->when > _length) {
                _fade_in->extend_to (_length);
                send_change (PropertyChange (Properties::fade_in));
        }
-
-       if (_fade_out->back()->when > _length) {
-               _fade_out->extend_to (_length);
-               send_change (PropertyChange (Properties::fade_out));
-       }
 }
 
 void
@@ -1014,7 +966,10 @@ AudioRegion::recompute_at_start ()
 
        _envelope->truncate_start (_length);
 
-       if (_fade_in->back()->when > _length) {
+        if (_right_of_split) {
+                set_default_fade_in ();
+                _right_of_split = false;
+        } else if (_fade_in->back()->when > _length) {
                _fade_in->extend_to (_length);
                send_change (PropertyChange (Properties::fade_in));
        }