Use a few shared_ptrs to make things slightly neater.
[ardour.git] / libs / ardour / crossfade.cc
index 9cbbbf1898156ccb057668986d31be60db73d032..b2301b7167bed7cfb12208277e041bcf1e72c713 100644 (file)
@@ -85,9 +85,8 @@ Crossfade::operator== (const Crossfade& other)
 
 Crossfade::Crossfade (boost::shared_ptr<AudioRegion> in, boost::shared_ptr<AudioRegion> out,
                      framecnt_t length,
-                     framepos_t position,
                      AnchorPoint ap)
-       : AudioRegion (in->session(), position, length, in->name() + string ("<>") + out->name())
+       : AudioRegion (in->session(), 0, length, in->name() + string ("<>") + out->name())
        , CROSSFADE_DEFAULT_PROPERTIES
        , _fade_in (Evoral::Parameter(FadeInAutomation)) // linear (gain coefficient) => -inf..+6dB
        , _fade_out (Evoral::Parameter(FadeOutAutomation)) // linear (gain coefficient) => -inf..+6dB
@@ -586,8 +585,8 @@ Crossfade::compute (boost::shared_ptr<AudioRegion> a, boost::shared_ptr<AudioReg
                        } else {
                                _position = top->last_frame() - short_xfade_length;
                        }
-
-                       _length = min (short_xfade_length, top->length());
+                       
+                       set_xfade_length (min (short_xfade_length, top->length()));
                        _follow_overlap = false;
                        _anchor_point = EndOfIn;
                        _active = true;
@@ -621,7 +620,7 @@ Crossfade::compute (boost::shared_ptr<AudioRegion> a, boost::shared_ptr<AudioReg
                        _in = top;
                        _out = bottom;
                        _position = top->first_frame();
-                       _length = min (short_xfade_length, top->length());
+                       set_xfade_length (min (short_xfade_length, top->length()));
                        _follow_overlap = false;
                        _anchor_point = StartOfIn;
                        _active = true;
@@ -670,11 +669,11 @@ Crossfade::compute (boost::shared_ptr<AudioRegion> a, boost::shared_ptr<AudioReg
 
                        if (model == FullCrossfade) {
                                _position = bottom->first_frame(); // "{"
-                               _length = _out->first_frame() + _out->length() - _in->first_frame();
+                               set_xfade_length (_out->first_frame() + _out->length() - _in->first_frame());
                                /* leave active alone */
                                _follow_overlap = true;
                        } else {
-                               _length = min (short_xfade_length, top->length());
+                               set_xfade_length (min (short_xfade_length, top->length()));
                                _position = top->last_frame() - _length;  // "]" - length
                                _active = true;
                                _follow_overlap = false;
@@ -694,11 +693,11 @@ Crossfade::compute (boost::shared_ptr<AudioRegion> a, boost::shared_ptr<AudioReg
                        _anchor_point = StartOfIn;
 
                        if (model == FullCrossfade) {
-                               _length = _out->first_frame() + _out->length() - _in->first_frame();
+                               set_xfade_length (_out->first_frame() + _out->length() - _in->first_frame());
                                /* leave active alone */
                                _follow_overlap = true;
                        } else {
-                               _length = min (short_xfade_length, top->length());
+                               set_xfade_length (min (short_xfade_length, top->length()));
                                _active = true;
                                _follow_overlap = false;
 
@@ -778,9 +777,7 @@ Crossfade::set_state (const XMLNode& node, int /*version*/)
        PropertyChange what_changed;
        framepos_t val;
 
-       if ((prop = node.property (X_("id")))) {
-               _id = prop->value();
-       }
+       set_id (node);
 
        if ((prop = node.property ("position")) != 0) {
                sscanf (prop->value().c_str(), "%" PRId64, &val);